This repository was archived by the owner on Oct 9, 2025. It is now read-only.
Commit 6a822a0
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 #14371 parent 6a23986 commit 6a822a0
1 file changed
+5
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
70 | 73 | | |
71 | 74 | | |
72 | 75 | | |
| |||
0 commit comments