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

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:[email protected]/index.js",
    "app": "./app.js"
  },
  "scopes": {
    "https://ga.jspm.io/": {
      "@lit/reactive-element": "https://ga.jspm.io/npm:@lit/[email protected]/reactive-element.js",
      "lit-element/lit-element.js": "https://ga.jspm.io/npm:[email protected]/lit-element.js",
      "lit-html": "https://ga.jspm.io/npm:[email protected]/lit-html.js",
      "lit-html/is-server.js": "https://ga.jspm.io/npm:[email protected]/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:[email protected]/dist/es-module-shims.js" crossorigin="anonymous"></script>
<script type="importmap">
{
  "imports": {
    "app": "./app.js"
  },
  "scopes": {
    "./": {
      "lit": "https://ga.jspm.io/npm:[email protected]/index.js"
    },
    "https://ga.jspm.io/": {
      "@lit/reactive-element": "https://ga.jspm.io/npm:@lit/[email protected]/reactive-element.js",
      "lit-element/lit-element.js": "https://ga.jspm.io/npm:[email protected]/lit-element.js",
      "lit-html": "https://ga.jspm.io/npm:[email protected]/lit-html.js",
      "lit-html/is-server.js": "https://ga.jspm.io/npm:[email protected]/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
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