mizchi / uniroll

Opinionated universal frontend bundler in browser
https://focused-raman-3ce115.netlify.com/
113 stars 5 forks source link

Rename Pika to skypack #10

Closed azu closed 4 years ago

azu commented 4 years ago
- https://cdn.pika.dev
+ https://cdn.skypack.dev

- rollup-plugin-pika-cdn-resolver
+ rollup-plugin-skypack-cdn-resolver

- babel-plugin-transform-import-to-pika-cdn
+ babel-plugin-transform-import-to-skypack-cdn
azu commented 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);
        }
    }
})();
mizchi commented 4 years ago

👍