Skip to content

Native ESM #292

Closed
Closed
@lukeed

Description

@lukeed

Hey there, trying to add support native ESM within uvu, and diff is the only blocker.

You have main/module setup, but in Node versions that support ESM, they're picking up the CommonJS/ main" build, which nests everything behind a default key.

To fix this, all you need to do is add this to your package.json file:

"export": {
  ".": {
    "import": "./lib/index.mjs",
    "require": "./lib/index.js"
  },
  "./package.json": "./package.json"
}

And then kick out an extra lib/index.mjs file with the same contents as lib/index.es6.js.

Check this repo for a simple reproduction.
It has nothing to do with uvu by the way, it's just how I uncovered the problem.

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