-
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
fix: remove exports["."].module
to be compatible with resolution policy of nodejs offical & bundlers like vite
#13
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 220b353:
|
package.json
Outdated
@@ -19,7 +19,7 @@ | |||
"./package.json": "./package.json", | |||
".": { | |||
"types": "./dist/src/index.d.ts", | |||
"module": "./dist/index.modern.js", | |||
"module": "./dist/index.modern.mjs", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was intentional to have .js
, otherwise it will break in some old bundlers.
Now, time passed. I think if this causes a problem, we should remove it entirely.
"module": "./dist/index.modern.mjs", |
Does that fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dai-shi yes, it does fix.
Or could we add "type": "module"
to package.json
? this can also fix this issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was intentional to have
.js
, otherwise it will break in some old bundlers. Now, time passed. I think if this causes a problem, we should remove it entirely.
does that old bundler consume exports
field? what I changed is only the one in exports
field, the module
field is kept as it is now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"type": "module"
might also break old bundlers. We keep cjs default for all jotai packages.
Now, would you be willing to fix more jotaijs/* packages? Some of them are not actively maintained. If the repo is migrated to pnpm from yarn, it means it's maintained.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dai-shi I find another solution, we can just reorder the keys of exports["."]
, please review latest commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order was important for a bundler to pick "module" before "import".
So, instead of reordering, let's remove it.
Alright, let's wait for other contributors for other repos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌 I've removed it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
Can you also remove "postcompile" script because we no longer need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Can you also remove "postcompile" script because we no longer need it?
I don't think so as "module": "./dist/index.modern.js"
at Line 16 is not removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, nice catch. Yeah, that might be good for very old bundlers (though, I'm not sure if we need to keep supporting it.)
exports["."]
to be compatible with resolution policy of nodejs offical & bundlers like vite
exports["."]
to be compatible with resolution policy of nodejs offical & bundlers like vite
exports["."].module
to be compatible with resolution policy of nodejs offical & bundlers like vite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
some build tools like
vite
would fail if type of package is not explicit declared while file extension is.js
:@dai-shi please help review, thanks