-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
Please provide an ECMAScript module #500
Comments
Happy to look into this. Do you have any recommendations for tools to use? |
I roughed out a version of this. I couldn't maintain the JSON imports so I had to convert those files to TypeScript. I don't know if the emitted JavaScript will fit all the import usage patterns for your users, either. I would note that build optimization is likely not to realize much savings with this library. The bulk of the library is the "entities" file and appears to be widely used, which would be hard optimize away. For example, I built my own private project which imports the entities library via the commonmark library (which uses
I hope this helps and is not just noise. |
The JSON imports are also a problem if you want to import this great lib from skypack.dev |
I just released a new version, and decided against making it ESM-only. I am still looking for tooling to add an optional ESM version, but haven't found a good option yet (open to suggestions!). For the original motivation of the issue: Webpack tree shaking supports CommonJS modules. The new release doesn't eliminate the JSON imports yet, but that is on my list. |
@pe8ter This is super helpful, thanks for looking into it. The new version actually would benefit from this quite a bit, as decoding now uses a separate data structure from encoding. Do you know of a way to actually generate two sets of files? |
@fb55 I don't understand what the two sets of files would be. Could you clarify please? |
Same as in your example output: One for ES5 (CommonJS), one for ES2015 (ES modules) |
I see. You would need two tsconfig.json files with different compiler options and different output directories. Since this package is consumable by Node.js, you would need to choose which output is the default format and specify the entry point to that built JavaScript in your package.json. Anyone that needs an alternate version would need to configure their builds to specifically reference that version of the built code. |
I think you should make the switch and go ESM only A ESM wrapper isn't as good. It only masks the problem. commonjs won't go await as long as we keep supporting it. It's time to make the move |
|
CommonJS modules cannot be optimized with webpack, for example, and the bundle size of the application is potentially larger.
As of Angular 10, a warning is emitted when building an app that imports entities.
The text was updated successfully, but these errors were encountered: