Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESM support for Node #331

Closed
stalniy opened this issue May 27, 2020 · 0 comments
Closed

ESM support for Node #331

stalniy opened this issue May 27, 2020 · 0 comments
Milestone

Comments

@stalniy
Copy link
Owner

stalniy commented May 27, 2020

Node 14 supports ESM out of the box and dual package loading, so what I need to do is to add exports field to every package. This is a new way to point to package entry points. While the main file of the module uses CommonJS, I need to use mjs extension for all ESM files. This is important, otherwise Node thinks that the file uses commonjs even in mjs file.

Example for @casl/ability

{
  "exports": {
    ".": {
      "import": "./dist/es6/index.mjs",
      "require": "./dist/umd/index.js"
    },
    "./extra": {
      "import": "./dist/es6/extra.mjs",
      "require": "./dist/umd/extra.js"
    }
  }
}

The same needs to be done for sift.js, otherwise the package cannot be loaded

@stalniy stalniy changed the title ESM for Node ESM support for Node May 27, 2020
stalniy added a commit to stalniy/casl-examples that referenced this issue May 27, 2020
To understand why check stalniy/casl#331. Also adds note that it's possible to use any package manager to run an example
@stalniy stalniy added this to the v5 milestone Jul 16, 2020
stalniy added a commit that referenced this issue Aug 20, 2020
@stalniy stalniy closed this as completed Aug 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant