@serwist/webpack-plugin 9.0.12 → 9.0.13
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/dist/chunks/perform-child-compilation.js +6 -2
- package/dist/index.js +4 -8
- package/dist/lib/relative-to-output-path.d.ts.map +1 -1
- package/dist/lib/types.d.ts +8 -3
- package/dist/lib/types.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/inject-manifest.ts +2 -2
- package/src/lib/get-asset-hash.ts +1 -1
- package/src/lib/relative-to-output-path.ts +2 -1
- package/src/lib/types.ts +10 -3
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
|
|
3
|
+
const toUnix = (p)=>{
|
|
4
|
+
return p.replace(/\\/g, "/").replace(/(?<!^)\/+/g, "/");
|
|
5
|
+
};
|
|
6
|
+
|
|
3
7
|
const relativeToOutputPath = (compilation, originalPath)=>{
|
|
4
8
|
if (path.resolve(originalPath) === path.normalize(originalPath)) {
|
|
5
|
-
return path.relative(compilation.options.output.path, originalPath);
|
|
9
|
+
return toUnix(path.relative(compilation.options.output.path, originalPath));
|
|
6
10
|
}
|
|
7
11
|
return originalPath;
|
|
8
12
|
};
|
|
@@ -30,4 +34,4 @@ const performChildCompilation = async (compiler, compilation, name, src, dest, p
|
|
|
30
34
|
});
|
|
31
35
|
};
|
|
32
36
|
|
|
33
|
-
export { performChildCompilation as p, relativeToOutputPath as r };
|
|
37
|
+
export { performChildCompilation as p, relativeToOutputPath as r, toUnix as t };
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { transformManifest, getSourceMapURL,
|
|
2
|
+
import { transformManifest, getSourceMapURL, escapeRegExp, replaceAndUpdateSourceMap } from '@serwist/build';
|
|
3
|
+
import { r as relativeToOutputPath, p as performChildCompilation, t as toUnix } from './chunks/perform-child-compilation.js';
|
|
3
4
|
import prettyBytes from 'pretty-bytes';
|
|
4
5
|
import { validationErrorMap, SerwistConfigError } from '@serwist/build/schema';
|
|
5
6
|
import crypto from 'node:crypto';
|
|
6
|
-
import { r as relativeToOutputPath, p as performChildCompilation } from './chunks/perform-child-compilation.js';
|
|
7
|
-
|
|
8
|
-
const toUnix = (p)=>{
|
|
9
|
-
return p.replace(/\\/g, "/").replace(/(?<!^)\/+/g, "/");
|
|
10
|
-
};
|
|
11
7
|
|
|
12
8
|
const validateInjectManifestOptions = async (input)=>{
|
|
13
9
|
const result = await (await import('./chunks/schema.js')).injectManifestOptions.spa(input, {
|
|
@@ -26,7 +22,7 @@ const getAssetHash = (asset)=>{
|
|
|
26
22
|
if (asset.info?.immutable) {
|
|
27
23
|
return null;
|
|
28
24
|
}
|
|
29
|
-
return crypto.createHash("md5").update(
|
|
25
|
+
return crypto.createHash("md5").update(asset.source.source()).digest("hex");
|
|
30
26
|
};
|
|
31
27
|
|
|
32
28
|
const resolveWebpackURL = (publicPath, ...paths)=>{
|
|
@@ -200,7 +196,7 @@ class InjectManifest {
|
|
|
200
196
|
}
|
|
201
197
|
config.exclude.push(({ asset })=>_generatedAssetNames.has(asset.name));
|
|
202
198
|
const { size, sortedEntries } = await getManifestEntriesFromCompilation(compilation, config);
|
|
203
|
-
let manifestString = stringify(sortedEntries);
|
|
199
|
+
let manifestString = JSON.stringify(sortedEntries);
|
|
204
200
|
if (this.config.compileSrc && !(compilation.options?.devtool === "eval-cheap-source-map" && compilation.options.optimization?.minimize)) {
|
|
205
201
|
manifestString = manifestString.replace(/"/g, `'`);
|
|
206
202
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relative-to-output-path.d.ts","sourceRoot":"","sources":["../../src/lib/relative-to-output-path.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"relative-to-output-path.d.ts","sourceRoot":"","sources":["../../src/lib/relative-to-output-path.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,gBAAiB,WAAW,gBAAgB,MAAM,KAAG,MAQrF,CAAC"}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
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
|
+
import type { WebpackPluginFunction, WebpackPluginInstance, Asset, Compilation } from "webpack";
|
|
4
|
+
export interface ConditionCallbackOptions {
|
|
5
|
+
asset: Asset;
|
|
6
|
+
compilation: Compilation;
|
|
7
|
+
}
|
|
8
|
+
export type ConditionCallback = (options: ConditionCallbackOptions) => boolean;
|
|
4
9
|
export interface WebpackPartial {
|
|
5
10
|
/**
|
|
6
11
|
* One or more chunk names whose corresponding output files should be included
|
|
@@ -17,7 +22,7 @@ export interface WebpackPartial {
|
|
|
17
22
|
* [/\.map$/, /^manifest.*\.js$/]
|
|
18
23
|
* ```
|
|
19
24
|
*/
|
|
20
|
-
exclude?: (string | RegExp |
|
|
25
|
+
exclude?: (string | RegExp | ConditionCallback)[];
|
|
21
26
|
/**
|
|
22
27
|
* One or more chunk names whose corresponding output files should be excluded
|
|
23
28
|
* from the precache manifest.
|
|
@@ -29,7 +34,7 @@ export interface WebpackPartial {
|
|
|
29
34
|
* [the same rules](https://webpack.js.org/configuration/module/#condition)
|
|
30
35
|
* as webpack's standard `include` option.
|
|
31
36
|
*/
|
|
32
|
-
include?: (string | RegExp |
|
|
37
|
+
include?: (string | RegExp | ConditionCallback)[];
|
|
33
38
|
}
|
|
34
39
|
export type WebpackResolved = Require<WebpackPartial, "exclude">;
|
|
35
40
|
export interface 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,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;
|
|
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,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEhG,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,wBAAwB,KAAK,OAAO,CAAC;AAE/E,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,iBAAiB,CAAC,EAAE,CAAC;IAClD;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,iBAAiB,CAAC,EAAE,CAAC;CACnD;AAED,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;AAEjE,MAAM,WAAW,aAAa;IAC5B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAIrB;;;OAGG;IACH,yBAAyB,CAAC,EAAE,aAAa,EAAE,CAAC;CAC7C;AAED,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;AAElE,MAAM,WAAW,qBAAsB,SAAQ,WAAW,EAAE,cAAc,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,aAAa;CAAG;AAEtI,MAAM,WAAW,6BAA8B,SAAQ,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,cAAc;CAAG;AAEnJ,MAAM,MAAM,aAAa,GAAG,qBAAqB,GAAG,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/webpack-plugin",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.13",
|
|
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": [
|
|
@@ -60,16 +60,16 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"pretty-bytes": "6.1.1",
|
|
62
62
|
"zod": "3.24.2",
|
|
63
|
-
"@serwist/build": "9.0.
|
|
63
|
+
"@serwist/build": "9.0.13"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@types/node": "22.
|
|
66
|
+
"@types/node": "22.14.0",
|
|
67
67
|
"@types/webpack": "5.28.5",
|
|
68
|
-
"rollup": "4.
|
|
68
|
+
"rollup": "4.39.0",
|
|
69
69
|
"typescript": "5.6.3",
|
|
70
70
|
"webpack": "5.98.0",
|
|
71
|
-
"@serwist/configs": "9.0.
|
|
72
|
-
"@serwist/utils": "9.0.
|
|
71
|
+
"@serwist/configs": "9.0.13",
|
|
72
|
+
"@serwist/utils": "9.0.13"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"typescript": ">=5.0.0",
|
package/src/inject-manifest.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { escapeRegExp, replaceAndUpdateSourceMap
|
|
2
|
+
import { escapeRegExp, replaceAndUpdateSourceMap } from "@serwist/build";
|
|
3
3
|
import { toUnix } from "@serwist/utils";
|
|
4
4
|
import prettyBytes from "pretty-bytes";
|
|
5
5
|
import type { Compilation, Compiler, WebpackError, default as Webpack } from "webpack";
|
|
@@ -101,7 +101,7 @@ export class InjectManifest {
|
|
|
101
101
|
|
|
102
102
|
const { size, sortedEntries } = await getManifestEntriesFromCompilation(compilation, config);
|
|
103
103
|
|
|
104
|
-
let manifestString = stringify(sortedEntries);
|
|
104
|
+
let manifestString = JSON.stringify(sortedEntries);
|
|
105
105
|
if (
|
|
106
106
|
this.config.compileSrc &&
|
|
107
107
|
// See https://github.com/GoogleChrome/workbox/issues/2729
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
license that can be found in the LICENSE file or at
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
|
+
import { toUnix } from "@serwist/utils";
|
|
8
9
|
import path from "node:path";
|
|
9
10
|
import type { Compilation } from "webpack";
|
|
10
11
|
|
|
@@ -20,7 +21,7 @@ import type { Compilation } from "webpack";
|
|
|
20
21
|
export const relativeToOutputPath = (compilation: Compilation, originalPath: string): string => {
|
|
21
22
|
// See https://github.com/jantimon/html-webpack-plugin/pull/266/files#diff-168726dbe96b3ce427e7fedce31bb0bcR38
|
|
22
23
|
if (path.resolve(originalPath) === path.normalize(originalPath)) {
|
|
23
|
-
return path.relative(compilation.options.output.path!, originalPath);
|
|
24
|
+
return toUnix(path.relative(compilation.options.output.path!, originalPath));
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
// Otherwise, return swDest as-is.
|
package/src/lib/types.ts
CHANGED
|
@@ -7,7 +7,14 @@ 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
|
+
import type { WebpackPluginFunction, WebpackPluginInstance, Asset, Compilation } from "webpack";
|
|
11
|
+
|
|
12
|
+
export interface ConditionCallbackOptions {
|
|
13
|
+
asset: Asset;
|
|
14
|
+
compilation: Compilation;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type ConditionCallback = (options: ConditionCallbackOptions) => boolean;
|
|
11
18
|
|
|
12
19
|
export interface WebpackPartial {
|
|
13
20
|
/**
|
|
@@ -25,7 +32,7 @@ export interface WebpackPartial {
|
|
|
25
32
|
* [/\.map$/, /^manifest.*\.js$/]
|
|
26
33
|
* ```
|
|
27
34
|
*/
|
|
28
|
-
exclude?: (string | RegExp |
|
|
35
|
+
exclude?: (string | RegExp | ConditionCallback)[];
|
|
29
36
|
/**
|
|
30
37
|
* One or more chunk names whose corresponding output files should be excluded
|
|
31
38
|
* from the precache manifest.
|
|
@@ -37,7 +44,7 @@ export interface WebpackPartial {
|
|
|
37
44
|
* [the same rules](https://webpack.js.org/configuration/module/#condition)
|
|
38
45
|
* as webpack's standard `include` option.
|
|
39
46
|
*/
|
|
40
|
-
include?: (string | RegExp |
|
|
47
|
+
include?: (string | RegExp | ConditionCallback)[];
|
|
41
48
|
}
|
|
42
49
|
|
|
43
50
|
export type WebpackResolved = Require<WebpackPartial, "exclude">;
|