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

Expose information about import assertions #73

Closed
LarsDenBakker opened this issue Jun 14, 2021 · 4 comments · Fixed by #74
Closed

Expose information about import assertions #73

LarsDenBakker opened this issue Jun 14, 2021 · 4 comments · Fixed by #74

Comments

@LarsDenBakker
Copy link
Contributor

I am looking into polyfilling the new upcoming module types (JSON, CSS, HTML etc.). To do this it would be great if we can find out in a lightweight way whether an import is done using an import assertion. Is this something that could be added to ex module lexer?

For an import like this:

import foo from 'bar' assert { type: 'json' } 

And this would tell use that the import assertion is JSON.

The proposal for import assertions is here: https://github.com/tc39/proposal-import-assertions

@guybedford
Copy link
Owner

@LarsDenBakker I think we should build this directly into the core project, just like SystemJS supports - https://github.com/systemjs/systemjs/blob/main/src/extras/module-types.js.

Steps:

  1. Support import assertions in ES module lexer (let me work on a PR now).
  2. Integrate the module-types logic into the main repo here, assuming the constructed stylesheets polyfill like SystemJS does.

What is the status on HTML modules these days?

@LarsDenBakker
Copy link
Contributor Author

Great to hear! Import assertions were stalling progress for a while, but JSON module is stage 3 and CSS modules is making progress https://groups.google.com/a/chromium.org/g/blink-dev/c/vCrJCQxNnzo/m/OAYI9cPWAQAJ?pli=1. I'm not sure about the current status of HTML modules

@LarsDenBakker
Copy link
Contributor Author

Is it possible to include the start and end position of the import assertion? For my case I'd have to remove the actual import assertion from the code. es-module-shims will have to do this as well I think?

@guybedford
Copy link
Owner

@LarsDenBakker thanks for the suggestions - I've added these features in #74, review would be very welcome there.

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.

2 participants