@serwist/webpack-plugin 9.5.6 → 9.5.8
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/relative-to-output-path-Gvhd54pA.js +49 -0
- package/dist/chunks/relative-to-output-path-Gvhd54pA.js.map +1 -0
- package/dist/chunks/schema-CpgCa1bB.js +51 -0
- package/dist/chunks/schema-CpgCa1bB.js.map +1 -0
- package/dist/index.d.mts +137 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.internal.d.mts +44 -0
- package/dist/index.internal.d.mts.map +1 -0
- package/dist/index.internal.mjs +31 -0
- package/dist/index.internal.mjs.map +1 -0
- package/dist/index.mjs +345 -0
- package/dist/index.mjs.map +1 -0
- package/dist/index.schema.d.mts +90 -0
- package/dist/index.schema.d.mts.map +1 -0
- package/dist/index.schema.mjs +2 -0
- package/package.json +19 -20
- package/dist/chunks/relative-to-output-path.js +0 -34
- package/dist/chunks/schema.js +0 -37
- package/dist/index.d.ts +0 -6
- package/dist/index.d.ts.map +0 -1
- package/dist/index.internal.d.ts +0 -4
- package/dist/index.internal.d.ts.map +0 -1
- package/dist/index.internal.js +0 -21
- package/dist/index.js +0 -281
- package/dist/index.schema.d.ts +0 -3
- package/dist/index.schema.d.ts.map +0 -1
- package/dist/index.schema.js +0 -3
- package/dist/inject-manifest.d.ts +0 -72
- package/dist/inject-manifest.d.ts.map +0 -1
- package/dist/lib/child-compilation-plugin.d.ts +0 -24
- package/dist/lib/child-compilation-plugin.d.ts.map +0 -1
- package/dist/lib/get-asset-hash.d.ts +0 -9
- package/dist/lib/get-asset-hash.d.ts.map +0 -1
- package/dist/lib/get-manifest-entries-from-compilation.d.ts +0 -8
- package/dist/lib/get-manifest-entries-from-compilation.d.ts.map +0 -1
- package/dist/lib/get-script-files-for-chunks.d.ts +0 -3
- package/dist/lib/get-script-files-for-chunks.d.ts.map +0 -1
- package/dist/lib/get-sourcemap-asset-name.d.ts +0 -20
- package/dist/lib/get-sourcemap-asset-name.d.ts.map +0 -1
- package/dist/lib/perform-child-compilation.d.ts +0 -16
- package/dist/lib/perform-child-compilation.d.ts.map +0 -1
- package/dist/lib/relative-to-output-path.d.ts +0 -12
- package/dist/lib/relative-to-output-path.d.ts.map +0 -1
- package/dist/lib/resolve-webpack-url.d.ts +0 -13
- package/dist/lib/resolve-webpack-url.d.ts.map +0 -1
- package/dist/lib/schema.d.ts +0 -86
- package/dist/lib/schema.d.ts.map +0 -1
- package/dist/lib/types.d.ts +0 -61
- package/dist/lib/types.d.ts.map +0 -1
- package/dist/lib/validator.d.ts +0 -3
- package/dist/lib/validator.d.ts.map +0 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { toUnix } from "@serwist/utils";
|
|
3
|
+
//#region src/lib/perform-child-compilation.ts
|
|
4
|
+
/**
|
|
5
|
+
* Perform a child compilation.
|
|
6
|
+
*
|
|
7
|
+
* @param compiler The parent webpack compiler.
|
|
8
|
+
* @param compilation The webpack compilation.
|
|
9
|
+
* @param name The name of the child compiler.
|
|
10
|
+
* @param src The source file. Should be absolute.
|
|
11
|
+
* @param dest The destination file. Should be relative to the compilation.
|
|
12
|
+
* @param plugins Additional webpack plugins.
|
|
13
|
+
*
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
const performChildCompilation = async (compiler, compilation, name, src, dest, plugins) => {
|
|
17
|
+
const childCompiler = compilation.createChildCompiler(name, { filename: dest }, plugins);
|
|
18
|
+
new compiler.webpack.webworker.WebWorkerTemplatePlugin().apply(childCompiler);
|
|
19
|
+
new compiler.webpack.EntryPlugin(compiler.context, src, name).apply(childCompiler);
|
|
20
|
+
await new Promise((resolve, reject) => {
|
|
21
|
+
childCompiler.runAsChild((error, _entries, childCompilation) => {
|
|
22
|
+
if (error) reject(error);
|
|
23
|
+
else {
|
|
24
|
+
if (childCompilation?.warnings) compilation.warnings.push(...childCompilation.warnings);
|
|
25
|
+
if (childCompilation?.errors) compilation.errors.push(...childCompilation.errors);
|
|
26
|
+
resolve();
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/lib/relative-to-output-path.ts
|
|
33
|
+
/**
|
|
34
|
+
* @param compilation The webpack compilation.
|
|
35
|
+
* @param originalPath The original path value.
|
|
36
|
+
*
|
|
37
|
+
* @returns If path was not absolute, the returns path as-is.
|
|
38
|
+
* Otherwise, returns path relative to the compilation's output path.
|
|
39
|
+
*
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
42
|
+
const relativeToOutputPath = (compilation, originalPath) => {
|
|
43
|
+
if (path.resolve(originalPath) === path.normalize(originalPath)) return toUnix(path.relative(compilation.options.output.path, originalPath));
|
|
44
|
+
return originalPath;
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
export { performChildCompilation as n, relativeToOutputPath as t };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=relative-to-output-path-Gvhd54pA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relative-to-output-path-Gvhd54pA.js","names":[],"sources":["../../src/lib/perform-child-compilation.ts","../../src/lib/relative-to-output-path.ts"],"sourcesContent":["import type { Compilation, Compiler } from \"webpack\";\nimport type { WebpackPlugin } from \"./types.js\";\n\n/**\n * Perform a child compilation.\n *\n * @param compiler The parent webpack compiler.\n * @param compilation The webpack compilation.\n * @param name The name of the child compiler.\n * @param src The source file. Should be absolute.\n * @param dest The destination file. Should be relative to the compilation.\n * @param plugins Additional webpack plugins.\n *\n * @private\n */\nexport const performChildCompilation = async (\n compiler: Compiler,\n compilation: Compilation,\n name: string,\n src: string,\n dest: string,\n plugins: WebpackPlugin[] | undefined,\n) => {\n const childCompiler = compilation.createChildCompiler(name, { filename: dest }, plugins);\n\n new compiler.webpack.webworker.WebWorkerTemplatePlugin().apply(childCompiler);\n\n new compiler.webpack.EntryPlugin(compiler.context, src, name).apply(childCompiler);\n\n await new Promise<void>((resolve, reject) => {\n childCompiler.runAsChild((error, _entries, childCompilation) => {\n if (error) {\n reject(error);\n } else {\n if (childCompilation?.warnings) {\n compilation.warnings.push(...childCompilation.warnings);\n }\n if (childCompilation?.errors) {\n compilation.errors.push(...childCompilation.errors);\n }\n resolve();\n }\n });\n });\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport path from \"node:path\";\nimport { toUnix } from \"@serwist/utils\";\nimport type { Compilation } from \"webpack\";\n\n/**\n * @param compilation The webpack compilation.\n * @param originalPath The original path value.\n *\n * @returns If path was not absolute, the returns path as-is.\n * Otherwise, returns path relative to the compilation's output path.\n *\n * @private\n */\nexport const relativeToOutputPath = (compilation: Compilation, originalPath: string): string => {\n // See https://github.com/jantimon/html-webpack-plugin/pull/266/files#diff-168726dbe96b3ce427e7fedce31bb0bcR38\n if (path.resolve(originalPath) === path.normalize(originalPath)) {\n return toUnix(path.relative(compilation.options.output.path!, originalPath));\n }\n\n // Otherwise, return swDest as-is.\n return originalPath;\n};\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,0BAA0B,OACrC,UACA,aACA,MACA,KACA,MACA,YACG;CACH,MAAM,gBAAgB,YAAY,oBAAoB,MAAM,EAAE,UAAU,MAAM,EAAE,QAAQ;AAExF,KAAI,SAAS,QAAQ,UAAU,yBAAyB,CAAC,MAAM,cAAc;AAE7E,KAAI,SAAS,QAAQ,YAAY,SAAS,SAAS,KAAK,KAAK,CAAC,MAAM,cAAc;AAElF,OAAM,IAAI,SAAe,SAAS,WAAW;AAC3C,gBAAc,YAAY,OAAO,UAAU,qBAAqB;AAC9D,OAAI,MACF,QAAO,MAAM;QACR;AACL,QAAI,kBAAkB,SACpB,aAAY,SAAS,KAAK,GAAG,iBAAiB,SAAS;AAEzD,QAAI,kBAAkB,OACpB,aAAY,OAAO,KAAK,GAAG,iBAAiB,OAAO;AAErD,aAAS;;IAEX;GACF;;;;;;;;;;;;;ACtBJ,MAAa,wBAAwB,aAA0B,iBAAiC;AAE9F,KAAI,KAAK,QAAQ,aAAa,KAAK,KAAK,UAAU,aAAa,CAC7D,QAAO,OAAO,KAAK,SAAS,YAAY,QAAQ,OAAO,MAAO,aAAa,CAAC;AAI9E,QAAO"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { basePartial, fn, injectPartial, optionalSwDestPartial } from "@serwist/build/schema";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region \0rolldown/runtime.js
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __exportAll = (all, no_symbols) => {
|
|
6
|
+
let target = {};
|
|
7
|
+
for (var name in all) __defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
11
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
12
|
+
return target;
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/lib/schema.ts
|
|
16
|
+
var schema_exports = /* @__PURE__ */ __exportAll({
|
|
17
|
+
injectManifestOptions: () => injectManifestOptions,
|
|
18
|
+
injectPartial: () => injectPartial$1,
|
|
19
|
+
webpackPartial: () => webpackPartial
|
|
20
|
+
});
|
|
21
|
+
const webpackConditionCallback = fn({
|
|
22
|
+
input: [z.any()],
|
|
23
|
+
output: z.boolean()
|
|
24
|
+
});
|
|
25
|
+
const webpackCondition = z.union([
|
|
26
|
+
z.string(),
|
|
27
|
+
z.instanceof(RegExp),
|
|
28
|
+
webpackConditionCallback
|
|
29
|
+
]);
|
|
30
|
+
const webpackPartial = z.strictObject({
|
|
31
|
+
chunks: z.array(z.string()).optional(),
|
|
32
|
+
exclude: z.array(webpackCondition).default([/\.map$/, /^manifest.*\.js$/]),
|
|
33
|
+
excludeChunks: z.array(z.string()).optional(),
|
|
34
|
+
include: z.array(webpackCondition).optional()
|
|
35
|
+
});
|
|
36
|
+
const injectPartial$1 = z.strictObject({
|
|
37
|
+
compileSrc: z.boolean().default(true),
|
|
38
|
+
swDest: z.string().optional(),
|
|
39
|
+
webpackCompilationPlugins: z.array(z.any()).optional()
|
|
40
|
+
});
|
|
41
|
+
const injectManifestOptions = z.strictObject({
|
|
42
|
+
...basePartial.shape,
|
|
43
|
+
...webpackPartial.shape,
|
|
44
|
+
...injectPartial.shape,
|
|
45
|
+
...optionalSwDestPartial.shape,
|
|
46
|
+
...injectPartial$1.shape
|
|
47
|
+
});
|
|
48
|
+
//#endregion
|
|
49
|
+
export { webpackPartial as i, injectPartial$1 as n, schema_exports as r, injectManifestOptions as t };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=schema-CpgCa1bB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-CpgCa1bB.js","names":["injectPartial","baseInjectPartial"],"sources":["../../src/lib/schema.ts"],"sourcesContent":["import { injectPartial as baseInjectPartial, basePartial, fn, optionalSwDestPartial } from \"@serwist/build/schema\";\nimport { z } from \"zod\";\n\nconst webpackConditionCallback = fn({\n input: [z.any()],\n output: z.boolean(),\n});\n\nconst webpackCondition = z.union([z.string(), z.instanceof(RegExp), webpackConditionCallback]);\n\nexport const webpackPartial = z.strictObject({\n chunks: z.array(z.string()).optional(),\n exclude: z.array(webpackCondition).default([/\\.map$/, /^manifest.*\\.js$/]),\n excludeChunks: z.array(z.string()).optional(),\n include: z.array(webpackCondition).optional(),\n});\n\nexport const injectPartial = z.strictObject({\n compileSrc: z.boolean().default(true),\n swDest: z.string().optional(),\n webpackCompilationPlugins: z.array(z.any()).optional(),\n});\n\nexport const injectManifestOptions = z.strictObject({\n ...basePartial.shape,\n ...webpackPartial.shape,\n ...baseInjectPartial.shape,\n ...optionalSwDestPartial.shape,\n ...injectPartial.shape,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAGA,MAAM,2BAA2B,GAAG;CAClC,OAAO,CAAC,EAAE,KAAK,CAAC;CAChB,QAAQ,EAAE,SAAS;CACpB,CAAC;AAEF,MAAM,mBAAmB,EAAE,MAAM;CAAC,EAAE,QAAQ;CAAE,EAAE,WAAW,OAAO;CAAE;CAAyB,CAAC;AAE9F,MAAa,iBAAiB,EAAE,aAAa;CAC3C,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;CACtC,SAAS,EAAE,MAAM,iBAAiB,CAAC,QAAQ,CAAC,UAAU,mBAAmB,CAAC;CAC1E,eAAe,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;CAC7C,SAAS,EAAE,MAAM,iBAAiB,CAAC,UAAU;CAC9C,CAAC;AAEF,MAAaA,kBAAgB,EAAE,aAAa;CAC1C,YAAY,EAAE,SAAS,CAAC,QAAQ,KAAK;CACrC,QAAQ,EAAE,QAAQ,CAAC,UAAU;CAC7B,2BAA2B,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,UAAU;CACvD,CAAC;AAEF,MAAa,wBAAwB,EAAE,aAAa;CAClD,GAAG,YAAY;CACf,GAAG,eAAe;CAClB,GAAGC,cAAkB;CACrB,GAAG,sBAAsB;CACzB,GAAGD,gBAAc;CAClB,CAAC"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { BasePartial, BaseResolved, InjectPartial, InjectResolved, OptionalSwDestPartial, OptionalSwDestResolved } from "@serwist/build";
|
|
2
|
+
import { Require } from "@serwist/utils";
|
|
3
|
+
import { Asset, Compilation, Compiler, WebpackPluginFunction, WebpackPluginInstance } from "webpack";
|
|
4
|
+
|
|
5
|
+
//#region src/lib/types.d.ts
|
|
6
|
+
interface ConditionCallbackOptions {
|
|
7
|
+
asset: Asset;
|
|
8
|
+
compilation: Compilation;
|
|
9
|
+
}
|
|
10
|
+
type ConditionCallback = (options: ConditionCallbackOptions) => boolean;
|
|
11
|
+
interface WebpackPartial {
|
|
12
|
+
/**
|
|
13
|
+
* One or more chunk names whose corresponding output files should be included
|
|
14
|
+
* in the precache manifest.
|
|
15
|
+
*/
|
|
16
|
+
chunks?: string[];
|
|
17
|
+
/**
|
|
18
|
+
* One or more specifiers used to exclude assets from the precache manifest.
|
|
19
|
+
* This is interpreted following
|
|
20
|
+
* [the same rules](https://webpack.js.org/configuration/module/#condition)
|
|
21
|
+
* as webpack's standard `exclude` option.
|
|
22
|
+
* @default
|
|
23
|
+
* ```
|
|
24
|
+
* [/\.map$/, /^manifest.*\.js$/]
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
exclude?: (string | RegExp | ConditionCallback)[];
|
|
28
|
+
/**
|
|
29
|
+
* One or more chunk names whose corresponding output files should be excluded
|
|
30
|
+
* from the precache manifest.
|
|
31
|
+
*/
|
|
32
|
+
excludeChunks?: string[];
|
|
33
|
+
/**
|
|
34
|
+
* One or more specifiers used to include assets in the precache manifest.
|
|
35
|
+
* This is interpreted following
|
|
36
|
+
* [the same rules](https://webpack.js.org/configuration/module/#condition)
|
|
37
|
+
* as webpack's standard `include` option.
|
|
38
|
+
*/
|
|
39
|
+
include?: (string | RegExp | ConditionCallback)[];
|
|
40
|
+
}
|
|
41
|
+
type WebpackResolved = Require<WebpackPartial, "exclude">;
|
|
42
|
+
interface InjectPartial$1 {
|
|
43
|
+
/**
|
|
44
|
+
* When `true` (the default), the `swSrc` file will be compiled by webpack.
|
|
45
|
+
* When `false`, compilation will not occur (and `webpackCompilationPlugins`
|
|
46
|
+
* can't be used.) Set to `false` if you want to inject the manifest into,
|
|
47
|
+
* e.g., a JSON file.
|
|
48
|
+
* @default true
|
|
49
|
+
*/
|
|
50
|
+
compileSrc?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Optional webpack plugins that will be used when compiling the `swSrc`
|
|
53
|
+
* file. Only valid if `compileSrc` is `true`.
|
|
54
|
+
*/
|
|
55
|
+
webpackCompilationPlugins?: WebpackPlugin[];
|
|
56
|
+
}
|
|
57
|
+
type InjectResolved$1 = Require<InjectPartial$1, "compileSrc">;
|
|
58
|
+
interface InjectManifestOptions extends BasePartial, WebpackPartial, InjectPartial, OptionalSwDestPartial, InjectPartial$1 {}
|
|
59
|
+
interface InjectManifestOptionsComplete extends BaseResolved, WebpackResolved, InjectResolved, OptionalSwDestResolved, InjectResolved$1 {}
|
|
60
|
+
type WebpackPlugin = WebpackPluginFunction | WebpackPluginInstance;
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/inject-manifest.d.ts
|
|
63
|
+
/**
|
|
64
|
+
* This class supports compiling a service worker file provided via `swSrc`,
|
|
65
|
+
* and injecting into that service worker a list of URLs and revision
|
|
66
|
+
* information for precaching based on the webpack asset pipeline.
|
|
67
|
+
*
|
|
68
|
+
* Use an instance of `InjectManifest` in the
|
|
69
|
+
* [`plugins` array](https://webpack.js.org/concepts/plugins/#usage) of a
|
|
70
|
+
* webpack config.
|
|
71
|
+
*
|
|
72
|
+
* In addition to injecting the manifest, this plugin will perform a compilation
|
|
73
|
+
* of the `swSrc` file, using the options from the main webpack configuration.
|
|
74
|
+
*
|
|
75
|
+
* ```
|
|
76
|
+
* // The following lists some common options; see the rest of the documentation
|
|
77
|
+
* // for the full set of options and defaults.
|
|
78
|
+
* new InjectManifest({
|
|
79
|
+
* exclude: [/.../, '...'],
|
|
80
|
+
* maximumFileSizeToCacheInBytes: ...,
|
|
81
|
+
* swSrc: '...',
|
|
82
|
+
* });
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
declare class InjectManifest {
|
|
86
|
+
protected config: InjectManifestOptionsComplete;
|
|
87
|
+
private alreadyCalled;
|
|
88
|
+
private webpack;
|
|
89
|
+
/**
|
|
90
|
+
* Creates an instance of InjectManifest.
|
|
91
|
+
*/
|
|
92
|
+
constructor(config: InjectManifestOptions);
|
|
93
|
+
/**
|
|
94
|
+
* @param compiler default compiler object passed from webpack
|
|
95
|
+
*
|
|
96
|
+
* @private
|
|
97
|
+
*/
|
|
98
|
+
private propagateWebpackConfig;
|
|
99
|
+
/**
|
|
100
|
+
* `getManifestEntriesFromCompilation` with a few additional checks.
|
|
101
|
+
*
|
|
102
|
+
* @private
|
|
103
|
+
*/
|
|
104
|
+
private getManifestEntries;
|
|
105
|
+
/**
|
|
106
|
+
* @param compiler default compiler object passed from webpack
|
|
107
|
+
*
|
|
108
|
+
* @private
|
|
109
|
+
*/
|
|
110
|
+
apply(compiler: Compiler): void;
|
|
111
|
+
/**
|
|
112
|
+
* @param compiler The webpack parent compiler.
|
|
113
|
+
* @param compilation The webpack compilation.
|
|
114
|
+
*
|
|
115
|
+
* @private
|
|
116
|
+
*/
|
|
117
|
+
private addSrcToAssets;
|
|
118
|
+
/**
|
|
119
|
+
* @param compiler The webpack parent compiler.
|
|
120
|
+
* @param compilation The webpack compilation.
|
|
121
|
+
*
|
|
122
|
+
* @private
|
|
123
|
+
*/
|
|
124
|
+
private handleMake;
|
|
125
|
+
/**
|
|
126
|
+
* @param compilation The webpack compilation.
|
|
127
|
+
*
|
|
128
|
+
* @private
|
|
129
|
+
*/
|
|
130
|
+
private addAssets;
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/lib/validator.d.ts
|
|
134
|
+
declare const validateInjectManifestOptions: (input: unknown) => Promise<InjectManifestOptionsComplete>;
|
|
135
|
+
//#endregion
|
|
136
|
+
export { InjectManifest, type InjectManifestOptions, type InjectManifestOptionsComplete, type WebpackPartial, type WebpackResolved, validateInjectManifestOptions };
|
|
137
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/lib/types.ts","../src/inject-manifest.ts","../src/lib/validator.ts"],"mappings":";;;;;UAWiB,wBAAA;EACf,KAAA,EAAO,KAAA;EACP,WAAA,EAAa,WAAA;AAAA;AAAA,KAGH,iBAAA,IAAqB,OAAA,EAAS,wBAAA;AAAA,UAEzB,cAAA;EANf;;;;EAWA,MAAA;EAVwB;AAG1B;;;;;AAEA;;;;EAgBE,OAAA,aAAoB,MAAA,GAAS,iBAAA;EAYT;;;;EAPpB,aAAA;EALA;;;;;;EAYA,OAAA,aAAoB,MAAA,GAAS,iBAAA;AAAA;AAAA,KAGnB,eAAA,GAAkB,OAAA,CAAQ,cAAA;AAAA,UAErB,eAAA;EAFU;;;;AAE3B;;;EAQE,UAAA;EAAA;;;;EAQA,yBAAA,GAA4B,aAAA;AAAA;AAAA,KAGlB,gBAAA,GAAiB,OAAA,CAAQ,eAAA;AAAA,UAEpB,qBAAA,SAA8B,WAAA,EAAa,cAAA,EAAgB,aAAA,EAAmB,qBAAA,EAAuB,eAAA;AAAA,UAErG,6BAAA,SAAsC,YAAA,EAAc,eAAA,EAAiB,cAAA,EAAoB,sBAAA,EAAwB,gBAAA;AAAA,KAEtH,aAAA,GAAgB,qBAAA,GAAwB,qBAAA;;;;;;AAjEpD;;;;;;;;;;AAKA;;;;;AAEA;;;;cCoBa,cAAA;EAAA,UACD,MAAA,EAAQ,6BAAA;EAAA,QACV,aAAA;EAAA,QACA,OAAA;EDKsC;;;cCAlC,MAAA,EAAQ,qBAAA;EDZS;;;;;EAAA,QCyBrB,sBAAA;EDbsC;AAGhD;;;;EAHgD,QC+BhC,kBAAA;ED1BC;;;;;ECsEf,KAAA,CAAM,QAAA,EAAU,QAAA;EDtDY;;;AAG9B;;;EAH8B,QCyFpB,cAAA;EDtFwC;AAElD;;;;;EAFkD,QCiGlC,UAAA;ED/F+E;;;;;EAAA,QC4H/E,SAAA;AAAA;;;cCjMH,6BAAA,GAAuC,KAAA,cAAiB,OAAA,CAAQ,6BAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Compilation, Compiler, WebpackPluginInstance } from "webpack";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/child-compilation-plugin.d.ts
|
|
4
|
+
interface ChildCompilationPluginOptions {
|
|
5
|
+
src: string;
|
|
6
|
+
dest: string;
|
|
7
|
+
plugins?: WebpackPluginInstance[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Compile a file by creating a child of the hooked compiler.
|
|
11
|
+
*
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
declare class ChildCompilationPlugin implements WebpackPluginInstance {
|
|
15
|
+
src: string;
|
|
16
|
+
dest: string;
|
|
17
|
+
plugins: WebpackPluginInstance[] | undefined;
|
|
18
|
+
constructor({
|
|
19
|
+
src,
|
|
20
|
+
dest,
|
|
21
|
+
plugins
|
|
22
|
+
}: ChildCompilationPluginOptions);
|
|
23
|
+
/**
|
|
24
|
+
* @param compiler default compiler object passed from webpack
|
|
25
|
+
*
|
|
26
|
+
* @private
|
|
27
|
+
*/
|
|
28
|
+
apply(compiler: Compiler): void;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/lib/relative-to-output-path.d.ts
|
|
32
|
+
/**
|
|
33
|
+
* @param compilation The webpack compilation.
|
|
34
|
+
* @param originalPath The original path value.
|
|
35
|
+
*
|
|
36
|
+
* @returns If path was not absolute, the returns path as-is.
|
|
37
|
+
* Otherwise, returns path relative to the compilation's output path.
|
|
38
|
+
*
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
declare const relativeToOutputPath: (compilation: Compilation, originalPath: string) => string;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { ChildCompilationPlugin, relativeToOutputPath };
|
|
44
|
+
//# sourceMappingURL=index.internal.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.internal.d.mts","names":[],"sources":["../src/lib/child-compilation-plugin.ts","../src/lib/relative-to-output-path.ts"],"mappings":";;;UAIiB,6BAAA;EACf,GAAA;EACA,IAAA;EACA,OAAA,GAAU,qBAAA;AAAA;;;;;;cAQC,sBAAA,YAAkC,qBAAA;EAC7C,GAAA;EACA,IAAA;EACA,OAAA,EAAS,qBAAA;;IACK,GAAA;IAAK,IAAA;IAAM;EAAA,GAAW,6BAAA;EAD3B;;;;;EAWT,KAAA,CAAM,QAAA,EAAU,QAAA;AAAA;;;;;AAzBlB;;;;;;;cCiBa,oBAAA,GAAwB,WAAA,EAAa,WAAA,EAAa,YAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { n as performChildCompilation, t as relativeToOutputPath } from "./chunks/relative-to-output-path-Gvhd54pA.js";
|
|
2
|
+
//#region src/lib/child-compilation-plugin.ts
|
|
3
|
+
/**
|
|
4
|
+
* Compile a file by creating a child of the hooked compiler.
|
|
5
|
+
*
|
|
6
|
+
* @private
|
|
7
|
+
*/
|
|
8
|
+
var ChildCompilationPlugin = class {
|
|
9
|
+
src;
|
|
10
|
+
dest;
|
|
11
|
+
plugins;
|
|
12
|
+
constructor({ src, dest, plugins }) {
|
|
13
|
+
this.src = src;
|
|
14
|
+
this.dest = dest;
|
|
15
|
+
this.plugins = plugins;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @param compiler default compiler object passed from webpack
|
|
19
|
+
*
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
apply(compiler) {
|
|
23
|
+
compiler.hooks.make.tapPromise(this.constructor.name, (compilation) => performChildCompilation(compiler, compilation, this.constructor.name, this.src, relativeToOutputPath(compilation, this.dest), this.plugins).catch((error) => {
|
|
24
|
+
compilation.errors.push(error);
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { ChildCompilationPlugin, relativeToOutputPath };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=index.internal.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.internal.mjs","names":[],"sources":["../src/lib/child-compilation-plugin.ts"],"sourcesContent":["import type { Compiler, WebpackError, WebpackPluginInstance } from \"webpack\";\nimport { performChildCompilation } from \"./perform-child-compilation.js\";\nimport { relativeToOutputPath } from \"./relative-to-output-path.js\";\n\nexport interface ChildCompilationPluginOptions {\n src: string;\n dest: string;\n plugins?: WebpackPluginInstance[];\n}\n\n/**\n * Compile a file by creating a child of the hooked compiler.\n *\n * @private\n */\nexport class ChildCompilationPlugin implements WebpackPluginInstance {\n src: string;\n dest: string;\n plugins: WebpackPluginInstance[] | undefined;\n constructor({ src, dest, plugins }: ChildCompilationPluginOptions) {\n this.src = src;\n this.dest = dest;\n this.plugins = plugins;\n }\n /**\n * @param compiler default compiler object passed from webpack\n *\n * @private\n */\n apply(compiler: Compiler) {\n compiler.hooks.make.tapPromise(this.constructor.name, (compilation) =>\n performChildCompilation(\n compiler,\n compilation,\n this.constructor.name,\n this.src,\n relativeToOutputPath(compilation, this.dest),\n this.plugins,\n ).catch((error: WebpackError) => {\n compilation.errors.push(error);\n }),\n );\n }\n}\n"],"mappings":";;;;;;;AAeA,IAAa,yBAAb,MAAqE;CACnE;CACA;CACA;CACA,YAAY,EAAE,KAAK,MAAM,WAA0C;AACjE,OAAK,MAAM;AACX,OAAK,OAAO;AACZ,OAAK,UAAU;;;;;;;CAOjB,MAAM,UAAoB;AACxB,WAAS,MAAM,KAAK,WAAW,KAAK,YAAY,OAAO,gBACrD,wBACE,UACA,aACA,KAAK,YAAY,MACjB,KAAK,KACL,qBAAqB,aAAa,KAAK,KAAK,EAC5C,KAAK,QACN,CAAC,OAAO,UAAwB;AAC/B,eAAY,OAAO,KAAK,MAAM;IAC9B,CACH"}
|