Closed azu closed 4 years ago
Previously(pikacdn), the build file does not work because runtime error. Using skycdn resolve this issue.
require("isomorphic-unfetch");
const fs = require("fs");
const path = require("path");
const { compile } = require("uniroll");
const files = {
"/package.json": `{
"dependencies": {
"@textlint/kernel": "3.2.1",
"@textlint/textlint-plugin-markdown": "5.1.12",
"textlint-rule-no-todo": "2.0.1"
}
}`,
"/index.js": `
import Kernel from "@textlint/kernel";
import markdown from "@textlint/textlint-plugin-markdown";
import rule from "textlint-rule-no-todo";
const textlint = new Kernel.TextlintKernel();
textlint.lintText("- [ ] No TODO ", {
filePath: "/path/to/README.md",
ext: ".md",
plugins: [
{
pluginId: "markdown",
plugin: markdown
}
],
rules: [{
ruleId: "textlint-rule-no-todo",
rule: rule,
options: {}
}]
}).then(result => {
console.log("Output:");
console.log(JSON.stringify(result, null, 4));
}).catch(error => {
console.error(error);
});
`
};
(async () => {
const bundle = await compile({
useInMemory: true,
files,
input: "/index.js"
});
// return rollup object
const out = await bundle.generate({});
for (const i of out.output) {
if (i.type === "chunk") {
const outpath = path.join(process.cwd(), "out.js");
fs.writeFileSync(outpath, i.code);
}
}
})();
👍