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

fix: Bring back ESM build (and fix bundle size) #381

Merged
merged 2 commits into from
Jul 5, 2023
Merged

Conversation

amannn
Copy link
Owner

@amannn amannn commented Jul 5, 2023

No description provided.

@vercel
Copy link

vercel bot commented Jul 5, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
example-next-13-next-auth ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 5, 2023 4:30pm
next-intl-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 5, 2023 4:30pm
next-intl-example-next-13 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 5, 2023 4:30pm

@@ -18,26 +18,39 @@
"postpublish": "git checkout . && rm ./README.md"
},
"main": "dist/index.js",
"module": "dist/index.mjs",
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not used by Node.js, only by ESM-enabled bundlers.

"typings": "dist/index.d.ts",
"exports": {
".": {
"react-server": {
"node": "./dist/react-server/index.js",
Copy link
Owner Author

@amannn amannn Jul 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's important that this goes first, so it has priority over import when compiled under Node.js.

We're not 100% ESM-compatible: https://nodejs.org/api/esm.html#esm_mandatory_file_extensions

But we don't want to be ESM-compatible anyway, because Next.js itself isn't, therefore the bundler will crash when it encounters imports from Next.js.

Rather, we want to stay in CJS land for Node.js and only use import when bundling for the browser (webpack).

@amannn amannn marked this pull request as ready for review July 5, 2023 16:33
@amannn amannn merged commit 4d0fefc into main Jul 5, 2023
6 checks passed
@amannn amannn deleted the fix/bundle-size-esm branch July 5, 2023 16:34
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 this pull request may close these issues.

None yet

1 participant