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.

Support package.json#exports for specifying the default file.

See original GitHub issue

With Node.js supporting ES Modules there’s a new field in package.json called exports. This field will override the main field for ES Modules wanting to specify their “default” file. Currently jsDelivr supports jsdelivr, browser, or main field in package.json.

I’d suggest looking at supporting exports.default and other related fields as well:

From the Node docs:

The “exports” field provides an alternative to “main” where the package main entry point can be defined

If both “exports” and “main” are defined, the “exports” field takes precedence over “main”.

With this new standard I imagine we’ll see more packages using exports.browser and dropping browser.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:5
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
mightyiamcommented, Oct 17, 2020

@SukkaW I got confused with a different term.

1reaction
MartinKolarikcommented, Dec 9, 2021

This is now fully supported in esm mode: https://github.com/jsdelivr/jsdelivr/issues/18263#issuecomment-989898481 We’re considering adding this as an alternative main field in the regular mode.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Modules: Packages | Node.js v19.3.0 Documentation
In a package's package.json file, two fields can define entry points for a package: "main" and "exports" . Both fields apply to both...
Read more >
Package exports - webpack
The exports field in the package.json of a package allows to declare ... It replaces the default implementation that returns main field resp....
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.json - npm Docs
It's assumed that it's js, since you're writing a package.json file, and you can specify the engine using the "engines" field. (See below.) ......
Read more >
Package JSON Demystified - The 'Exports' Keyword - YouTube
In this Javascript tutorial on NPM Package. JSON we look at the ' EXPORTS ' keyword and how it helps us expose and...
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