shellscape / jsx-email

Build emails with a delightful DX
https://jsx.email
MIT License
897 stars 28 forks source link

TS CommonJS builds broken with a Node.js backend #122

Closed affanshahid closed 6 months ago

affanshahid commented 6 months ago

Expected Behavior

Typescript apps built using the CommonJS output should run.

Actual Behavior

The app crashes with the following error:

Error [ERR_REQUIRE_ESM]: require() of ES Module /node_modules/.pnpm/shikiji@0.8.7/node_modules/shikiji/dist/index.mjs not supported.

Additional Information

You can reproduce the error in the reproduction by running npm run produce-error in the terminal (tsc && node ./dist/main.js). I tried different values in tsconfig to somehow work around this but nothing worked, for different reasons.

shellscape commented 6 months ago

Thanks for raising the issue. We'll take a look at a fix for this.

tandpfun commented 6 months ago

@shellscape I'm still getting a similar issue on 1.7.2 with the same "shikiji" package in NextJS, but with a different file.

export 'addClassToHast' (reexported as 'addClassToHast') was not found in './core.mjs' (module has no exports)

Import trace for requested module:
./node_modules/.pnpm/shikiji@0.8.7/node_modules/shikiji/dist/index.mjs
./node_modules/.pnpm/jsx-email@1.7.2_@types+node@20.10.7_@types+react-dom@18.2.18_@types+react@18.2.47_react@18.2.0/node_modules/jsx-email/dist/index.mjs
./src/app/api/admin/email/send-test/route.ts
shellscape commented 6 months ago

@tandpfun that's a separate issue, please open a new issue with a reproduction