Tests how different tools handle import thunk from 'redux-thunk' where redux-thunk@2 ships
both a CJS build (main: lib/index.js, has __esModule: true) and a native ESM build
(module: es/index.js, export default thunk).
npm install
| Script | Resolves via | is function? |
how |
|---|---|---|---|
npm run inspect |
require() directly |
- | raw shape: {__esModule:true, default:fn} |
npm run node |
main (Node ignores module) |
❌ | no interop |
npm run babel |
main via require() |
✅ | _interopRequireDefault at call site |
npm run esbuild:module |
module (native ESM) |
✅ | no interop needed - real ESM default |
npm run esbuild:main |
main (CJS + __esModule) |
❌ | no interop |
npm run webpack:module |
module (native ESM) |
✅ | no interop needed - real ESM default |
npm run webpack:main |
main (CJS + __esModule) |
❌ | no interop |
npm run typescript:cjs |
main via require() |
✅ | __importDefault at call site |
npm run typescript:esm |
main (NodeNext, no helpers) |
❌ | no interop helpers emitted |
| Script | Mode | Resolves via | is function? |
|---|---|---|---|
npm run jest:cjs |
CJS (babel-jest) | main |
✅ |
npm run jest:esm |
ESM (--experimental-vm-modules) |
main |
❌ |
npm run jest:esm:module |
ESM (--experimental-vm-modules) |
module |
💥 |
The resolver returns node_modules/redux-thunk/es/index.js via the module field, but Jest's
shouldLoadAsEsm() checks the file extension (.js) and the package's "type" field to
decide CJS vs ESM. redux-thunk@2 has neither .mjs nor "type": "module", so Jest treats it
as CJS and cjs-module-lexer chokes on the export statement.
npm run all