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

Export map without '.' entry throws on self-referenntial deep imports #30633

Closed
MylesBorins opened this issue Nov 25, 2019 · 2 comments
Closed
Assignees
Labels
esm Issues and PRs related to the ECMAScript Modules implementation. help wanted Issues that need assistance from volunteers or PRs that need help to proceed.

Comments

@MylesBorins
Copy link
Contributor

MylesBorins commented Nov 25, 2019

package.json

{
  "name": " bada",
  "exports": {
    "./boom": "./lib/powder.mjs"
  }
}

index.mjs

import 'bada/boom'

Will throw with the error

Error: Cannot find package '$PACAKGE_NAME' imported from ...

Adding a dot export to the package.json makes thing work as expected

package.json
```json
{
  "name": " bada",
  "exports": {
   ".": "./ohnoes.lol",
    "./boom": "./lib/powder.mjs"
  }
}

Seems like this might be to spec (as currently written). I'm not sure that we want to enforce a "." main if folks don't need one (thinking about top level application), but at the very least we likely want to throw with a better error... lost some time debugging this.

@MylesBorins MylesBorins changed the title Export map without '.' entry throws Export map without '.' entry throws on self-referenntial deep imports Nov 25, 2019
@guybedford guybedford added esm Issues and PRs related to the ECMAScript Modules implementation. help wanted Issues that need assistance from volunteers or PRs that need help to proceed. labels Nov 25, 2019
MylesBorins added a commit to MylesBorins/lorem-demo that referenced this issue Nov 25, 2019
I was partially confused due to a potential spec bug
in package.exports that didn't take into account top-level
application (without a . main)

This now works and has a passing test.

Refs: nodejs/node#30633
@guybedford
Copy link
Contributor

Seems like this may be related to #30602.

@guybedford
Copy link
Contributor

Fixed in #31009.

DerekNonGeneric pushed a commit to DerekNonGeneric/loader339 that referenced this issue Feb 20, 2020
I was partially confused due to a potential spec bug
in package.exports that didn't take into account top-level
application (without a . main)

This now works and has a passing test.

Refs: nodejs/node#30633
DerekNonGeneric pushed a commit to DerekNonGeneric/loader339 that referenced this issue Feb 25, 2020
I was partially confused due to a potential spec bug
in package.exports that didn't take into account top-level
application (without a . main)

This now works and has a passing test.

Refs: nodejs/node#30633
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
esm Issues and PRs related to the ECMAScript Modules implementation. help wanted Issues that need assistance from volunteers or PRs that need help to proceed.
Projects
None yet
Development

No branches or pull requests

3 participants