@serwist/webpack-plugin 9.2.2 → 9.3.0

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.
@@ -1,4 +1,4 @@
1
- import { p as performChildCompilation, r as relativeToOutputPath } from './chunks/perform-child-compilation.js';
1
+ import { p as performChildCompilation, r as relativeToOutputPath } from './chunks/relative-to-output-path.js';
2
2
  import 'node:path';
3
3
 
4
4
  class ChildCompilationPlugin {
package/dist/index.js CHANGED
@@ -1,22 +1,9 @@
1
1
  import path from 'node:path';
2
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
+ import { r as relativeToOutputPath, p as performChildCompilation, t as toUnix } from './chunks/relative-to-output-path.js';
4
4
  import prettyBytes from 'pretty-bytes';
5
- import { validationErrorMap, SerwistConfigError } from '@serwist/build/schema';
6
5
  import crypto from 'node:crypto';
7
-
8
- const validateInjectManifestOptions = async (input)=>{
9
- const result = await (await import('./chunks/schema.js')).injectManifestOptions.spa(input, {
10
- error: validationErrorMap
11
- });
12
- if (!result.success) {
13
- throw new SerwistConfigError({
14
- moduleName: "@serwist/webpack-plugin",
15
- message: JSON.stringify(result.error.format(), null, 2)
16
- });
17
- }
18
- return result.data;
19
- };
6
+ import { validationErrorMap, SerwistConfigError } from '@serwist/build/schema';
20
7
 
21
8
  const getAssetHash = (asset)=>{
22
9
  if (asset.info?.immutable) {
@@ -162,6 +149,19 @@ const getSourcemapAssetName = (compilation, swContents, swDest)=>{
162
149
  return undefined;
163
150
  };
164
151
 
152
+ const validateInjectManifestOptions = async (input)=>{
153
+ const result = await (await import('./chunks/schema.js')).injectManifestOptions.spa(input, {
154
+ error: validationErrorMap
155
+ });
156
+ if (!result.success) {
157
+ throw new SerwistConfigError({
158
+ moduleName: "@serwist/webpack-plugin",
159
+ message: JSON.stringify(result.error.format(), null, 2)
160
+ });
161
+ }
162
+ return result.data;
163
+ };
164
+
165
165
  const _generatedAssetNames = new Set();
166
166
  class InjectManifest {
167
167
  config;
@@ -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;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;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
+ {"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":"child-compilation-plugin.d.ts","sourceRoot":"","sources":["../../src/lib/child-compilation-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAgB,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAK7E,MAAM,WAAW,6BAA6B;IAC5C,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,qBAAqB,EAAE,CAAC;CACnC;AAED;;;;GAIG;AACH,qBAAa,sBAAuB,YAAW,qBAAqB;IAClE,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,qBAAqB,EAAE,GAAG,SAAS,CAAC;gBACjC,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,6BAA6B;IAKjE;;;;OAIG;IACH,KAAK,CAAC,QAAQ,EAAE,QAAQ;CAczB"}
1
+ {"version":3,"file":"child-compilation-plugin.d.ts","sourceRoot":"","sources":["../../src/lib/child-compilation-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAgB,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAI7E,MAAM,WAAW,6BAA6B;IAC5C,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,qBAAqB,EAAE,CAAC;CACnC;AAED;;;;GAIG;AACH,qBAAa,sBAAuB,YAAW,qBAAqB;IAClE,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,qBAAqB,EAAE,GAAG,SAAS,CAAC;gBACjC,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,6BAA6B;IAKjE;;;;OAIG;IACH,KAAK,CAAC,QAAQ,EAAE,QAAQ;CAczB"}
@@ -1 +1 @@
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
+ {"version":3,"file":"relative-to-output-path.d.ts","sourceRoot":"","sources":["../../src/lib/relative-to-output-path.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,GAAI,aAAa,WAAW,EAAE,cAAc,MAAM,KAAG,MAQrF,CAAC"}
@@ -1,6 +1,6 @@
1
- import type { BasePartial, BaseResolved, InjectPartial as BaseInjectPartial, InjectResolved as BaseInjectResolved, OptionalSwDestPartial, OptionalSwDestResolved } from "@serwist/build";
1
+ import type { InjectPartial as BaseInjectPartial, InjectResolved as BaseInjectResolved, BasePartial, BaseResolved, OptionalSwDestPartial, OptionalSwDestResolved } from "@serwist/build";
2
2
  import type { Require } from "@serwist/utils";
3
- import type { WebpackPluginFunction, WebpackPluginInstance, Asset, Compilation } from "webpack";
3
+ import type { Asset, Compilation, WebpackPluginFunction, WebpackPluginInstance } from "webpack";
4
4
  export interface ConditionCallbackOptions {
5
5
  asset: Asset;
6
6
  compilation: Compilation;
@@ -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,IA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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.2.2",
3
+ "version": "9.3.0",
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": [
@@ -59,17 +59,17 @@
59
59
  },
60
60
  "dependencies": {
61
61
  "pretty-bytes": "6.1.1",
62
- "zod": "4.1.12",
63
- "@serwist/build": "9.2.2"
62
+ "zod": "4.2.1",
63
+ "@serwist/build": "9.3.0"
64
64
  },
65
65
  "devDependencies": {
66
- "@types/node": "24.10.1",
66
+ "@types/node": "25.0.3",
67
67
  "@types/webpack": "5.28.5",
68
- "rollup": "4.53.3",
68
+ "rollup": "4.54.0",
69
69
  "typescript": "5.9.3",
70
- "webpack": "5.103.0",
71
- "@serwist/configs": "9.2.2",
72
- "@serwist/utils": "9.2.2"
70
+ "webpack": "5.104.1",
71
+ "@serwist/configs": "9.3.0",
72
+ "@serwist/utils": "9.3.0"
73
73
  },
74
74
  "peerDependencies": {
75
75
  "typescript": ">=5.0.0",
@@ -2,13 +2,13 @@ import path from "node:path";
2
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, WebpackError, default as Webpack } from "webpack";
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
@@ -1,7 +1,6 @@
1
1
  import type { Compiler, WebpackError, WebpackPluginInstance } from "webpack";
2
-
3
- import { relativeToOutputPath } from "./relative-to-output-path.js";
4
2
  import { performChildCompilation } from "./perform-child-compilation.js";
3
+ import { relativeToOutputPath } from "./relative-to-output-path.js";
5
4
 
6
5
  export interface ChildCompilationPluginOptions {
7
6
  src: string;
@@ -5,8 +5,9 @@
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
9
  import path from "node:path";
10
+ import { toUnix } from "@serwist/utils";
10
11
  import type { Compilation } from "webpack";
11
12
 
12
13
  /**
package/src/lib/schema.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { fn, basePartial, injectPartial as baseInjectPartial, optionalSwDestPartial } from "@serwist/build/schema";
1
+ import { injectPartial as baseInjectPartial, basePartial, fn, optionalSwDestPartial } from "@serwist/build/schema";
2
2
  import { z } from "zod";
3
3
 
4
4
  const webpackConditionCallback = fn({
package/src/lib/types.ts CHANGED
@@ -1,13 +1,13 @@
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
9
  import type { Require } from "@serwist/utils";
10
- import type { WebpackPluginFunction, WebpackPluginInstance, Asset, Compilation } from "webpack";
10
+ import type { Asset, Compilation, WebpackPluginFunction, WebpackPluginInstance } from "webpack";
11
11
 
12
12
  export interface ConditionCallbackOptions {
13
13
  asset: Asset;
@@ -4,13 +4,6 @@ const toUnix = (p)=>{
4
4
  return p.replace(/\\/g, "/").replace(/(?<!^)\/+/g, "/");
5
5
  };
6
6
 
7
- const relativeToOutputPath = (compilation, originalPath)=>{
8
- if (path.resolve(originalPath) === path.normalize(originalPath)) {
9
- return toUnix(path.relative(compilation.options.output.path, originalPath));
10
- }
11
- return originalPath;
12
- };
13
-
14
7
  const performChildCompilation = async (compiler, compilation, name, src, dest, plugins)=>{
15
8
  const childCompiler = compilation.createChildCompiler(name, {
16
9
  filename: dest
@@ -34,4 +27,11 @@ const performChildCompilation = async (compiler, compilation, name, src, dest, p
34
27
  });
35
28
  };
36
29
 
30
+ const relativeToOutputPath = (compilation, originalPath)=>{
31
+ if (path.resolve(originalPath) === path.normalize(originalPath)) {
32
+ return toUnix(path.relative(compilation.options.output.path, originalPath));
33
+ }
34
+ return originalPath;
35
+ };
36
+
37
37
  export { performChildCompilation as p, relativeToOutputPath as r, toUnix as t };