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

feat: Add full ESM support via an import export condition #755

Closed
wants to merge 9 commits into from

Conversation

amannn
Copy link
Owner

@amannn amannn commented Jan 3, 2024

We currently support ESM partially. This PR investigates switching to bunchee in order to enable full ESM support.

TODO

  • Make sure entries share code as expected
  • Provide a separate development build with unminified errors (see https://twitter.com/jantimon/status/1745758514763469047). What are the side effects though? E.g. bundling with jest/vitest might get the prod build (to be verified). What if we rely on the production environment instead and ship full errors by default for other entry points? That would result in Next.js getting the smallest build, test runners getting unminified errors—and, users of use-intl (e.g. react-native) potentially also unminified errors. Should we ship a version where a condition like typeof process !== 'undefined' && process.env.NODE_ENV === 'production' is included in the bundle? Maybe ship development, production as well as default with with an uncompiled condition like typeof process !== 'undefined' && process.env.NODE_ENV === 'production' ? to support everything.
  • Make sure turbo works

Copy link

vercel bot commented Jan 3, 2024

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

Name Status Preview Comments Updated (UTC)
next-intl-docs ❌ Failed (Inspect) Mar 4, 2024 9:22am
next-intl-example-app-router ❌ Failed (Inspect) Mar 4, 2024 9:22am

@@ -21,7 +21,7 @@
"test": "TZ=Europe/Berlin vitest",
"lint": "pnpm run lint:source && pnpm run lint:package",
"lint:source": "eslint src test && tsc --noEmit",
"lint:package": "publint && attw --pack",
Copy link
Owner Author

Choose a reason for hiding this comment

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

  • Revert or use .mjs?

@@ -15,7 +15,7 @@
"test": "TZ=Europe/Berlin vitest",
"lint": "pnpm run lint:source && pnpm run lint:package",
"lint:source": "eslint src test && tsc --noEmit",
"lint:package": "publint && attw --pack",
Copy link
Owner Author

Choose a reason for hiding this comment

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

  • Revert or use .mjs?

@amannn amannn changed the title feat: Add import export condition for ESM support feat: Add import export condition to enable ESM support Jan 3, 2024
@amannn amannn changed the title feat: Add import export condition to enable ESM support feat: Add full ESM support via an import export condition Jan 12, 2024
# Conflicts:
#	packages/next-intl/package.json
#	packages/next-intl/plugin.d.ts
#	packages/next-intl/src/plugin.tsx
#	packages/use-intl/package.json
#	pnpm-lock.yaml
/** @type import('rollup').RollupOptions */
const config = {
input,
external: [/node_modules/, ...external],
output: {
dir: outDir + env,
format: 'cjs',
format,
entryFileNames: '[name]' + (format === 'es' ? '.mjs' : '.js'),
Copy link
Owner Author

Choose a reason for hiding this comment

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

Remove this

@amannn
Copy link
Owner Author

amannn commented Jun 11, 2024

Superseded by #1115

@amannn amannn closed this Jun 11, 2024
@amannn amannn deleted the feat/esm branch June 13, 2024 13:30
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.

1 participant