Using import
for non JavaScript modules
#606
Replies: 5 comments 1 reply
-
Looks like |
Beta Was this translation helpful? Give feedback.
-
CSS / JSON modules Spec! |
Beta Was this translation helpful? Give feedback.
-
On the topic of CSS modules, some interesting threads
|
Beta Was this translation helpful? Give feedback.
-
Some good convos happening over in the Rollup repo |
Beta Was this translation helpful? Give feedback.
-
I think a lot of this is now being tracked in formal issues like #923 |
Beta Was this translation helpful? Give feedback.
-
Overview
As tracked in a couple issues, some already attempted there is some precedences / interest being able to use ESM for assets that are not JavaScript modules.
import
JSON using ESM #516As this is definitely not a standard, any of these instances would have to be supported in a consistent way. This discussion is for that API.
Examples
The below are some examples of what this could look like
CSS
/styles/card.js
would be returned as
and used as, say with
LitElement#styles
JSON
/assets/data.json
Would be resolved as
and used as
Proposal
I think being explicitly is better than being implicit as we do with plugin-import-css and using header detection, because as discovered for JSON, won't change. Headers will be the same in either using
fetch
orimport
.Taking some influence from
import
assertions, I propose something like I introduced in , which we needed just to keep certain things working since the bug really needed to get fixed.The solution would require adding
?type=xxx
to the end of any requestex.
Questions
import
JSON using ESM #516 with final approachBeta Was this translation helpful? Give feedback.
All reactions