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

node resolution not handling flat export maps for files and transient dependency imports #715

Closed
1 of 5 tasks
thescientist13 opened this issue Sep 6, 2021 · 0 comments · Fixed by #716
Closed
1 of 5 tasks
Assignees
Labels
alpha.2 bug Something isn't working CLI v0.16.0
Milestone

Comments

@thescientist13
Copy link
Member

thescientist13 commented Sep 6, 2021

Type of Change

  • New Feature Request
  • Documentation / Website
  • Improvement / Suggestion
  • Bug
  • Other (please clarify below)

Summary

Doing some discovery as part of #523 to validate Greenwood works correctly with a variety of frameworks and libraries, have a couple more improvements to update here regarding integration work in progress with Lion -ProjectEvergreen/greenwood-getting-started#45.

Details

"Flat" Export Map

Was getting an error that one Lion's export maps entries (./define) was not resolving correctly

es-module-shims.js:469 Uncaught (in promise) Error: Unable to resolve specifier '@lion/button/define' from http://localhost:1984/?0
    at throwUnresolved (es-module-shims.js:469)
    at resolve (es-module-shims.js:465)
    at es-module-shims.js:424
    at Array.map (<anonymous>)
    at es-module-shims.js:423
    at async loadAll (es-module-shims.js:237)
    at async topLevelLoad (es-module-shims.js:256)

Screen Shot 2021-09-06 at 10 52 23 AM

I think the issue is I was not correctly handling "flat" export maps, e.g.

Lit - each entry is an object

"exports": {
  ".": {
    "default": "./index.js"
  },
  "./async-directive.js": {
    "default": "./async-directive.js"
  },
  "./decorators.js": {
    "default": "./decorators.js"
  },
  "./decorators/custom-element.js": {
    "default": "./decorators/custom-element.js"
  },

  ...
}

Lion - each entry is a string

"exports": {
  ".": "./index.js",
  "./define": "./lion-calendar.js",
  "./translations/*": "./translations/*",
  "./test-helpers": "./test-helpers/index.js",
  "./docs/": "./docs/"
}  

Transient Imports

After fixing the above, I then saw that an import of a dependent package was not correctly getting updated in the import map when walking a module.

es-module-shims.js:469 Uncaught (in promise) Error: Unable to resolve specifier '@bundled-es-modules/message-format/MessageFormat.js' from http://localhost:1984/node_modules/@lion/localize/src/LocalizeManager.js
    at throwUnresolved (es-module-shims.js:469)
    at resolve (es-module-shims.js:465)
    at es-module-shims.js:424
    at Array.map (<anonymous>)
    at es-module-shims.js:423

Screen Shot 2021-09-06 at 10 54 48 AM

Not sure if this is just bad export map reading on my end, but presumably all import statements needs to be registered in the import map somewhere, right?


There might be some other fixes needed as part of working with MWC and the double scoped namespace bug seen, but will save that for another issue / PR.

@thescientist13 thescientist13 added bug Something isn't working CLI labels Sep 6, 2021
@thescientist13 thescientist13 added this to the 1.0 milestone Sep 6, 2021
@thescientist13 thescientist13 self-assigned this Sep 6, 2021
@thescientist13 thescientist13 changed the title node resolution not handling flat export maps and transient imports node resolution not handling flat export maps for files and transient dependency imports Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alpha.2 bug Something isn't working CLI v0.16.0
Projects
None yet
1 participant