Skip to content

Commit 31c9247

Browse files
committed
test(ci): smoke-test the ESM bundle under Node's native loader
The existing validate-cjs smoke test loads the bundle with require(), whose CJS resolver tolerates extensionless subpath imports -- so it never caught the invalid ESM output that broke Node's native loader. Add an ESM counterpart that imports dist/es/index.mjs under the native loader and wire it into CI right after validate-cjs. Verified: the check passes on a healthy build and fails with ERR_MODULE_NOT_FOUND when a .js extension is stripped from a dayjs subpath import in the built output.
1 parent a36afba commit 31c9247

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ jobs:
3636
- name: Validate CJS bundle with Node ${{ env.NODE_VERSION }}
3737
run: yarn validate-cjs
3838

39+
- name: Validate ESM bundle with Node ${{ env.NODE_VERSION }}
40+
run: yarn validate-esm
41+
3942
- name: Validate translations
4043
run: yarn validate-translations
4144

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@
212212
"types:tests": "tsc --project tsconfig.test.json --noEmit",
213213
"validate-translations": "node scripts/validate-translations.js",
214214
"validate-cjs": "concurrently 'node scripts/validate-cjs-node-bundle.cjs' 'node scripts/validate-cjs-browser-bundle.cjs'",
215+
"validate-esm": "node scripts/validate-esm-node-bundle.mjs",
215216
"semantic-release": "semantic-release",
216217
"prepack": "yarn build",
217218
"examples:build": "yarn workspaces foreach -A --include '@stream-io/stream-chat-react-*' run build",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// ESM counterpart to validate-cjs-node-bundle.cjs.
2+
//
3+
// Node's native ESM loader is stricter than any bundler: it requires file
4+
// extensions on subpath imports of dependencies that ship no "exports" map
5+
// (e.g. `dayjs/plugin/calendar` must be written as `dayjs/plugin/calendar.js`).
6+
// Such specifiers resolve fine through Turbopack/Webpack/Vite but throw
7+
// ERR_MODULE_NOT_FOUND under Node — the same path Next.js takes when it loads
8+
// this package as a server external. Importing the built ESM bundle here catches
9+
// that class of breakage before it ships.
10+
11+
import '../dist/es/index.mjs';

0 commit comments

Comments
 (0)