-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
Add .cjs build output needed for commonjs environments #23325
Conversation
Looks good. The main/module field resolution also works across Node 14-16 with the usual suspects of Node tools like Next and Webpack (via CRA). It should be noted that commonjs users that use a bundler will have to also resolve files with a cjs extension if not already. Probably good to note this in the release notes alongside the new |
@CodyJasonBennett thanks for testing!
I tested this, all modern bundlers (even with commonjs) work this PR by default, no need for the user to do anything.
It's not there yet, it's just a rumor, mrdoob decides when he wants to go through with it 😛 |
Thanks! |
It's crazy how many dependencies This is slowly becoming a quite maintenance burden. Just yesterday I had to check when The more dependencies, the more often we'll have to run In fact, just by adding |
I've removed |
Thanks @mrdoob! It was the first library I came across hahah Even better you can set |
Like this? {
format: 'umd',
name: 'THREE',
file: 'build/three.js',
indent: '\t'
},
{
format: 'cjs',
name: 'THREE',
file: 'build/three.cjs',
indent: '\t'
} |
Yup! |
Related issue: Fixes #23324
Description
According to the docs one more thing is needed, an esm module must provide a
.cjs
file for commonjs environment.Added a short script that copies over
build/three.js
tobuild/three.cjs
.To test this, I've created a simple commonjs test environment:
cd
into itexports
fieldnpm i
npm start
137dev
should be the console output