Skip to content

Compatibility with CommonJS modules that reexport transpiled ES modules #1116

@haoqunjiang

Description

@haoqunjiang

Expected Behavior

import foo from './reexport.cjs should get the default export from transpiled-esm.cjs.

Actual Behavior

The CJS plugin doesn't realize that the reexport.cjs should also be treated as an ES module.

Additional Information

See also vitejs/vite#2139 (comment)
Previously reported at #872

It seems quite like Improvement 7 in #481 but that issue only addresses the issue with external dependencies, not bundled dependencies.

I'm willing to write a third-party plugin or create a PR for the commonjs plugin to fix this issue.
But I couldn't figure out a solution by myself yet.
Could you provide some guidance?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions