@serwist/webpack-plugin 9.1.0-preview.0 → 10.0.0-preview.2
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 → relative-to-output-path.js} +8 -7
- package/dist/index.internal.js +2 -1
- package/dist/index.js +19 -22
- package/dist/inject-manifest.d.ts.map +1 -1
- package/dist/lib/get-asset-hash.d.ts.map +1 -1
- package/dist/lib/get-manifest-entries-from-compilation.d.ts.map +1 -1
- package/dist/lib/get-script-files-for-chunks.d.ts.map +1 -1
- package/dist/lib/get-sourcemap-asset-name.d.ts.map +1 -1
- package/dist/lib/perform-child-compilation.d.ts.map +1 -1
- package/dist/lib/relative-to-output-path.d.ts.map +1 -1
- package/dist/lib/resolve-webpack-url.d.ts.map +1 -1
- package/dist/lib/schema.d.ts +15 -19
- package/dist/lib/schema.d.ts.map +1 -1
- package/dist/lib/types.d.ts +14 -11
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/validator.d.ts.map +1 -1
- package/package.json +11 -10
- package/src/inject-manifest.ts +6 -6
- package/src/lib/child-compilation-plugin.ts +1 -1
- package/src/lib/get-asset-hash.ts +1 -1
- package/src/lib/relative-to-output-path.ts +2 -1
- package/src/lib/schema.ts +1 -1
- package/src/lib/types.ts +17 -10
|
@@ -1,12 +1,6 @@
|
|
|
1
|
+
import { toUnix } from '@serwist/utils';
|
|
1
2
|
import path from 'node:path';
|
|
2
3
|
|
|
3
|
-
const relativeToOutputPath = (compilation, originalPath)=>{
|
|
4
|
-
if (path.resolve(originalPath) === path.normalize(originalPath)) {
|
|
5
|
-
return path.relative(compilation.options.output.path, originalPath);
|
|
6
|
-
}
|
|
7
|
-
return originalPath;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
4
|
const performChildCompilation = async (compiler, compilation, name, src, dest, plugins)=>{
|
|
11
5
|
const childCompiler = compilation.createChildCompiler(name, {
|
|
12
6
|
filename: dest
|
|
@@ -30,4 +24,11 @@ const performChildCompilation = async (compiler, compilation, name, src, dest, p
|
|
|
30
24
|
});
|
|
31
25
|
};
|
|
32
26
|
|
|
27
|
+
const relativeToOutputPath = (compilation, originalPath)=>{
|
|
28
|
+
if (path.resolve(originalPath) === path.normalize(originalPath)) {
|
|
29
|
+
return toUnix(path.relative(compilation.options.output.path, originalPath));
|
|
30
|
+
}
|
|
31
|
+
return originalPath;
|
|
32
|
+
};
|
|
33
|
+
|
|
33
34
|
export { performChildCompilation as p, relativeToOutputPath as r };
|
package/dist/index.internal.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { p as performChildCompilation, r as relativeToOutputPath } from './chunks/
|
|
1
|
+
import { p as performChildCompilation, r as relativeToOutputPath } from './chunks/relative-to-output-path.js';
|
|
2
|
+
import '@serwist/utils';
|
|
2
3
|
import 'node:path';
|
|
3
4
|
|
|
4
5
|
class ChildCompilationPlugin {
|
package/dist/index.js
CHANGED
|
@@ -1,32 +1,16 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { transformManifest, getSourceMapURL,
|
|
2
|
+
import { transformManifest, getSourceMapURL, escapeRegExp, replaceAndUpdateSourceMap } from '@serwist/build';
|
|
3
|
+
import { toUnix } from '@serwist/utils';
|
|
3
4
|
import prettyBytes from 'pretty-bytes';
|
|
4
|
-
import { validationErrorMap, SerwistConfigError } from '@serwist/build/schema';
|
|
5
5
|
import crypto from 'node:crypto';
|
|
6
|
-
import { r as relativeToOutputPath, p as performChildCompilation } from './chunks/
|
|
7
|
-
|
|
8
|
-
const toUnix = (p)=>{
|
|
9
|
-
return p.replace(/\\/g, "/").replace(/(?<!^)\/+/g, "/");
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const validateInjectManifestOptions = async (input)=>{
|
|
13
|
-
const result = await (await import('./chunks/schema.js')).injectManifestOptions.spa(input, {
|
|
14
|
-
errorMap: validationErrorMap
|
|
15
|
-
});
|
|
16
|
-
if (!result.success) {
|
|
17
|
-
throw new SerwistConfigError({
|
|
18
|
-
moduleName: "@serwist/webpack-plugin",
|
|
19
|
-
message: JSON.stringify(result.error.format(), null, 2)
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return result.data;
|
|
23
|
-
};
|
|
6
|
+
import { r as relativeToOutputPath, p as performChildCompilation } from './chunks/relative-to-output-path.js';
|
|
7
|
+
import { validationErrorMap, SerwistConfigError } from '@serwist/build/schema';
|
|
24
8
|
|
|
25
9
|
const getAssetHash = (asset)=>{
|
|
26
10
|
if (asset.info?.immutable) {
|
|
27
11
|
return null;
|
|
28
12
|
}
|
|
29
|
-
return crypto.createHash("md5").update(
|
|
13
|
+
return crypto.createHash("md5").update(asset.source.source()).digest("hex");
|
|
30
14
|
};
|
|
31
15
|
|
|
32
16
|
const resolveWebpackURL = (publicPath, ...paths)=>{
|
|
@@ -164,6 +148,19 @@ const getSourcemapAssetName = (compilation, swContents, swDest)=>{
|
|
|
164
148
|
return undefined;
|
|
165
149
|
};
|
|
166
150
|
|
|
151
|
+
const validateInjectManifestOptions = async (input)=>{
|
|
152
|
+
const result = await (await import('./chunks/schema.js')).injectManifestOptions.spa(input, {
|
|
153
|
+
errorMap: validationErrorMap
|
|
154
|
+
});
|
|
155
|
+
if (!result.success) {
|
|
156
|
+
throw new SerwistConfigError({
|
|
157
|
+
moduleName: "@serwist/webpack-plugin",
|
|
158
|
+
message: JSON.stringify(result.error.format(), null, 2)
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
return result.data;
|
|
162
|
+
};
|
|
163
|
+
|
|
167
164
|
const _generatedAssetNames = new Set();
|
|
168
165
|
class InjectManifest {
|
|
169
166
|
config;
|
|
@@ -200,7 +197,7 @@ class InjectManifest {
|
|
|
200
197
|
}
|
|
201
198
|
config.exclude.push(({ asset })=>_generatedAssetNames.has(asset.name));
|
|
202
199
|
const { size, sortedEntries } = await getManifestEntriesFromCompilation(compilation, config);
|
|
203
|
-
let manifestString = stringify(sortedEntries);
|
|
200
|
+
let manifestString = JSON.stringify(sortedEntries);
|
|
204
201
|
if (this.config.compileSrc && !(compilation.options?.devtool === "eval-cheap-source-map" && compilation.options.optimization?.minimize)) {
|
|
205
202
|
manifestString = manifestString.replace(/"/g, `'`);
|
|
206
203
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-manifest.d.ts","sourceRoot":"","sources":["../src/inject-manifest.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAe,QAAQ,EAAoC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"inject-manifest.d.ts","sourceRoot":"","sources":["../src/inject-manifest.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAe,QAAQ,EAAoC,MAAM,SAAS,CAAC;AAKvF,OAAO,KAAK,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAO3F;;;;;;;;;;;;;;;;;;;;;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;IAQzC;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAa9B;;;;OAIG;YACW,kBAAkB;IAuChC;;;;OAIG;IACH,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IA6B/B;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAKtB;;;;;OAKG;YACW,UAAU;IAwBxB;;;;OAIG;YACW,SAAS;CAiDxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-asset-hash.d.ts","sourceRoot":"","sources":["../../src/lib/get-asset-hash.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC;;;;;GAKG;AACH,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"get-asset-hash.d.ts","sourceRoot":"","sources":["../../src/lib/get-asset-hash.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,KAAK,KAAG,MAAM,GAAG,IASpD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-manifest-entries-from-compilation.d.ts","sourceRoot":"","sources":["../../src/lib/get-manifest-entries-from-compilation.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,KAAK,EAAgB,WAAW,EAAgB,MAAM,SAAS,CAAC;AAIvE,OAAO,KAAK,EAAyB,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAoKvF,eAAO,MAAM,iCAAiC,
|
|
1
|
+
{"version":3,"file":"get-manifest-entries-from-compilation.d.ts","sourceRoot":"","sources":["../../src/lib/get-manifest-entries-from-compilation.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,KAAK,EAAgB,WAAW,EAAgB,MAAM,SAAS,CAAC;AAIvE,OAAO,KAAK,EAAyB,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAoKvF,eAAO,MAAM,iCAAiC,GAC5C,aAAa,WAAW,EACxB,QAAQ,6BAA6B,KACpC,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,aAAa,EAAE,GAAG,SAAS,CAAA;CAAE,CAiCtE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-script-files-for-chunks.d.ts","sourceRoot":"","sources":["../../src/lib/get-script-files-for-chunks.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,SAAS,CAAC;AAIzD,eAAO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"get-script-files-for-chunks.d.ts","sourceRoot":"","sources":["../../src/lib/get-script-files-for-chunks.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,SAAS,CAAC;AAIzD,eAAO,MAAM,uBAAuB,GAAI,aAAa,WAAW,EAAE,YAAY,MAAM,EAAE,KAAG,MAAM,EAwB9F,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-sourcemap-asset-name.d.ts","sourceRoot":"","sources":["../../src/lib/get-sourcemap-asset-name.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"get-sourcemap-asset-name.d.ts","sourceRoot":"","sources":["../../src/lib/get-sourcemap-asset-name.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,qBAAqB,GAAI,aAAa,WAAW,EAAE,YAAY,MAAM,EAAE,QAAQ,MAAM,KAAG,MAAM,GAAG,SAgB7G,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perform-child-compilation.d.ts","sourceRoot":"","sources":["../../src/lib/perform-child-compilation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"perform-child-compilation.d.ts","sourceRoot":"","sources":["../../src/lib/perform-child-compilation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,GAClC,UAAU,QAAQ,EAClB,aAAa,WAAW,EACxB,MAAM,MAAM,EACZ,KAAK,MAAM,EACX,MAAM,MAAM,EACZ,SAAS,aAAa,EAAE,GAAG,SAAS,kBAuBrC,CAAC"}
|
|
@@ -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,GAAI,aAAa,WAAW,EAAE,cAAc,MAAM,KAAG,MAQrF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-webpack-url.d.ts","sourceRoot":"","sources":["../../src/lib/resolve-webpack-url.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"resolve-webpack-url.d.ts","sourceRoot":"","sources":["../../src/lib/resolve-webpack-url.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,GAAI,YAAY,MAAM,EAAE,GAAG,OAAO,MAAM,EAAE,KAAG,MAO1E,CAAC"}
|
package/dist/lib/schema.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare const injectPartial: z.ZodObject<{
|
|
|
28
28
|
webpackCompilationPlugins?: any[] | undefined;
|
|
29
29
|
swDest?: string | undefined;
|
|
30
30
|
}>;
|
|
31
|
-
export declare const injectManifestOptions: z.ZodObject<
|
|
31
|
+
export declare const injectManifestOptions: z.ZodObject<{
|
|
32
32
|
additionalPrecacheEntries: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
33
33
|
integrity: z.ZodOptional<z.ZodString>;
|
|
34
34
|
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -44,13 +44,13 @@ export declare const injectManifestOptions: z.ZodObject<z.objectUtil.extendShape
|
|
|
44
44
|
}>]>, "many">>;
|
|
45
45
|
disablePrecacheManifest: z.ZodDefault<z.ZodBoolean>;
|
|
46
46
|
dontCacheBustURLsMatching: z.ZodOptional<z.ZodType<RegExp, z.ZodTypeDef, RegExp>>;
|
|
47
|
-
manifestTransforms: z.ZodOptional<z.ZodArray<z.ZodFunction<z.ZodTuple<[z.ZodArray<z.ZodObject<
|
|
47
|
+
manifestTransforms: z.ZodOptional<z.ZodArray<z.ZodFunction<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
48
48
|
integrity: z.ZodOptional<z.ZodString>;
|
|
49
49
|
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
50
50
|
url: z.ZodString;
|
|
51
|
-
}
|
|
51
|
+
} & {
|
|
52
52
|
size: z.ZodNumber;
|
|
53
|
-
}
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
54
|
url: string;
|
|
55
55
|
size: number;
|
|
56
56
|
integrity?: string | undefined;
|
|
@@ -61,13 +61,13 @@ export declare const injectManifestOptions: z.ZodObject<z.objectUtil.extendShape
|
|
|
61
61
|
integrity?: string | undefined;
|
|
62
62
|
revision?: string | null | undefined;
|
|
63
63
|
}>, "many">, z.ZodOptional<z.ZodUnknown>], null>, z.ZodUnion<[z.ZodPromise<z.ZodObject<{
|
|
64
|
-
manifest: z.ZodArray<z.ZodObject<
|
|
64
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
65
65
|
integrity: z.ZodOptional<z.ZodString>;
|
|
66
66
|
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
67
67
|
url: z.ZodString;
|
|
68
|
-
}
|
|
68
|
+
} & {
|
|
69
69
|
size: z.ZodNumber;
|
|
70
|
-
}
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
71
|
url: string;
|
|
72
72
|
size: number;
|
|
73
73
|
integrity?: string | undefined;
|
|
@@ -96,13 +96,13 @@ export declare const injectManifestOptions: z.ZodObject<z.objectUtil.extendShape
|
|
|
96
96
|
}[];
|
|
97
97
|
warnings?: string[] | undefined;
|
|
98
98
|
}>>, z.ZodObject<{
|
|
99
|
-
manifest: z.ZodArray<z.ZodObject<
|
|
99
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
100
100
|
integrity: z.ZodOptional<z.ZodString>;
|
|
101
101
|
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
102
102
|
url: z.ZodString;
|
|
103
|
-
}
|
|
103
|
+
} & {
|
|
104
104
|
size: z.ZodNumber;
|
|
105
|
-
}
|
|
105
|
+
}, "strip", z.ZodTypeAny, {
|
|
106
106
|
url: string;
|
|
107
107
|
size: number;
|
|
108
108
|
integrity?: string | undefined;
|
|
@@ -133,21 +133,17 @@ export declare const injectManifestOptions: z.ZodObject<z.objectUtil.extendShape
|
|
|
133
133
|
}>]>>, "many">>;
|
|
134
134
|
maximumFileSizeToCacheInBytes: z.ZodDefault<z.ZodNumber>;
|
|
135
135
|
modifyURLPrefix: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
136
|
-
}, {
|
|
137
136
|
chunks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
138
137
|
exclude: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>, z.ZodFunction<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>]>, "many">>;
|
|
139
138
|
excludeChunks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
140
139
|
include: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>, z.ZodFunction<z.ZodTuple<[z.ZodAny], null>, z.ZodBoolean>]>, "many">>;
|
|
141
|
-
}>, {
|
|
142
140
|
injectionPoint: z.ZodDefault<z.ZodString>;
|
|
143
141
|
swSrc: z.ZodString;
|
|
144
|
-
}
|
|
145
|
-
swDest: z.ZodOptional<z.ZodString>;
|
|
146
|
-
}>, {
|
|
142
|
+
} & {
|
|
147
143
|
compileSrc: z.ZodDefault<z.ZodBoolean>;
|
|
148
144
|
swDest: z.ZodOptional<z.ZodString>;
|
|
149
145
|
webpackCompilationPlugins: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
150
|
-
}
|
|
146
|
+
}, "strict", z.ZodTypeAny, {
|
|
151
147
|
exclude: (string | RegExp | ((args_0: any) => boolean))[];
|
|
152
148
|
compileSrc: boolean;
|
|
153
149
|
disablePrecacheManifest: boolean;
|
|
@@ -196,12 +192,14 @@ export declare const injectManifestOptions: z.ZodObject<z.objectUtil.extendShape
|
|
|
196
192
|
include?: (string | RegExp | ((args_0: any) => boolean))[] | undefined;
|
|
197
193
|
compileSrc?: boolean | undefined;
|
|
198
194
|
webpackCompilationPlugins?: any[] | undefined;
|
|
195
|
+
disablePrecacheManifest?: boolean | undefined;
|
|
196
|
+
maximumFileSizeToCacheInBytes?: number | undefined;
|
|
197
|
+
injectionPoint?: string | undefined;
|
|
199
198
|
additionalPrecacheEntries?: (string | {
|
|
200
199
|
url: string;
|
|
201
200
|
integrity?: string | undefined;
|
|
202
201
|
revision?: string | null | undefined;
|
|
203
202
|
})[] | undefined;
|
|
204
|
-
disablePrecacheManifest?: boolean | undefined;
|
|
205
203
|
dontCacheBustURLsMatching?: RegExp | undefined;
|
|
206
204
|
manifestTransforms?: ((args_0: {
|
|
207
205
|
url: string;
|
|
@@ -225,9 +223,7 @@ export declare const injectManifestOptions: z.ZodObject<z.objectUtil.extendShape
|
|
|
225
223
|
}[];
|
|
226
224
|
warnings?: string[] | undefined;
|
|
227
225
|
}>)[] | undefined;
|
|
228
|
-
maximumFileSizeToCacheInBytes?: number | undefined;
|
|
229
226
|
modifyURLPrefix?: Record<string, string> | undefined;
|
|
230
|
-
injectionPoint?: string | undefined;
|
|
231
227
|
swDest?: string | undefined;
|
|
232
228
|
}>;
|
|
233
229
|
//# sourceMappingURL=schema.d.ts.map
|
package/dist/lib/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/lib/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;EASmC,CAAC;AAE/D,eAAO,MAAM,aAAa;;;;;;;;;;;;EAMkD,CAAC;AAE7E,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/lib/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;EASmC,CAAC;AAE/D,eAAO,MAAM,aAAa;;;;;;;;;;;;EAMkD,CAAC;AAE7E,eAAO,MAAM,qBAAqB;;;;;;;iBAdL,CAAC;gBACV,CAAC;;;iBACyB,CAAC;gBAAsC,CAAC;;;;;;;;;;;;;iBAiB5D,CAAC;gBAAsC,CAAC;;;;iBACoB,CAAC;gBAAsC,CAAC;;;;;;;;;;;qBAAgd,CAAC;oBAA0C,CAAC;;;;qBAAkH,CAAC;oBAA0C,CAAC;;;;;;;qBAAiP,CAAC;oBAA0C,CAAC;;gBAA0D,CAAC;;;;;qBAA6H,CAAC;oBAA0C,CAAC;;gBAA0D,CAAC;;;;;;;;;;;qBAAqY,CAAC;oBAA0C,CAAC;;;;qBAAkH,CAAC;oBAA0C,CAAC;;;;;;;qBAAiP,CAAC;oBAA0C,CAAC;;gBAA0D,CAAC;;;;;qBAA6H,CAAC;oBAA0C,CAAC;;gBAA0D,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAA3U,CAAC;oBAA0C,CAAC;;;;;;;qBAAvrC,CAAC;oBAA0C,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAAm0C,CAAC;oBAA0C,CAAC;;;;;;;qBAAvrC,CAAC;oBAA0C,CAAC;;;;;;EAD7sC,CAAC"}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Require } from "@serwist/utils";
|
|
3
|
-
import type { WebpackPluginFunction, WebpackPluginInstance } from "webpack";
|
|
1
|
+
import type { InjectPartial as BaseInjectPartial, InjectResolved as BaseInjectResolved, BasePartial, BaseResolved, OptionalSwDestPartial, OptionalSwDestResolved } from "@serwist/build";
|
|
2
|
+
import type { Prettify, Require } from "@serwist/utils";
|
|
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,9 +34,9 @@ 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
|
-
export type WebpackResolved = Require<WebpackPartial, "exclude"
|
|
39
|
+
export type WebpackResolved = Prettify<Require<WebpackPartial, "exclude">>;
|
|
35
40
|
export interface InjectPartial {
|
|
36
41
|
/**
|
|
37
42
|
* When `true` (the default), the `swSrc` file will be compiled by webpack.
|
|
@@ -47,10 +52,8 @@ export interface InjectPartial {
|
|
|
47
52
|
*/
|
|
48
53
|
webpackCompilationPlugins?: WebpackPlugin[];
|
|
49
54
|
}
|
|
50
|
-
export type InjectResolved = Require<InjectPartial, "compileSrc"
|
|
51
|
-
export
|
|
52
|
-
|
|
53
|
-
export interface InjectManifestOptionsComplete extends BaseResolved, WebpackResolved, BaseInjectResolved, OptionalSwDestResolved, InjectResolved {
|
|
54
|
-
}
|
|
55
|
+
export type InjectResolved = Prettify<Require<InjectPartial, "compileSrc">>;
|
|
56
|
+
export type InjectManifestOptions = Prettify<BasePartial & WebpackPartial & BaseInjectPartial & OptionalSwDestPartial & InjectPartial>;
|
|
57
|
+
export type InjectManifestOptionsComplete = Prettify<BaseResolved & WebpackResolved & BaseInjectResolved & OptionalSwDestResolved & InjectResolved>;
|
|
55
58
|
export type WebpackPlugin = WebpackPluginFunction | WebpackPluginInstance;
|
|
56
59
|
//# sourceMappingURL=types.d.ts.map
|
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,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,IAAI,iBAAiB,EAClC,cAAc,IAAI,kBAAkB,EACpC,WAAW,EACX,YAAY,EACZ,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACxD,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,QAAQ,CAAC,OAAO,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC,CAAC;AAE3E,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,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;AAE5E,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC,WAAW,GAAG,cAAc,GAAG,iBAAiB,GAAG,qBAAqB,GAAG,aAAa,CAAC,CAAC;AAEvI,MAAM,MAAM,6BAA6B,GAAG,QAAQ,CAAC,YAAY,GAAG,eAAe,GAAG,kBAAkB,GAAG,sBAAsB,GAAG,cAAc,CAAC,CAAC;AAEpJ,MAAM,MAAM,aAAa,GAAG,qBAAqB,GAAG,qBAAqB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/lib/validator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAEhE,eAAO,MAAM,6BAA6B,
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/lib/validator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAEhE,eAAO,MAAM,6BAA6B,GAAU,OAAO,OAAO,KAAG,OAAO,CAAC,6BAA6B,CAMzG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/webpack-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0-preview.2",
|
|
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": [
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"file manifest"
|
|
21
21
|
],
|
|
22
22
|
"engines": {
|
|
23
|
-
"node": ">=
|
|
23
|
+
"node": ">=20.0.0"
|
|
24
24
|
},
|
|
25
25
|
"author": "Google's Web DevRel Team",
|
|
26
26
|
"contributors": [
|
|
@@ -59,17 +59,17 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"pretty-bytes": "6.1.1",
|
|
62
|
-
"zod": "3.
|
|
63
|
-
"@serwist/build": "
|
|
62
|
+
"zod": "3.24.3",
|
|
63
|
+
"@serwist/build": "10.0.0-preview.2",
|
|
64
|
+
"@serwist/utils": "10.0.0-preview.2"
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|
|
66
|
-
"@types/node": "22.
|
|
67
|
+
"@types/node": "22.14.1",
|
|
67
68
|
"@types/webpack": "5.28.5",
|
|
68
|
-
"rollup": "4.
|
|
69
|
-
"typescript": "5.
|
|
70
|
-
"webpack": "5.
|
|
71
|
-
"@serwist/configs": "
|
|
72
|
-
"@serwist/utils": "9.1.0-preview.0"
|
|
69
|
+
"rollup": "4.40.0",
|
|
70
|
+
"typescript": "5.8.3",
|
|
71
|
+
"webpack": "5.99.6",
|
|
72
|
+
"@serwist/configs": "10.0.0-preview.2"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"typescript": ">=5.0.0",
|
|
@@ -87,6 +87,7 @@
|
|
|
87
87
|
"build": "rimraf dist && NODE_ENV=production rollup --config rollup.config.js",
|
|
88
88
|
"dev": "rollup --config rollup.config.js --watch",
|
|
89
89
|
"lint": "biome lint ./src",
|
|
90
|
+
"qcheck": "biome check ./src",
|
|
90
91
|
"typecheck": "tsc"
|
|
91
92
|
}
|
|
92
93
|
}
|
package/src/inject-manifest.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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
|
-
import type { Compilation, Compiler,
|
|
6
|
-
import type { InjectManifestOptions, InjectManifestOptionsComplete } from "./lib/types.js";
|
|
7
|
-
import { validateInjectManifestOptions } from "./lib/validator.js";
|
|
5
|
+
import type { Compilation, Compiler, default as Webpack, WebpackError } from "webpack";
|
|
8
6
|
import { getManifestEntriesFromCompilation } from "./lib/get-manifest-entries-from-compilation.js";
|
|
9
7
|
import { getSourcemapAssetName } from "./lib/get-sourcemap-asset-name.js";
|
|
10
|
-
import { relativeToOutputPath } from "./lib/relative-to-output-path.js";
|
|
11
8
|
import { performChildCompilation } from "./lib/perform-child-compilation.js";
|
|
9
|
+
import { relativeToOutputPath } from "./lib/relative-to-output-path.js";
|
|
10
|
+
import type { InjectManifestOptions, InjectManifestOptionsComplete } from "./lib/types.js";
|
|
11
|
+
import { validateInjectManifestOptions } from "./lib/validator.js";
|
|
12
12
|
|
|
13
13
|
// Used to keep track of swDest files written by *any* instance of this plugin.
|
|
14
14
|
// See https://github.com/GoogleChrome/workbox/issues/2181
|
|
@@ -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
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Compiler, WebpackError, WebpackPluginInstance } from "webpack";
|
|
2
2
|
|
|
3
|
-
import { relativeToOutputPath } from "./relative-to-output-path.js";
|
|
4
3
|
import { performChildCompilation } from "./perform-child-compilation.js";
|
|
4
|
+
import { relativeToOutputPath } from "./relative-to-output-path.js";
|
|
5
5
|
|
|
6
6
|
export interface ChildCompilationPluginOptions {
|
|
7
7
|
src: string;
|
|
@@ -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/schema.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { injectPartial as baseInjectPartial, basePartial, optionalSwDestPartial } from "@serwist/build/schema";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
export const webpackPartial = z
|
package/src/lib/types.ts
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
BasePartial,
|
|
3
|
-
BaseResolved,
|
|
4
2
|
InjectPartial as BaseInjectPartial,
|
|
5
3
|
InjectResolved as BaseInjectResolved,
|
|
4
|
+
BasePartial,
|
|
5
|
+
BaseResolved,
|
|
6
6
|
OptionalSwDestPartial,
|
|
7
7
|
OptionalSwDestResolved,
|
|
8
8
|
} from "@serwist/build";
|
|
9
|
-
import type { Require } from "@serwist/utils";
|
|
10
|
-
import type { WebpackPluginFunction, WebpackPluginInstance } from "webpack";
|
|
9
|
+
import type { Prettify, Require } from "@serwist/utils";
|
|
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,10 +44,10 @@ 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
|
-
export type WebpackResolved = Require<WebpackPartial, "exclude"
|
|
50
|
+
export type WebpackResolved = Prettify<Require<WebpackPartial, "exclude">>;
|
|
44
51
|
|
|
45
52
|
export interface InjectPartial {
|
|
46
53
|
/**
|
|
@@ -61,10 +68,10 @@ export interface InjectPartial {
|
|
|
61
68
|
webpackCompilationPlugins?: WebpackPlugin[];
|
|
62
69
|
}
|
|
63
70
|
|
|
64
|
-
export type InjectResolved = Require<InjectPartial, "compileSrc"
|
|
71
|
+
export type InjectResolved = Prettify<Require<InjectPartial, "compileSrc">>;
|
|
65
72
|
|
|
66
|
-
export
|
|
73
|
+
export type InjectManifestOptions = Prettify<BasePartial & WebpackPartial & BaseInjectPartial & OptionalSwDestPartial & InjectPartial>;
|
|
67
74
|
|
|
68
|
-
export
|
|
75
|
+
export type InjectManifestOptionsComplete = Prettify<BaseResolved & WebpackResolved & BaseInjectResolved & OptionalSwDestResolved & InjectResolved>;
|
|
69
76
|
|
|
70
77
|
export type WebpackPlugin = WebpackPluginFunction | WebpackPluginInstance;
|