@lynx-js/template-webpack-plugin-canary 0.6.9-canary-20250411-bbcdba12 → 0.6.10-canary-20250423-f3afaf6c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -1
- package/lib/LynxAsyncChunksRuntimeModule.d.ts +1 -1
- package/lib/LynxTemplatePlugin.d.ts +1 -1
- package/lib/LynxTemplatePlugin.js +3 -3
- package/lib/css/cssChunksToMap.d.ts +1 -1
- package/lib/css/cssChunksToMap.js +2 -2
- package/lib/css/debundle.d.ts +1 -1
- package/lib/css/debundle.js +8 -2
- package/lib/css/encode.js +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
# @lynx-js/template-webpack-plugin
|
|
2
2
|
|
|
3
|
-
## 0.6.
|
|
3
|
+
## 0.6.10-canary-20250423105122-f3afaf6c7919d3fe60ac2dfcd8af77178436f785
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix CSS import order when `enableCSSSelector` is false. ([#609](https://github.com/lynx-family/lynx-stack/pull/609))
|
|
8
|
+
|
|
9
|
+
When the `enableCSSSelector` option is set to false, style rule priority is inversely related to `@import` order(Lynx CSS engine has the incorrect behavior). Reversing the import order to maintain correct priority is required. For example:
|
|
10
|
+
|
|
11
|
+
```css
|
|
12
|
+
@import "0.css";
|
|
13
|
+
@import "1.css";
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
will convert to:
|
|
17
|
+
|
|
18
|
+
```css
|
|
19
|
+
@import "1.css";
|
|
20
|
+
@import "0.css";
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 0.6.9
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
6
26
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { RuntimeModule } from 'webpack';
|
|
2
|
-
type LynxAsyncChunksRuntimeModule = new (getChunkName: (chunkName: string | undefined) => string) => RuntimeModule;
|
|
2
|
+
type LynxAsyncChunksRuntimeModule = new (getChunkName: (chunkName: string | null | undefined) => string) => RuntimeModule;
|
|
3
3
|
export declare function createLynxAsyncChunksRuntimeModule(webpack: typeof import('webpack')): LynxAsyncChunksRuntimeModule;
|
|
4
4
|
export {};
|
|
@@ -320,7 +320,7 @@ export declare class LynxTemplatePlugin {
|
|
|
320
320
|
* )));
|
|
321
321
|
* ```
|
|
322
322
|
*/
|
|
323
|
-
static convertCSSChunksToMap(cssChunks: string[], plugins: CSS.Plugin[]): {
|
|
323
|
+
static convertCSSChunksToMap(cssChunks: string[], plugins: CSS.Plugin[], enableCSSSelector: boolean): {
|
|
324
324
|
cssMap: Record<string, CSS.LynxStyleNode[]>;
|
|
325
325
|
cssSource: Record<string, string>;
|
|
326
326
|
};
|
|
@@ -111,8 +111,8 @@ export class LynxTemplatePlugin {
|
|
|
111
111
|
* )));
|
|
112
112
|
* ```
|
|
113
113
|
*/
|
|
114
|
-
static convertCSSChunksToMap(cssChunks, plugins) {
|
|
115
|
-
return cssChunksToMap(cssChunks, plugins);
|
|
114
|
+
static convertCSSChunksToMap(cssChunks, plugins, enableCSSSelector) {
|
|
115
|
+
return cssChunksToMap(cssChunks, plugins, enableCSSSelector);
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
118
|
* The entry point of a webpack plugin.
|
|
@@ -274,7 +274,7 @@ class LynxTemplatePluginImpl {
|
|
|
274
274
|
const css = cssChunksToMap(assetsInfoByGroups.css
|
|
275
275
|
.map(chunk => compilation.getAsset(chunk.name))
|
|
276
276
|
.filter((v) => !!v)
|
|
277
|
-
.map(asset => asset.source.source().toString()), cssPlugins);
|
|
277
|
+
.map(asset => asset.source.source().toString()), cssPlugins, enableCSSSelector);
|
|
278
278
|
const encodeRawData = {
|
|
279
279
|
compilerOptions: {
|
|
280
280
|
enableFiberArch: true,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as CSS from '@lynx-js/css-serializer';
|
|
2
|
-
export declare function cssChunksToMap(cssChunks: string[], plugins: CSS.Plugin[]): {
|
|
2
|
+
export declare function cssChunksToMap(cssChunks: string[], plugins: CSS.Plugin[], enableCSSSelector: boolean): {
|
|
3
3
|
cssMap: Record<string, CSS.LynxStyleNode[]>;
|
|
4
4
|
cssSource: Record<string, string>;
|
|
5
5
|
contentMap: Map<number, string[]>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { cssToAst } from './ast.js';
|
|
2
2
|
import { debundleCSS } from './debundle.js';
|
|
3
|
-
export function cssChunksToMap(cssChunks, plugins) {
|
|
3
|
+
export function cssChunksToMap(cssChunks, plugins, enableCSSSelector) {
|
|
4
4
|
const cssMap = cssChunks
|
|
5
5
|
.reduce((cssMap, css) => {
|
|
6
|
-
debundleCSS(css, cssMap);
|
|
6
|
+
debundleCSS(css, cssMap, enableCSSSelector);
|
|
7
7
|
return cssMap;
|
|
8
8
|
}, new Map());
|
|
9
9
|
return {
|
package/lib/css/debundle.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function debundleCSS(code: string, css: Map<number, string[]
|
|
1
|
+
export declare function debundleCSS(code: string, css: Map<number, string[]>, enableCSSSelector: boolean): void;
|
package/lib/css/debundle.js
CHANGED
|
@@ -6,7 +6,7 @@ import * as cssTree from 'css-tree';
|
|
|
6
6
|
// It should always has `cssId: 0`.
|
|
7
7
|
const COMMON_CSS = '/common.css';
|
|
8
8
|
const COMMON_CSS_ID = 0;
|
|
9
|
-
export function debundleCSS(code, css) {
|
|
9
|
+
export function debundleCSS(code, css, enableCSSSelector) {
|
|
10
10
|
const ast = cssTree.parse(code);
|
|
11
11
|
const fileKeyToCSSContent = new Map();
|
|
12
12
|
const cssIdToFileKeys = new Map();
|
|
@@ -71,7 +71,13 @@ export function debundleCSS(code, css) {
|
|
|
71
71
|
// TODO: remove /cssId/0.css if not exists in the cssMap
|
|
72
72
|
// For each scoped CSSStyleSheet, we should import the real CSSStyleSheet.
|
|
73
73
|
// So that the styles can be resolved with the scoped cssId.
|
|
74
|
-
cssIdToFileKeys.forEach((
|
|
74
|
+
cssIdToFileKeys.forEach((rawFileKeys, cssId) => {
|
|
75
|
+
let fileKeys = Array.from(rawFileKeys);
|
|
76
|
+
if (enableCSSSelector === false) {
|
|
77
|
+
// When enableCSSSelector is false, style rule priority is inversely related to @import order,
|
|
78
|
+
// requiring reversed imports to maintain correct priority.
|
|
79
|
+
fileKeys = fileKeys.reverse();
|
|
80
|
+
}
|
|
75
81
|
emplaceCSSStyleSheet(css, cssId, Array.from(fileKeys).map(fileKey => `@import "${fileKeyToCSSId.get(fileKey)}";`).join('\n'));
|
|
76
82
|
});
|
|
77
83
|
}
|
package/lib/css/encode.js
CHANGED
|
@@ -11,7 +11,7 @@ encode = (options) => {
|
|
|
11
11
|
buffer,
|
|
12
12
|
});
|
|
13
13
|
}) {
|
|
14
|
-
const css = cssChunksToMap(cssChunks, plugins);
|
|
14
|
+
const css = cssChunksToMap(cssChunks, plugins, enableCSSSelector);
|
|
15
15
|
const encodeOptions = {
|
|
16
16
|
compilerOptions: {
|
|
17
17
|
// Do not remove this, it will crash :)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/template-webpack-plugin-canary",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.10-canary-20250423-f3afaf6c",
|
|
4
4
|
"description": "Simplifies creation of Lynx template files to serve your webpack bundles",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"@microsoft/api-extractor": "7.52.3",
|
|
44
44
|
"@types/css-tree": "^2.3.10",
|
|
45
45
|
"@types/object.groupby": "^1.0.4",
|
|
46
|
-
"webpack": "^5.
|
|
47
|
-
"@lynx-js/
|
|
48
|
-
"@lynx-js/
|
|
46
|
+
"webpack": "^5.99.5",
|
|
47
|
+
"@lynx-js/vitest-setup": "0.0.0",
|
|
48
|
+
"@lynx-js/test-tools": "0.0.0"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
51
|
"node": ">=18"
|