Add easy sync feature detection for new module types #7017
Labels
addition/proposal
New features or enhancements
needs implementer interest
Moving the issue forward requires implementers to express interest
topic: script
Spinning off from #6472 (comment)
It is currently a bit nontrivial to feature-detect support for new module types like JSON or CSS modules. You can do something like the following async:
but this is kind of annoying.
I think a good API for this would be something like
import.meta.supportsType("css")
or maybeimport.meta.supportsTypeAssert("css")
.It's a little unusual for an
import.meta
API since it's not particularly about the current module. But I think that's OK?Other places to put this I can think of would be:
HTMLScriptElement.supportsTypeAssert("css")
. (Not so great since it's window-only and various module types work in more places than just<script>
elements.)supportsImportTypeAssert("css")
.import
itself, e.g.import.supportsType("css")
./cc @guybedford @dandclark
The text was updated successfully, but these errors were encountered: