You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature Use Case
Importing JSON, CSS, and HTML according to upcoming JavaScript and HTML standards.
CSS modules are standardized (In the HTML spec here) and shipping in Chrome and Edge since v93. Firefox and Webkit were involved in the development of import assertions as a result of working out CSS modules, and are both currently implementing the prerequisites for CSS modules (constructible stylesheets and adopedStyleSheets).
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'}});
It is very helpful for shadowDOM web custom elements.
anil9973
changed the title
Add support for for import assertions and non-JS module types
Add support for import assertions and non-JS module types
Nov 18, 2022
Import assertions are already supported. They are passed through to the output unmodified so that the browser can interpret them (unless you tell esbuild that they are unsupported, in which case esbuild will remove them):
$echo"import {default as foo} from './foo.json' assert {type: 'json'}"|esbuildimport{defaultasfoo}from"./foo.json"assert{type: "json" };$echo"import {default as foo} from './foo.json' assert {type: 'json'}"|esbuild--supported:import-assertions=falseimport{defaultasfoo}from"./foo.json";
Feature Use Case
Importing JSON, CSS, and HTML according to upcoming JavaScript and HTML standards.
CSS modules are standardized (In the HTML spec here) and shipping in Chrome and Edge since v93. Firefox and Webkit were involved in the development of import assertions as a result of working out CSS modules, and are both currently implementing the prerequisites for CSS modules (constructible stylesheets and adopedStyleSheets).
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?):
It is very helpful for shadowDOM web custom elements.
know more at
web.dev/css-module-scripts
The text was updated successfully, but these errors were encountered: