{"id":6282,"date":"2025-06-19T10:46:44","date_gmt":"2025-06-19T15:46:44","guid":{"rendered":"https:\/\/frontendmasters.com\/blog\/?p=6282"},"modified":"2025-06-19T10:46:45","modified_gmt":"2025-06-19T15:46:45","slug":"import-assertions-use-with-not-assert-anymore","status":"publish","type":"post","link":"https:\/\/frontendmasters.com\/blog\/import-assertions-use-with-not-assert-anymore\/","title":{"rendered":"Import Assertions use &#8220;with&#8221; not &#8220;assert&#8221; anymore."},"content":{"rendered":"\n<p>I was trying to play with <a href=\"https:\/\/web.dev\/articles\/css-module-scripts\">CSS Module Scripts<\/a> the other day, which are a way to import CSS as a <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/CSSStyleSheet\/CSSStyleSheet\">constructable stylesheet<\/a> using the ESModules syntax. They are Chrome-only so not really something we can generally use (unless you&#8217;re building an Electron app or something), but I really like the idea of being able to load a stylesheet for a web component in a separate file cleanly. Anyway, there is lots of information out there that shows and old syntax that doesn&#8217;t work anymore, and little information that the syntax has changed to use the <code>with<\/code> keyword.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-comment\">\/\/ NOPE, old<\/span>\n<span class=\"hljs-keyword\">import<\/span> sheet <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">'.\/styles.css'<\/span> assert { <span class=\"hljs-attr\">type<\/span>: <span class=\"hljs-string\">'css'<\/span> };\n\n<span class=\"hljs-comment\">\/\/ YEP, they changed it<\/span>\n<span class=\"hljs-keyword\">import<\/span> sheet <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">'.\/styles.css'<\/span> <span class=\"hljs-keyword\">with<\/span> { <span class=\"hljs-attr\">type<\/span>: <span class=\"hljs-string\">'css'<\/span> };<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>So they are called &#8220;import attributes&#8221; now also, best I can tell. I imagine it applies to the JSON version as well. Hope this saves someone some grief. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was trying to play with CSS Module Scripts the other day, which are a way to import CSS as a constructable stylesheet using the ESModules syntax. They are Chrome-only so not really something we can generally use (unless you&#8217;re building an Electron app or something), but I really like the idea of being able [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6283,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[29],"tags":[357,358,3],"class_list":["post-6282","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-the-beat","tag-import","tag-import-attributes","tag-javascript"],"acf":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2025\/06\/pexels-photo-1036622.jpeg?fit=1880%2C1255&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/6282","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/comments?post=6282"}],"version-history":[{"count":1,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/6282\/revisions"}],"predecessor-version":[{"id":6284,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/6282\/revisions\/6284"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media\/6283"}],"wp:attachment":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media?parent=6282"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/categories?post=6282"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/tags?post=6282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}