Commit 17ab6fe
committed
Fix "require is not defined" caused by dist/package.json type:module
ncc injects {"type":"module"} into dist/package.json when the source project is ESM, but the bundle itself is CJS format. Node then tries to run it as ESM and fails.
Add a postbuild hook that overwrites dist/package.json with {} to establish a CJS package boundary in dist/ without walking up to the root package.json.1 parent 8d0e47c commit 17ab6fe
2 files changed
Lines changed: 2 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
0 commit comments