jspm / generator

JSPM Import Map Generator
Apache License 2.0
160 stars 20 forks source link

Installing `lit` from `esm.sh` provider is failing #335

Open JayaKrishnaNamburu opened 6 months ago

JayaKrishnaNamburu commented 6 months ago

Installation of lit package is failing right now when using esm.sh as a provider.

Expected

Installs the package and updates the import-map

Result

Fails with a error in resolving a import.

file:///workspaces/sandbox/node_modules/@jspm/generator/dist/generator-387fd949.js:1697
            throw new JspmError(`No '${subpath}' exports subpath defined in ${pkgUrl} resolving ${originalSpecifier}${importedFrom(parentUrl)}.`, "MODULE_NOT_FOUND");
                  ^

JspmError: No './css-tag' exports subpath defined in https://esm.sh/*@lit/reactive-element@2.0.2/ resolving @lit/reactive-element/css-tag imported from https://esm.sh/v135/@lit/reactive-element@2.0.2/X-ZS8q/esnext/reactive-element.mjs.
    at throwExportNotDefined (file:///workspaces/sandbox/node_modules/@jspm/generator/dist/generator-387fd949.js:1697:19)
    at Resolver.resolveExport (file:///workspaces/sandbox/node_modules/@jspm/generator/dist/generator-387fd949.js:1726:17)
    at async TraceMap.resolve (file:///workspaces/sandbox/node_modules/@jspm/generator/dist/generator-387fd949.js:2915:59)
    at async TraceMap.visit (file:///workspaces/sandbox/node_modules/@jspm/generator/dist/generator-387fd949.js:2719:26)
    at async file:///workspaces/sandbox/node_modules/@jspm/generator/dist/generator-387fd949.js:2756:13
    at async Promise.all (index 0)
    at async TraceMap.visit (file:///workspaces/sandbox/node_modules/@jspm/generator/dist/generator-387fd949.js:2751:9)
    at async file:///workspaces/sandbox/node_modules/@jspm/generator/dist/generator-387fd949.js:2756:13
    at async Promise.all (index 0)
    at async TraceMap.visit (file:///workspaces/sandbox/node_modules/@jspm/generator/dist/generator-387fd949.js:2751:9) {
  jspmError: true,
  code: 'MODULE_NOT_FOUND'
}

The resolution of the path /css-tag seems to failing. Could it be because the pacakge is exposing the modules with the file extension. https://unpkg.com/browse/@lit/reactive-element@2.0.2/package.json

"./css-tag.js": {
      "types": "./development/css-tag.d.ts",
      "node": {
        "development": "./node/development/css-tag.js",
        "default": "./node/css-tag.js"
      },
      "development": "./development/css-tag.js",
      "default": "./css-tag.js"
    },

Here is a reproduction for the bug https://codesandbox.io/p/devbox/list-esm-install-bug-y72sjm?file=%2Findex.js%3A4%2C18

guybedford commented 6 months ago

I've disabled the esm.sh provider test for now. I think this is an esm.sh issue actually //cc @ije