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

Add support for modifying import map as a js variable #16

Closed
joeldenning opened this issue Mar 18, 2020 · 1 comment · Fixed by #17
Closed

Add support for modifying import map as a js variable #16

joeldenning opened this issue Mar 18, 2020 · 1 comment · Fixed by #17

Comments

@joeldenning
Copy link
Member

Since only one import map per page is supported in the most recent import maps spec, we should provide a way for import map overrides to work with only one import map.

See more info at https://github.com/WICG/import-maps/#dynamic-import-map-example

<script>
  window.importMap = {imports: {foo: './foo1.js'}};
<script>
<script src="https://cdn.jsdelivr.net/npm/import-map-overrides/dist/import-map-overrides.js"></script>

With this proposed API, import map overrides would look for a global variable named importMap, modify it with the overrides, and then inject it as <script type="importmap"> into the DOM.

@joeldenning
Copy link
Member Author

Oo actually a better API would be this, I think:

<script type="overridable-importmap">
{
  "imports": {
    "foo": "./foo1.js"
  }
}
</script>
<script src="https://cdn.jsdelivr.net/npm/import-map-overrides/dist/import-map-overrides.js"></script>

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

Successfully merging a pull request may close this issue.

1 participant