Skip to content

New defaultIsModuleExports option #948

@guybedford

Description

@guybedford

Feature Use Case

Currently with the CommonJS plugin you have to choose between Node.js style interop with CommonJS or browser style interop. There is no option that can work for both making compat mutually exclusive.

Feature Proposal

The idea would be for a defaultIsModuleExports: 'compat' option which uses the pattern:

import * as m from 'cjs';
const moduleExports = m.default || m;

Where the default is used if it exists, otherwise falling back to the namespace.

This might allow for compatibility with Node.js interop as well as Babel interop cases in more scenarios.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions