@lynx-js/css-extract-webpack-plugin 0.7.0 → 0.7.1
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 +8 -0
- package/lib/CssExtractRspackPlugin.d.ts +1 -1
- package/lib/CssExtractRspackPlugin.js +1 -1
- package/lib/loader.d.ts +6 -0
- package/lib/loader.js +15 -6
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @lynx-js/css-extract-webpack-plugin
|
|
2
2
|
|
|
3
|
+
## 0.7.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix CSS source map line offsets when wrapping extracted CSS with cssId metadata. ([#2514](https://github.com/lynx-family/lynx-stack/pull/2514))
|
|
8
|
+
|
|
9
|
+
- Support `@lynx-js/template-webpack-plugin` v0.11.0. ([#2483](https://github.com/lynx-family/lynx-stack/pull/2483))
|
|
10
|
+
|
|
3
11
|
## 0.7.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -23,7 +23,7 @@ interface CssExtractRspackPluginOptions extends ExternalCssExtractRspackPluginOp
|
|
|
23
23
|
* @public
|
|
24
24
|
*
|
|
25
25
|
* CssExtractRspackPlugin is the CSS extract plugin for Lynx.
|
|
26
|
-
* It works just like the {@link https://
|
|
26
|
+
* It works just like the {@link https://rspack.rs/plugins/rspack/css-extract-rspack-plugin.html | CssExtractRspackPlugin} in Web.
|
|
27
27
|
*
|
|
28
28
|
* @example
|
|
29
29
|
* ```js
|
|
@@ -8,7 +8,7 @@ const require = createRequire(import.meta.url);
|
|
|
8
8
|
* @public
|
|
9
9
|
*
|
|
10
10
|
* CssExtractRspackPlugin is the CSS extract plugin for Lynx.
|
|
11
|
-
* It works just like the {@link https://
|
|
11
|
+
* It works just like the {@link https://rspack.rs/plugins/rspack/css-extract-rspack-plugin.html | CssExtractRspackPlugin} in Web.
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```js
|
package/lib/loader.d.ts
CHANGED
|
@@ -32,6 +32,10 @@ export interface LoaderOptions {
|
|
|
32
32
|
*/
|
|
33
33
|
layer?: string | undefined;
|
|
34
34
|
}
|
|
35
|
+
interface DependencySourceMap {
|
|
36
|
+
mappings?: string | undefined;
|
|
37
|
+
[key: string]: unknown;
|
|
38
|
+
}
|
|
35
39
|
export interface Dep {
|
|
36
40
|
identifier: string;
|
|
37
41
|
context: string | null;
|
|
@@ -43,5 +47,7 @@ export interface Dep {
|
|
|
43
47
|
sourceMap?: Buffer | undefined;
|
|
44
48
|
}
|
|
45
49
|
export declare function load(this: LoaderContext<LoaderOptions>, request: string, addDependencies: (deps: Dep[]) => void): Promise<string>;
|
|
50
|
+
export declare function offsetSourceMapLines<T extends DependencySourceMap>(sourceMap: T, lineOffset: number): T;
|
|
46
51
|
export declare function pitch(this: LoaderContext<LoaderOptions>, request: string): Promise<string | undefined>;
|
|
47
52
|
export default function loader(this: LoaderContext<LoaderOptions>, content: string): string | undefined;
|
|
53
|
+
export {};
|
package/lib/loader.js
CHANGED
|
@@ -54,13 +54,14 @@ export async function load(request, addDependencies) {
|
|
|
54
54
|
params.set('cssId', cssId);
|
|
55
55
|
}
|
|
56
56
|
const filePath = path.relative(this.rootContext, extractPathFromIdentifier(identifier));
|
|
57
|
+
const shouldWrapCSSId = Boolean(cssId)
|
|
58
|
+
&& (params.get('common') === null
|
|
59
|
+
|| params.get('common') === 'false');
|
|
57
60
|
identifierCountMap.set(identifier, count + 1);
|
|
58
61
|
return {
|
|
59
62
|
identifier: identifier.replace(rawResourcePath, `${resourcePath}?${params.toString()}`),
|
|
60
63
|
context: this.rootContext,
|
|
61
|
-
content: Buffer.from(
|
|
62
|
-
&& (params.get('common') === null
|
|
63
|
-
|| params.get('common') === 'false')
|
|
64
|
+
content: Buffer.from(shouldWrapCSSId
|
|
64
65
|
/**
|
|
65
66
|
* Given the following source code:
|
|
66
67
|
*
|
|
@@ -92,8 +93,7 @@ export async function load(request, addDependencies) {
|
|
|
92
93
|
* }
|
|
93
94
|
* ```
|
|
94
95
|
*/
|
|
95
|
-
?
|
|
96
|
-
@cssId "${cssId}" "${filePath}" {
|
|
96
|
+
? `@cssId "${cssId}" "${filePath}" {
|
|
97
97
|
${content}
|
|
98
98
|
}
|
|
99
99
|
`
|
|
@@ -103,7 +103,7 @@ ${content}
|
|
|
103
103
|
layer,
|
|
104
104
|
identifierIndex: count,
|
|
105
105
|
sourceMap: sourceMap
|
|
106
|
-
? Buffer.from(JSON.stringify(sourceMap))
|
|
106
|
+
? Buffer.from(JSON.stringify(shouldWrapCSSId ? offsetSourceMapLines(sourceMap, 1) : sourceMap))
|
|
107
107
|
: undefined,
|
|
108
108
|
};
|
|
109
109
|
});
|
|
@@ -151,6 +151,15 @@ ${content}
|
|
|
151
151
|
: result;
|
|
152
152
|
return resultSource;
|
|
153
153
|
}
|
|
154
|
+
export function offsetSourceMapLines(sourceMap, lineOffset) {
|
|
155
|
+
if (lineOffset <= 0 || !sourceMap.mappings) {
|
|
156
|
+
return sourceMap;
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
...sourceMap,
|
|
160
|
+
mappings: `${';'.repeat(lineOffset)}${sourceMap.mappings}`,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
154
163
|
export async function pitch(request) {
|
|
155
164
|
if (this._compiler?.options?.experiments?.css
|
|
156
165
|
&& this._module
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/css-extract-webpack-plugin",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "This plugin extracts CSS into separate files. It creates a CSS file per JS file which contains CSS.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -41,21 +41,21 @@
|
|
|
41
41
|
"README.md"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"mini-css-extract-plugin": "^2.
|
|
44
|
+
"mini-css-extract-plugin": "^2.10.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@microsoft/api-extractor": "7.
|
|
48
|
-
"@rspack/core": "1.
|
|
49
|
-
"css-loader": "^7.1.
|
|
50
|
-
"sass-loader": "^16.0.
|
|
51
|
-
"webpack": "^5.
|
|
52
|
-
"@lynx-js/css-serializer": "0.1.
|
|
53
|
-
"@lynx-js/template-webpack-plugin": "0.
|
|
47
|
+
"@microsoft/api-extractor": "7.58.2",
|
|
48
|
+
"@rspack/core": "1.7.9",
|
|
49
|
+
"css-loader": "^7.1.4",
|
|
50
|
+
"sass-loader": "^16.0.7",
|
|
51
|
+
"webpack": "^5.105.2",
|
|
52
|
+
"@lynx-js/css-serializer": "0.1.6",
|
|
53
|
+
"@lynx-js/template-webpack-plugin": "0.11.0",
|
|
54
54
|
"@lynx-js/test-tools": "0.0.0",
|
|
55
55
|
"@lynx-js/vitest-setup": "0.0.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@lynx-js/template-webpack-plugin": "^0.
|
|
58
|
+
"@lynx-js/template-webpack-plugin": "^0.11.0"
|
|
59
59
|
},
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=18"
|