Updated to 11.0.2 but seems like #84 is still an issue. operation files are missing the same ESM/CommonJS compatibility as main entry file. Or maybe it's not needed at all if there's a separate esm build?
#85 seemed to fix tsc compilation but we're now seeing issues in runtime.
We use mailosaur in e2e tests with playwright and vite so our actual tsconfig is "module": "esnext" and "moduleResolution": "bundler". But it doesn't work with "module": "NodeNext" either.
➜ mailosaur-esm-issue git:(main) ✗ pnpm run check-and-run
> check-and-run
> tsc && node ./dist/index.js
file:///Users/roman/Documents/dev/mailosaur-esm-issue/node_modules/.pnpm/mailosaur@11.0.2_@types+node@24.10.13/node_modules/mailosaur/esm/operations/analysis.js:52
module.exports = Analysis;
^
ReferenceError: module is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/Users/roman/Documents/dev/mailosaur-esm-issue/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///Users/roman/Documents/dev/mailosaur-esm-issue/node_modules/.pnpm/mailosaur@11.0.2_@types+node@24.10.13/node_modules/mailosaur/esm/operations/analysis.js:52:1
at ModuleJob.run (node:internal/modules/esm/module_job:413:25)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:660:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5)
Node.js v24.13.0
minimal repro: https://github.com/romansp/mailosaur-esm-issue
- Clone
- Execute
pnpm install
- Execute
pnpm run check-and-run. this will compile via tsc and run with node
Node.js version: v24.13.0
Updated to 11.0.2 but seems like #84 is still an issue.
operationfiles are missing the same ESM/CommonJS compatibility as main entry file. Or maybe it's not needed at all if there's a separateesmbuild?#85 seemed to fix
tsccompilation but we're now seeing issues in runtime.We use mailosaur in e2e tests with playwright and vite so our actual tsconfig is
"module": "esnext"and"moduleResolution": "bundler". But it doesn't work with"module": "NodeNext"either.minimal repro: https://github.com/romansp/mailosaur-esm-issue
pnpm installpnpm run check-and-run. this will compile viatscand run withnodeNode.js version: v24.13.0