Skip to content
No description, website, or topics provided.
TypeScript JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows
__tests__
plugins
.gitignore
README.md
index.d.ts
index.ts
jest.config.js
package.json
rollup.config.js
tsconfig.json
webpack.config.js
yarn.lock

README.md

@mizchi/browserpack

You can compile frontend in browser.

npm install @mizchi/browserpack

Example

// Need globalThis.fetch in node
// import "isomorphic-unfetch";
import { compileToString } from "@mizchi/browserpack";

const code = await compileToString({
  entry: "/index.tsx",
  files: {
    "/index.tsx": `
      import { h, render } from "preact";
      import { useEffect } from "preact/hooks";
      function App() {
        useEffect(() => console.log("mounted"), []);
        return <div>App</div>
      }
      render(<App />, document.body);
    `,
    "/tsconfig.json": `{ "compilerOptions": { "target": "es5", "jsx": "react", "jsxFactory": "h" } }`,
    "/package.json": `{
      "dependencies": {
        "preact": "10.0.5"
      }
    }`
  }
});

eval(code);

TODO

  • Use rollup

LICENSE

MIT

You can’t perform that action at this time.