Skip to content
This repository has been archived by the owner on Dec 3, 2022. It is now read-only.

Add native ESM entry point #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marvinhagemeister
Copy link

@marvinhagemeister marvinhagemeister commented Jul 4, 2021

This PR adds an ESM entry point so that this library can be used with ES modules natively in node.

Explanation:

"exports": {
  // Main/default entry point
  ".": {
    "browser": "./dist/sourcemap-codec.umd.js",
    // Must be `.mjs` because our `package.json` doesn't include `"type": "module"`
    "import": "./dist/sourcemap-codec.mjs",
    // CommonJS entry point
    "require": "./dist/sourcemap-codec.umd.js"
  },
  // If any module wants to import `sourcemap-codec/package.json` for some reason
  // (grabbing package.version or something)
  "./package.json": "./package.json",
  // Old-style deep imports, like `require("sourcemap-codec/dist/sourcemap-codec.umd.js")`
  "./": "./"
},

Verified both CommonJS and ESM entries in node 12.18.0 locally.

Fixes #81 .

@wangjia184
Copy link

when can this PR be released in npm?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make ES module compatible with node core ESM loader
2 participants