Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Commit 6a822a0

Browse files
authored
fix: prioritize ESM build in package exports to fix webpack warnings (#481)
Updates package.json exports to default to the ESM build instead of CommonJS, resolving "Critical dependency: the request of a dependency is an expression" warnings in webpack builds. Changes: - Set "default" to ESM build (./dist/module/) preserving native import() - Add explicit "import" condition for ESM-aware bundlers - Add "types" condition for better TypeScript resolution - Keep "require" pointing to CommonJS for Node.js compatibility Tested on Next.js v15 with webpack (non-turbopack). Previous workaround required manual webpack config: ```js webpack: (config) => { config.resolve.mainFields = ['browser', 'module', 'main']; config.resolve.conditionNames = ['browser', 'module', 'import', 'default']; return config; } ``` This exports change eliminates the need for manual webpack configuration by making bundlers prefer the ES2020 build that preserves dynamic imports. Fixes: webpack "Critical dependency" warnings in issue #1437
1 parent 6a23986 commit 6a822a0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,11 @@
6565
},
6666
"exports": {
6767
".": {
68-
"node":"./dist/main/index.js",
69-
"browser": "./dist/module/index.js",
68+
"types": "./dist/module/index.d.ts",
69+
"import": "./dist/module/index.js",
70+
"browser": "./dist/module/index.js",
71+
"require": "./dist/main/index.js",
72+
"node": "./dist/main/index.js",
7073
"default": "./dist/main/index.js"
7174
},
7275
"./websocket": {

0 commit comments

Comments
 (0)