Skip to content

Error: ES Modules may not assign module.exports or exports.*, Use ESM export syntax #765

@styfle

Description

@styfle

When using typescript with "module": "commonjs" in tsconfig.json, mixing ESM/CJS fails with the following error:

Error: ES Modules may not assign module.exports or exports.*, Use ESM export syntax

This does not match the behavior of tsc which allows mixed usage.

git clone https://github.com/uncurated-tests/ncc-ts-mixed-modules
cd ncc-ts-mixed-modules
yarn install

yarn run tsc
node dist/index.js # works

rm -rf dist

ncc build index.ts
node dist/index.js # fails

https://github.com/uncurated-tests/ncc-ts-mixed-modules

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions