Skip to content

Provide .mjs entry for native ESM #1217

Closed
@jaydenseric

Description

@jaydenseric

This will make it possible for packages dependant on graphql to in turn do the same for their consumers, without encountering babel/babel#7294.

Node.js with --experimental-modules can run ESM in .mjs files.

Essentially, package.json needs to go from this:

{
  "main": "index.js",
  "module": "module/index.js"
}

To this:

{
  "main": "index",
  "module": "index.mjs"
}

Sibling index.js (CJS) and index.mjs (ESM) files need to be published. Node.js will load the relevant file, looking up .mjs before .js for main if --experimental-modules is enabled.

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