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

converted-esm/import-meta-resolve.js single-file CJS is unnecessarily huge due to non-ESM node_modules externals bundled by esbuild #9

Closed
danielweck opened this issue Feb 23, 2022 · 5 comments · Fixed by #10

Comments

@danielweck
Copy link

https://github.com/weiran-zsd/eslint-plugin-node/blob/master/lib/converted-esm/import-meta-resolve.js

Suggested fix: try esbuild externals
--external:./node_modules/*
(or be more selective if some externals are ESM instead of CJS dependencies)

See documentation: https://esbuild.github.io/api/#external

@danielweck
Copy link
Author

@danielweck
Copy link
Author

danielweck commented Feb 23, 2022

For example, the bundled NPM packages builtins, semver, and yallist are all CJS, not ESM:
https://unpkg.com/browse/builtins/
https://unpkg.com/browse/semver/
https://unpkg.com/browse/yallist/
... so they should be externalised from the esbuild bundle, which otherwise is a huge payload of hard-to-review (and trust) code shipped to developers / users of the esling-plugin-node fork.

@danielweck
Copy link
Author

ping @aladdin-add @voxpelli @giltayar
👍

Thanks for your work 😸

@danielweck
Copy link
Author

From 109KB down to 32KB, just by externalising CJS NPM packages builtins yallist and semver:

npx esbuild --platform=node --external:builtins --external:yallist --external:semver --bundle node_modules/import-meta-resolve/lib/resolve.js > lib/converted-esm/import-meta-resolve.js

=>

Screenshot 2022-02-23 at 07 10 02

@danielweck
Copy link
Author

Pull Request: #10

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 a pull request may close this issue.

1 participant