Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build es, cjs and d.ts bundles #51

Closed
wants to merge 3 commits into from

Conversation

microshine
Copy link

  1. This update allows compiling CJS, ES and D.TS bundles.

image

It makes possible to use modules for both types of nodejs modules - commonjs or module.

// commonjs
const base64 = require("@stablelib/base64");

// esm
import * as base64 from "@stablelib/base64";

and use modules using https://unpkg.com/ service

<script type="moduel">
  import * as base64 from "https://unpkg.com/@stablelib/base64?module";
</script>
  1. Each module publishes only compiled files

image

@dajiaji
Copy link

dajiaji commented May 25, 2022

@dchest Could you move forward this PR? I'd like to use this stablelib not on Node.js but on web browsers and Deno.

@dchest
Copy link
Member

dchest commented May 27, 2022

Thanks, I'm working on supporting es modules, but without rollup as it's super slow for me. Question: how would browser resolve dependencies? For example, the chacha package has these imports:

import { writeUint32LE } from "@stablelib/binary";
import { wipe } from "@stablelib/wipe";

What do you need to do to use this chacha.mjs from <script type="module">?

@dchest
Copy link
Member

dchest commented Jun 26, 2022

Also, we need to detect the system random number generator (Node or browser) at runtime, and we can't use asynchronous imports for Node's crypto in ES module.

@joshxyzhimself
Copy link

Maybe ESBuild instead of rollup? It's hella fast compared to webpack / rollup / etc.

https://esbuild.github.io/

image

I haven't used SWC but it might be a good option too.

https://swc.rs/docs/benchmarks

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants