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

Runtime's own key resolution should be at least somewhat defined #18

Open
panva opened this issue Oct 31, 2024 · 0 comments
Open

Runtime's own key resolution should be at least somewhat defined #18

panva opened this issue Oct 31, 2024 · 0 comments

Comments

@panva
Copy link

panva commented Oct 31, 2024

This is very much related to #5, it highlights its importance and issues in the module ecosystem stemming from runtimes such as Bun and Deno pretending to be Node.js

From the very example in the proposal

"exports": {
    "node": "./dist/node/index.js",
    "deno": "./dist/deno/index.js"
},

or an extended one

"exports": {
    "node": "./dist/node/index.js",
    "deno": "./dist/deno/index.js",
    "bun": "./dist/bun/index.js"
},

While lacking resolution for #5 and at least some prescribed lookup behaviour one would mistakenly think that the following means "everything but node loads from the webapi dist".

"exports": {
    "node": "./dist/node/index.js",
    "default": "./dist/webapi/index.js"
},

Unfortunately that is not the case. Only Node.js correctly loads its intended export, while both Bun and Deno load "node" in all three examples above because of their compatibility beliefs and undescribed key order matching (all runtimes just look from top to bottom for a first hit).

I believe the proposal needs #5 combined with at least some text around how the keys are to be used.

For example:

  • add "wintercg" or similar which effectively behaves as "default" does in the Node.js resolution algorithm
  • prescribe that runtimes must first look for their own key, then wintercg/default, and only then fallback on proprietary resolution algorithms

The alternative (today's behaviour) is that module authors need to maintain an ever growing list of keys in their package.json on the offchance that a new runtime is added that inherits from Deno or Bun in that they believe they can work with "node" exports

@panva panva changed the title Runtimes playing make-believe Runtime's own key resolution should be at least somewhat defined Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant