-
Notifications
You must be signed in to change notification settings - Fork 6
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
Use as ES6 module in browser? #22
Comments
Hi @borkdude 👋 |
I'll have a look later, just dropping this link as a note for now: https://dev.to/a0viedo/nodejs-typescript-and-esm-it-doesnt-have-to-be-painful-438e |
your project has no dependencies, the easiest way to have esm cjs interop if you compile to commonjs and have named exports: exports.x = x
exports.y = y or a default export: exports.default = {
x,
y
} another requirement is that the typescript project cannot use require (or it has to be shimmed). the current setup you have with tsc compiles to require this way, everything is consumable in both esm and cjs environments |
esbuild may be a solution to this:
|
I'd like to use this library in the squint playground. It seems I'm only able to do this via esm.sh:
example
The esm.sh service rewrites all the module.exports + require stuff to proper ES6 modules.
Would it be an idea to publish ES6 modules directly, such that this can be used from unpkg.com etc?
The text was updated successfully, but these errors were encountered: