question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature: support new package.json exports field

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:32
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

14reactions
kamleshchandnanicommented, Jun 23, 2021

Is there any plan to support this any time soon?

13reactions
huntiecommented, Aug 24, 2022

Hi all 👋, happy to share that exports field support is on our roadmap for the second half of 2022. We haven’t scheduled this work immediately, but once we have progress I will make sure to post an update here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Modules: Packages | Node.js v19.3.0 Documentation
The "exports" provides a modern alternative to "main" allowing multiple entry points to be defined, conditional entry resolution support between environments, ...
Read more >
Node.JS (New) Package.json Exports Field | by Thomas Juster
The exports field (or “export map”) provides a way to expose your package modules for different environments and JavaScript flavors WHILE ...
Read more >
Package exports - webpack
The exports field in the package.json of a package allows to declare which module should be used when using module requests like import...
Read more >
New package.json `exports` field not working with TypeScript
It is an upcoming feature of Typescript 4.5 which soon should be available: // package.json { "name": "my-package", "type": "module", ...
Read more >
Support "exports" field of package.json : WEB-40509 - YouTrack
According to change log of node 12.7.0, https://github.com/nodejs/node/pull/28568 has been merged, and new field named "exports" is defiend in package.json ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found