-
-
Notifications
You must be signed in to change notification settings - Fork 760
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
Incorrect use of "module"/ESM in package.json #1110
Comments
I made a small repo to try and get jimp working with vite (requires proper ESM setup) and I was able to get it working. See: https://github.com/danielholmes/jimp-vite for the code and https://danielholmes.github.io/jimp-vite/ for the bundled example. Some notes on how I got it working:
I would be interested in submitting a PR with the relevant changes to get these packages working. So far it would be mostly simple changes:
I'm a little concerned that it might break developer's build systems that use these packages - I do think it should be classed as a breaking change. |
@danielholmes if you're still interested in fixing this I'm up for the PRs. As for breaking changes I'm fine with it for now. I plan to make a bunch of smaller breaking changes 0.x before a v1 release |
🚀 Issue was released in |
Expected Behavior
I expect the ESM bundle to include valid ESM code and thus when building with an ESM bundler or interacting with ESM based tools, it should work.
Current Behavior
ESM bundlers (such as rollup.js) produce a failure.
Failure Information (for bugs)
ES modules were added to the Javascript spec in 2015. To make use of them, people started adopting the
"module"
field in package.json. i.e. the following package.json excerpt tells users of this package to importes/index.js
if they require an ESM compatible source, otherwise usedist/index.js
:The problem in JIMP is that
es/index.js
isn't an ES module at all (View source) - it's a JS file using the CommonJS module format. This format was created for node.js but there have been a lot of tools such as browserify and babel created which allow you to use this format in the browser.There are various good technical reasons to want to support ESM. But from a practical standpoint there are a wave of tools gaining popularity which are built around ESM and JIMP will be left behind without properly supporting it (e.g. vite, esbuild, rollup).
Steps to Reproduce
I've created a minimal repo here: https://github.com/danielholmes/jimp-rollup which shows the problem in the rollup context.
npm ci
)npm run build
Context
0.16.2
18.12.1
(should be all though)Failure Logs
The text was updated successfully, but these errors were encountered: