Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Top-level package scope should inconsistent between stdout and HTML injection #2519

Open
guybedford opened this issue Apr 3, 2023 · 0 comments

Comments

@guybedford
Copy link
Member

For the following example:

package.json

{
  "name": "app",
  "exports": "./app.js"
}

with app.js containing:

import * as lit from 'lit';
console.log(lit);

Running:

jspm link app --stdout

Gives:

{
  "env": [
    "browser",
    "module",
    "production"
  ],
  "imports": {
    "lit": "https://ga.jspm.io/npm:lit@2.7.0/index.js",
    "app": "./app.js"
  },
  "scopes": {
    "https://ga.jspm.io/": {
      "@lit/reactive-element": "https://ga.jspm.io/npm:@lit/reactive-element@1.6.1/reactive-element.js",
      "lit-element/lit-element.js": "https://ga.jspm.io/npm:lit-element@3.3.0/lit-element.js",
      "lit-html": "https://ga.jspm.io/npm:lit-html@2.7.0/lit-html.js",
      "lit-html/is-server.js": "https://ga.jspm.io/npm:lit-html@2.7.0/is-server.js"
    }
  }
}

But if I provide an output HTML file:

jspm link app -o app.html

Then I get a different scope grouping:

<!doctype html>
<script async src="https://ga.jspm.io/npm:es-module-shims@1.7.1/dist/es-module-shims.js" crossorigin="anonymous"></script>
<script type="importmap">
{
  "imports": {
    "app": "./app.js"
  },
  "scopes": {
    "./": {
      "lit": "https://ga.jspm.io/npm:lit@2.7.0/index.js"
    },
    "https://ga.jspm.io/": {
      "@lit/reactive-element": "https://ga.jspm.io/npm:@lit/reactive-element@1.6.1/reactive-element.js",
      "lit-element/lit-element.js": "https://ga.jspm.io/npm:lit-element@3.3.0/lit-element.js",
      "lit-html": "https://ga.jspm.io/npm:lit-html@2.7.0/lit-html.js",
      "lit-html/is-server.js": "https://ga.jspm.io/npm:lit-html@2.7.0/is-server.js"
    }
  }
}
</script>
<script type="module">import 'my-app/test'</script>

We should try to ensure we have a very consistent architecture here, so this difference seems a little surprising to me. Not sure which one is right I must admit.

@guybedford guybedford changed the title Top-level package scope should always be imports scope Top-level package scope should inconsistent between stdout and HTML injection Apr 3, 2023
@guybedford guybedford transferred this issue from another repository Apr 8, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant