这是indexloc提供的服务,不要输入任何密码
Skip to content

Esm/Cjs issue? #752

@yovanoc

Description

@yovanoc

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.<anonymous> (/app/packages/common/dist/Time.cjs:1:88)
    at /app/apps/api/dist/types/subscriptions/index.js:1:748

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions