Skip to content

Commit a6e4fbc

Browse files
fix: nested selectors with css modules.
1 parent 8278579 commit a6e4fbc

3 files changed

Lines changed: 50 additions & 16 deletions

File tree

playwright/diagnostics.spec.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,35 @@ test('sass compiler warnings surface in styles diagnostics', async ({ page }) =>
442442
)
443443
})
444444

445+
test('css modules nesting compiles without lightning wasm compatibility errors', async ({
446+
page,
447+
}) => {
448+
await waitForInitialRender(page)
449+
450+
await ensurePanelToolsVisible(page, 'styles')
451+
await page.getByRole('combobox', { name: 'Style mode' }).selectOption('module')
452+
await setStylesEditorSource(
453+
page,
454+
['.btn {', ' &:hover {', ' color: red;', ' }', '}'].join('\n'),
455+
)
456+
457+
await expect
458+
.poll(async () => {
459+
return (
460+
await page.getByRole('status', { name: 'App status' }).textContent()
461+
)?.trim()
462+
})
463+
.toBe('Rendered')
464+
465+
await ensureDiagnosticsDrawerOpen(page)
466+
await expect(page.locator('#diagnostics-styles')).not.toContainText(
467+
'Style compilation failed.',
468+
)
469+
await expect(page.locator('#diagnostics-styles')).not.toContainText(
470+
'invalid type: unit value, expected a boolean',
471+
)
472+
})
473+
445474
test('clear component diagnostics resets rendered lint-issue status pill', async ({
446475
page,
447476
}) => {

src/modules/cdn.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,25 @@ const fallbackCdnProviders = fallbackCdnProvidersByPrimary[primaryCdnProvider] ?
4545

4646
export const cdnImportSpecs = {
4747
cssBrowser: {
48-
importMap: '@knighted/css/browser',
49-
esm: '@knighted/css/browser',
50-
jspmGa: 'npm:@knighted/css/browser',
48+
importMap: '@knighted/css@1.2.1/browser',
49+
esm: '@knighted/css@1.2.1/browser',
50+
unpkg: '@knighted/css@1.2.1/dist/browser.js?module',
51+
jspmGa: 'npm:@knighted/css@1.2.1/browser',
5152
},
5253
jsxDom: {
53-
importMap: '@knighted/jsx',
54-
esm: '@knighted/jsx',
55-
jspmGa: 'npm:@knighted/jsx',
54+
importMap: '@knighted/jsx@1.14.0',
55+
esm: '@knighted/jsx@1.14.0',
56+
jspmGa: 'npm:@knighted/jsx@1.14.0',
5657
},
5758
jsxTransform: {
58-
importMap: '@knighted/jsx/transform',
59-
esm: '@knighted/jsx/transform',
60-
jspmGa: 'npm:@knighted/jsx/transform',
59+
importMap: '@knighted/jsx@1.14.0/transform',
60+
esm: '@knighted/jsx@1.14.0/transform',
61+
jspmGa: 'npm:@knighted/jsx@1.14.0/transform',
6162
},
6263
jsxReact: {
63-
importMap: '@knighted/jsx/react',
64-
esm: '@knighted/jsx/react',
65-
jspmGa: 'npm:@knighted/jsx/react',
64+
importMap: '@knighted/jsx@1.14.0/react',
65+
esm: '@knighted/jsx@1.14.0/react',
66+
jspmGa: 'npm:@knighted/jsx@1.14.0/react',
6667
},
6768
react: {
6869
importMap: 'react',
@@ -100,9 +101,13 @@ export const cdnImportSpecs = {
100101
jspmGa: 'npm:less',
101102
},
102103
lightningCssWasm: {
103-
importMap: '@parcel/css-wasm',
104-
esm: '@parcel/css-wasm',
105-
jspmGa: 'npm:@parcel/css-wasm',
104+
/**
105+
* Keep this pinned to a runtime version verified with @knighted/css browser.
106+
* Drift here can break cssFromSource module transforms (e.g. drafts.nesting).
107+
*/
108+
importMap: 'lightningcss-wasm@1.30.1',
109+
esm: 'lightningcss-wasm@1.30.1',
110+
jspmGa: 'npm:lightningcss-wasm@1.30.1',
106111
},
107112
typescript: {
108113
importMap: 'typescript',

src/modules/preview/render-runtime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ export const createRenderRuntimeController = ({
318318
if (hasNamedInit) {
319319
await module.init()
320320
} else if (hasNamedTransform && typeof module.default === 'function') {
321-
// @parcel/css-wasm exports default init + named transform.
321+
// Common WASM ESM shape: default init + named transform.
322322
await module.default()
323323
}
324324

0 commit comments

Comments
 (0)