Feature: support new package.json exports field
See original GitHub issueexports
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:
- Created 2 years ago
- Reactions:32
- Comments:13 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is there any plan to support this any time soon?
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.