@serwist/webpack-plugin 9.0.4 → 9.0.6
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/LICENSE +1 -1
- package/dist/index.js +3 -11
- package/dist/inject-manifest.d.ts.map +1 -1
- package/dist/lib/types.d.ts +2 -1
- package/dist/lib/types.d.ts.map +1 -1
- package/package.json +13 -8
- package/src/inject-manifest.ts +9 -16
- package/src/lib/types.ts +2 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2018 Google LLC, 2019 ShadowWalker w@weiw.io https://weiw.io, 2023 Serwist
|
|
3
|
+
Copyright (c) 2018-2023 Google LLC, 2019-2023 ShadowWalker w@weiw.io https://weiw.io, 2020-2023 Anthony Fu <https://github.com/antfu>, 2023-PRESENT Serwist
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/dist/index.js
CHANGED
|
@@ -222,18 +222,10 @@ class InjectManifest {
|
|
|
222
222
|
});
|
|
223
223
|
}
|
|
224
224
|
async performChildCompilation(compilation, parentCompiler) {
|
|
225
|
-
const
|
|
225
|
+
const childCompiler = compilation.createChildCompiler(this.constructor.name, {
|
|
226
226
|
filename: this.config.swDest
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
childCompiler.context = parentCompiler.context;
|
|
230
|
-
childCompiler.inputFileSystem = parentCompiler.inputFileSystem;
|
|
231
|
-
childCompiler.outputFileSystem = parentCompiler.outputFileSystem;
|
|
232
|
-
if (Array.isArray(this.config.webpackCompilationPlugins)) {
|
|
233
|
-
for (const plugin of this.config.webpackCompilationPlugins){
|
|
234
|
-
plugin.apply(childCompiler);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
227
|
+
}, this.config.webpackCompilationPlugins);
|
|
228
|
+
new this.webpack.webworker.WebWorkerTemplatePlugin().apply(childCompiler);
|
|
237
229
|
new this.webpack.EntryPlugin(parentCompiler.context, this.config.swSrc, this.constructor.name).apply(childCompiler);
|
|
238
230
|
await new Promise((resolve, reject)=>{
|
|
239
231
|
childCompiler.runAsChild((error, _entries, childCompilation)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-manifest.d.ts","sourceRoot":"","sources":["../src/inject-manifest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAe,QAAQ,EAAoC,MAAM,SAAS,CAAC;AACvF,OAAO,KAAK,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAW3F;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,cAAc;IACzB,SAAS,CAAC,MAAM,EAAE,6BAA6B,CAAC;IAChD,OAAO,CAAC,aAAa,CAAU;IAC/B,OAAO,CAAC,OAAO,CAAiB;IAEhC;;OAEG;gBACS,MAAM,EAAE,qBAAqB;IAOzC;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAa9B;;;;OAIG;YACW,kBAAkB;IAwChC;;;;OAIG;IACH,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IA6B/B;;;;;OAKG;YACW,uBAAuB;
|
|
1
|
+
{"version":3,"file":"inject-manifest.d.ts","sourceRoot":"","sources":["../src/inject-manifest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAe,QAAQ,EAAoC,MAAM,SAAS,CAAC;AACvF,OAAO,KAAK,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAW3F;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,cAAc;IACzB,SAAS,CAAC,MAAM,EAAE,6BAA6B,CAAC;IAChD,OAAO,CAAC,aAAa,CAAU;IAC/B,OAAO,CAAC,OAAO,CAAiB;IAEhC;;OAEG;gBACS,MAAM,EAAE,qBAAqB;IAOzC;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAa9B;;;;OAIG;YACW,kBAAkB;IAwChC;;;;OAIG;IACH,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IA6B/B;;;;;OAKG;YACW,uBAAuB;IA8BrC;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAKtB;;;;;OAKG;YACW,UAAU;IAiBxB;;;;OAIG;YACW,SAAS;CAmDxB"}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BasePartial, BaseResolved, InjectPartial as BaseInjectPartial, InjectResolved as BaseInjectResolved, OptionalSwDestPartial, OptionalSwDestResolved } from "@serwist/build";
|
|
2
2
|
import type { Require } from "@serwist/utils";
|
|
3
|
+
import type { WebpackPluginFunction, WebpackPluginInstance } from "webpack";
|
|
3
4
|
export interface WebpackPartial {
|
|
4
5
|
/**
|
|
5
6
|
* One or more chunk names whose corresponding output files should be included
|
|
@@ -44,7 +45,7 @@ export interface InjectPartial {
|
|
|
44
45
|
* Optional webpack plugins that will be used when compiling the `swSrc`
|
|
45
46
|
* file. Only valid if `compileSrc` is `true`.
|
|
46
47
|
*/
|
|
47
|
-
webpackCompilationPlugins?:
|
|
48
|
+
webpackCompilationPlugins?: (WebpackPluginFunction | WebpackPluginInstance)[];
|
|
48
49
|
}
|
|
49
50
|
export type InjectResolved = Require<InjectPartial, "compileSrc">;
|
|
50
51
|
export interface InjectManifestOptions extends BasePartial, WebpackPartial, BaseInjectPartial, OptionalSwDestPartial, InjectPartial {
|
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,aAAa,IAAI,iBAAiB,EAClC,cAAc,IAAI,kBAAkB,EACpC,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KA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AAEtI,MAAM,WAAW,6BAA8B,SAAQ,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,cAAc;CAAG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/webpack-plugin",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A plugin for your webpack build process, helping you generate a manifest of local files that should be precached.",
|
|
6
6
|
"files": [
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
"serwist",
|
|
12
12
|
"serwistjs",
|
|
13
13
|
"webpack",
|
|
14
|
+
"rspack",
|
|
15
|
+
"rsbuild",
|
|
14
16
|
"service worker",
|
|
15
17
|
"caching",
|
|
16
18
|
"fetch requests",
|
|
@@ -20,7 +22,10 @@
|
|
|
20
22
|
"engines": {
|
|
21
23
|
"node": ">=18.0.0"
|
|
22
24
|
},
|
|
23
|
-
"author": "Google's Web DevRel Team
|
|
25
|
+
"author": "Google's Web DevRel Team",
|
|
26
|
+
"contributors": [
|
|
27
|
+
"Serwist <ducanh2912.rusty@gmail.com> (https://serwist.pages.dev/)"
|
|
28
|
+
],
|
|
24
29
|
"license": "MIT",
|
|
25
30
|
"repository": "https://github.com/serwist/serwist",
|
|
26
31
|
"bugs": "https://github.com/serwist/serwist/issues",
|
|
@@ -56,16 +61,16 @@
|
|
|
56
61
|
"pretty-bytes": "6.1.1",
|
|
57
62
|
"upath": "2.0.1",
|
|
58
63
|
"zod": "3.23.8",
|
|
59
|
-
"@serwist/build": "9.0.
|
|
64
|
+
"@serwist/build": "9.0.6"
|
|
60
65
|
},
|
|
61
66
|
"devDependencies": {
|
|
62
|
-
"@types/node": "
|
|
67
|
+
"@types/node": "22.5.0",
|
|
63
68
|
"@types/webpack": "5.28.5",
|
|
64
|
-
"rollup": "4.
|
|
65
|
-
"typescript": "5.5.
|
|
69
|
+
"rollup": "4.21.0",
|
|
70
|
+
"typescript": "5.5.4",
|
|
66
71
|
"webpack": "5.93.0",
|
|
67
|
-
"@serwist/utils": "9.0.
|
|
68
|
-
"@serwist/configs": "9.0.
|
|
72
|
+
"@serwist/utils": "9.0.6",
|
|
73
|
+
"@serwist/configs": "9.0.6"
|
|
69
74
|
},
|
|
70
75
|
"peerDependencies": {
|
|
71
76
|
"typescript": ">=5.0.0",
|
package/src/inject-manifest.ts
CHANGED
|
@@ -154,21 +154,15 @@ export class InjectManifest {
|
|
|
154
154
|
* @private
|
|
155
155
|
*/
|
|
156
156
|
private async performChildCompilation(compilation: Compilation, parentCompiler: Compiler): Promise<void> {
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
157
|
+
const childCompiler = compilation.createChildCompiler(
|
|
158
|
+
this.constructor.name,
|
|
159
|
+
{
|
|
160
|
+
filename: this.config.swDest,
|
|
161
|
+
},
|
|
162
|
+
this.config.webpackCompilationPlugins,
|
|
163
|
+
);
|
|
162
164
|
|
|
163
|
-
|
|
164
|
-
childCompiler.inputFileSystem = parentCompiler.inputFileSystem;
|
|
165
|
-
childCompiler.outputFileSystem = parentCompiler.outputFileSystem;
|
|
166
|
-
|
|
167
|
-
if (Array.isArray(this.config.webpackCompilationPlugins)) {
|
|
168
|
-
for (const plugin of this.config.webpackCompilationPlugins) {
|
|
169
|
-
plugin.apply(childCompiler);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
165
|
+
new this.webpack.webworker.WebWorkerTemplatePlugin().apply(childCompiler);
|
|
172
166
|
|
|
173
167
|
new this.webpack.EntryPlugin(parentCompiler.context, this.config.swSrc, this.constructor.name).apply(childCompiler);
|
|
174
168
|
|
|
@@ -183,7 +177,6 @@ export class InjectManifest {
|
|
|
183
177
|
if (childCompilation?.errors) {
|
|
184
178
|
compilation.errors.push(...childCompilation.errors);
|
|
185
179
|
}
|
|
186
|
-
|
|
187
180
|
resolve();
|
|
188
181
|
}
|
|
189
182
|
});
|
|
@@ -197,7 +190,7 @@ export class InjectManifest {
|
|
|
197
190
|
* @private
|
|
198
191
|
*/
|
|
199
192
|
private addSrcToAssets(compilation: Compilation, parentCompiler: Compiler): void {
|
|
200
|
-
const source =
|
|
193
|
+
const source = parentCompiler.inputFileSystem!.readFileSync!(this.config.swSrc);
|
|
201
194
|
compilation.emitAsset(this.config.swDest!, new this.webpack.sources.RawSource(source));
|
|
202
195
|
}
|
|
203
196
|
|
package/src/lib/types.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
OptionalSwDestResolved,
|
|
8
8
|
} from "@serwist/build";
|
|
9
9
|
import type { Require } from "@serwist/utils";
|
|
10
|
+
import type { WebpackPluginFunction, WebpackPluginInstance } from "webpack";
|
|
10
11
|
|
|
11
12
|
export interface WebpackPartial {
|
|
12
13
|
/**
|
|
@@ -57,7 +58,7 @@ export interface InjectPartial {
|
|
|
57
58
|
* Optional webpack plugins that will be used when compiling the `swSrc`
|
|
58
59
|
* file. Only valid if `compileSrc` is `true`.
|
|
59
60
|
*/
|
|
60
|
-
webpackCompilationPlugins?:
|
|
61
|
+
webpackCompilationPlugins?: (WebpackPluginFunction | WebpackPluginInstance)[];
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
export type InjectResolved = Require<InjectPartial, "compileSrc">;
|