Skip to content

Feature: support new package.json exports field #670

@jsamr

Description

@jsamr

exports field is a new standard which adoption will inevitably grow further as the ecosystem switches to full ESM as NodeJS 10 reaches EOL. It's probably best to support it before things break. Features:

  • Export submodules with sub-path exports;
  • Specific exports for both CJS and ESM modules.

Example of subpath exports from NodeJS docs:

{
  "type": "module",
  "name": "es-module-package",
  "main": "./main.js",
  "exports": {
    ".": "./main.js",
    "./submodule": "./src/submodule.js"
  }
}

The consumer of the library can now use:

import submodule from 'es-module-package/submodule';
// Loads ./node_modules/es-module-package/src/submodule.js

Metadata

Metadata

Assignees

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