-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Feature Use Case
Importing JSON, CSS, and HTML according to upcoming JavaScript and HTML standards.
Feature Proposal
Import assertions are a Stage 3 TC39 proposal to allow source code to assert that an import has a specific type (among other possible assertions): https://github.com/tc39/proposal-import-assertions
Assertions are being added to unblock the JSON, CSS, and HTML modules proposals which allow importing those file type as JavaScript modules.
This means that we'll be able to import JSON, CSS and HTML into JavaScript natively, and ideally in bundlers without any specific loaders (or perhaps a "web standard loader" that implements all web-native module types?):
import styles from './styles.css' assert {type: 'css'};
// or
const styles = await import('./styles.css', {assert: {type: 'css'}});I filed an issue on Acorn for import assertion support.
The JSON and CSS proposals are furthest along, with implementations in Chromium behind flags.