Skip to content

Commit cc791b3

Browse files
committed
work
1 parent 1bf3484 commit cc791b3

17 files changed

Lines changed: 171 additions & 36 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jsenv/core",
3-
"version": "41.4.27",
3+
"version": "41.4.28",
44
"type": "module",
55
"description": "Tool to develop, test and build js projects",
66
"repository": {
@@ -78,7 +78,7 @@
7878
"@jsenv/plugin-bundling": "2.10.18",
7979
"@jsenv/plugin-minification": "1.7.11",
8080
"@jsenv/plugin-supervisor": "1.8.14",
81-
"@jsenv/plugin-transpilation": "1.6.3",
81+
"@jsenv/plugin-transpilation": "1.6.4",
8282
"@jsenv/server": "17.6.3",
8383
"@jsenv/sourcemap": "1.4.2",
8484
"react-table": "7.8.0"

packages/frontend/navi/dist/jsenv_navi_side_effects.js

Lines changed: 98 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/frontend/navi/dist/jsenv_navi_side_effects.js.map

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/frontend/navi/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jsenv/navi",
3-
"version": "0.29.145",
3+
"version": "0.29.146",
44
"type": "module",
55
"description": "Library of components including navigation to create frontend applications",
66
"repository": {

packages/internal/plugin-transpilation/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jsenv/plugin-transpilation",
3-
"version": "1.6.3",
3+
"version": "1.6.4",
44
"type": "module",
55
"description": "TODO",
66
"repository": {

packages/internal/plugin-transpilation/src/css/apply_css_transpilation.js

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,45 @@ export const applyCssTranspilation = async ({
1818
customMedia: true,
1919
},
2020
});
21-
return { content: String(code), sourcemap: map };
21+
return {
22+
content: defineLightDarkSwitchIfNeeded(String(code)),
23+
sourcemap: map,
24+
};
25+
};
26+
27+
// The two custom properties lightningcss lowers "light-dark()" into. The pair
28+
// works as a switch: exactly one of them computes to the guaranteed-invalid
29+
// "initial" at a time, so exactly one of the two var() fallbacks survives.
30+
const LIGHT_DARK_SWITCH_CSS = `
31+
:root {
32+
--lightningcss-light: initial;
33+
--lightningcss-dark: ;
34+
}
35+
@media (prefers-color-scheme: dark) {
36+
:root {
37+
--lightningcss-light: ;
38+
--lightningcss-dark: initial;
39+
}
40+
}
41+
`;
42+
43+
// lightningcss writes that switch into the rule declaring "color-scheme", and
44+
// only there: a stylesheet lowering light-dark() without one references two
45+
// properties nobody defines, both var() fall back, the two values concatenate
46+
// and the declaration is dropped as invalid — a color silently missing rather
47+
// than an approximation of it. Each module owning a stylesheet of its own (see
48+
// jsenv:import_meta_css), the sheet declaring color-scheme is almost never the
49+
// sheet using light-dark(), so the switch is written here instead. Appended
50+
// rather than prepended: nothing else declares these two, so cascade order does
51+
// not matter, and the sourcemap of what comes before stays exact.
52+
const defineLightDarkSwitchIfNeeded = (css) => {
53+
if (!css.includes("var(--lightningcss-light")) {
54+
return css;
55+
}
56+
if (css.includes("--lightningcss-light:")) {
57+
return css;
58+
}
59+
return `${css}${LIGHT_DARK_SWITCH_CSS}`;
2260
};
2361

2462
// runtimeCompat names on the left, lightningcss target names on the right

packages/related/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jsenv/cli",
3-
"version": "0.3.154",
3+
"version": "0.3.155",
44
"type": "module",
55
"description": "Command Line Interface for jsenv",
66
"repository": {

packages/related/cli/template-node-package/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"devDependencies": {
1515
"@jsenv/assert": "4.5.7",
16-
"@jsenv/core": "41.4.27",
16+
"@jsenv/core": "41.4.28",
1717
"@jsenv/eslint-config-relax": "1.9.0",
1818
"@jsenv/test": "3.7.35",
1919
"eslint": "9.39.2",

packages/related/cli/template-web-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@babel/plugin-syntax-import-attributes": "7.29.7",
1919
"@jsenv/custom-elements-redefine": "0.1.0",
2020
"@jsenv/assert": "4.5.7",
21-
"@jsenv/core": "41.4.27",
21+
"@jsenv/core": "41.4.28",
2222
"@jsenv/plugin-bundling": "2.10.18",
2323
"@jsenv/plugin-minification": "1.7.11",
2424
"@jsenv/eslint-config-relax": "1.9.0",

packages/related/cli/template-web-preact/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"@babel/plugin-syntax-import-attributes": "7.29.7",
2222
"@babel/plugin-transform-react-jsx": "7.29.7",
2323
"@jsenv/assert": "4.5.7",
24-
"@jsenv/core": "41.4.27",
24+
"@jsenv/core": "41.4.28",
2525
"@jsenv/plugin-preact": "1.8.2",
2626
"@jsenv/plugin-bundling": "2.10.18",
2727
"@jsenv/plugin-minification": "1.7.11",

0 commit comments

Comments
 (0)