Esm/Cjs issue?
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 275
- PR merge metrics
- No merged PRs in 30d
Description
First of all my entire codebase is in TS. I have an api which is in CJS. It imports a `common` library in my Monorepo that is in originally in ESM. (type: module in package.json) but this is build with tsup in js files in esm and cjs. BUT the problem is that my Time.cjs file import another file (Random.js) in my `common` lib and I think tsup don't correctly link this. It keeps the Random.js instead of Random.cjs. Or maybe am I missing something? Thanks in advance for the help.
```
Internal error occurred during message handling. Please check your implementation. Error [ERR_REQUIRE_ESM]: require() of ES Module /app/packages/common/dist/Random.js from /app/packages/common/dist/Time.cjs not supported.
Instead change the require of Random.js in /app/packages/common/dist/Time.cjs to a dynamic import() which is available in all CommonJS modules.
at Object. (/app/packages/common/dist/Time.cjs:1:88)
at /app/apps/api/dist/types/subscriptions/index.js:1:748
```
Contributor guide
Assessment
This issue has not been assessed yet.