@plaudit/webpack-extensions 2.64.0 → 2.65.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.
- package/build/plugins/{AbstractMultiPhaseLibraryAndEntryPlugin.d.ts → AbstractBiPhasicGroupAndEntryPlugin.d.ts} +7 -6
- package/build/plugins/AbstractBiPhasicGroupAndEntryPlugin.js +85 -0
- package/build/plugins/AbstractBiPhasicGroupPlugin.d.ts +33 -0
- package/build/plugins/AbstractBiPhasicGroupPlugin.js +93 -0
- package/build/plugins/AdditionalDependencyInjectorPlugin.d.ts +2 -2
- package/build/plugins/EnhancedDynamicEntryPlugin.d.ts +3 -3
- package/build/plugins/EnhancedDynamicEntryPlugin.js +3 -3
- package/build/plugins/ExtensionsConfigFileGeneratorPlugin.d.ts +9 -8
- package/build/plugins/ExtensionsConfigFileGeneratorPlugin.js +103 -93
- package/build/plugins/ExtensionsConfigFileGeneratorPluginV1.d.ts +6 -7
- package/build/plugins/ExtensionsConfigFileGeneratorPluginV1.js +10 -17
- package/build/plugins/PlainEntrypointsConfigFileGeneratorPlugin.d.ts +6 -7
- package/build/plugins/PlainEntrypointsConfigFileGeneratorPlugin.js +15 -16
- package/build/plugins/PlainEntrypointsStyleBlockJSONPlugin.d.ts +5 -5
- package/build/plugins/PlainEntrypointsStyleBlockJSONPlugin.js +7 -6
- package/build/plugins/SpecialAssetHandlingPlugin.d.ts +5 -5
- package/build/plugins/SpecialAssetHandlingPlugin.js +44 -47
- package/build/plugins/UnifiedLoaderGenerator.d.ts +8 -8
- package/build/plugins/UnifiedLoaderGenerator.js +54 -69
- package/build/plugins/WPMLConfigBuilder.d.ts +2 -2
- package/build/shared.d.ts +4 -3
- package/build/shared.js +19 -3
- package/build/utils/common-config-helpers.d.ts +3 -3
- package/build/utils/common-config-helpers.js +2 -2
- package/build/utils/json-to-php-but-with-__-injection.js +1 -1
- package/build/utils/pseduo-semaphore.d.ts +2 -3
- package/build/utils/pseduo-semaphore.js +9 -5
- package/build/wordpress-scripts-wrapper.js +13 -7
- package/package.json +1 -1
- package/build/plugins/AbstractMultiPhaseLibraryAndEntryPlugin.js +0 -113
- package/build/plugins/AbstractMultiPhaseLibraryPlugin.d.ts +0 -17
- package/build/plugins/AbstractMultiPhaseLibraryPlugin.js +0 -44
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AbstractBiPhasicGroupAndEntryPlugin, EntryProvider } from "../plugins/AbstractBiPhasicGroupAndEntryPlugin";
|
|
2
2
|
import type { AdditionalDependencyInjectorPlugin } from "../plugins/AdditionalDependencyInjectorPlugin";
|
|
3
3
|
import { EntrypointFields, PlauditWordpressWebpackConfig, UnpackedBlockEntrypointInfo, VerifiedAdvancedOutputConfig } from "../shared";
|
|
4
4
|
import type { Compiler, Configuration, DynamicEntryPlugin, WebpackPluginInstance } from "webpack";
|
|
@@ -10,7 +10,7 @@ export type VerifiedPlauditWordpressWebpackConfig = Required<Omit<PlauditWordpre
|
|
|
10
10
|
export type CommonPluginConfig = {
|
|
11
11
|
plugins: (WebpackPluginInstance | ((this: Compiler, compiler: Compiler) => void))[];
|
|
12
12
|
removeEmptyScriptsPlugin: WebpackRemoveEmptyScriptsPlugin;
|
|
13
|
-
makeAdditionalDependencyInjectorPlugin(referencePlugin:
|
|
13
|
+
makeAdditionalDependencyInjectorPlugin(referencePlugin: AbstractBiPhasicGroupAndEntryPlugin<any>): AdditionalDependencyInjectorPlugin;
|
|
14
14
|
};
|
|
15
15
|
export type CommonConfigProcessingResult = {
|
|
16
16
|
entrypointFields: EntrypointFields;
|
|
@@ -29,4 +29,4 @@ export type ExtensibleEntryObject<M> = {
|
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
31
|
export declare function resolveEntryFromDirectory(commonConfig: CommonConfigProcessingResult, srcRoot: string, dest: VerifiedAdvancedOutputConfig): EntryProvider<UnpackedBlockEntrypointInfo | string>;
|
|
32
|
-
export declare function commonMakeWebpackConfig(config: VerifiedPlauditWordpressWebpackConfig, commonConfig: CommonConfigProcessingResult, webpackConfig: Configuration, externalize: VerifiedAdvancedOutputConfig['externalize'], plugins: CommonPluginConfig['plugins']): Configuration;
|
|
32
|
+
export declare function commonMakeWebpackConfig(config: VerifiedPlauditWordpressWebpackConfig, commonConfig: CommonConfigProcessingResult, webpackConfig: Configuration, externalize: VerifiedAdvancedOutputConfig['externalize'], plugins: CommonPluginConfig['plugins'], canClean: boolean): Configuration;
|
|
@@ -263,7 +263,7 @@ function resolveEntryFromDirectory(commonConfig, srcRoot, dest) {
|
|
|
263
263
|
return currentEntry;
|
|
264
264
|
};
|
|
265
265
|
}
|
|
266
|
-
function commonMakeWebpackConfig(config, commonConfig, webpackConfig, externalize, plugins) {
|
|
266
|
+
function commonMakeWebpackConfig(config, commonConfig, webpackConfig, externalize, plugins, canClean) {
|
|
267
267
|
const { variablesFilePath } = config;
|
|
268
268
|
const { fixedRules, processingModules, updateCurrentVariables } = commonConfig;
|
|
269
269
|
const outPath = joinPossiblyAbsolutePaths(process.cwd(), config.outputDir);
|
|
@@ -327,7 +327,7 @@ function commonMakeWebpackConfig(config, commonConfig, webpackConfig, externaliz
|
|
|
327
327
|
chunkFilename: 'webpack-chunks/[id].js',
|
|
328
328
|
publicPath: publicPath,
|
|
329
329
|
library: outputLibrary,
|
|
330
|
-
clean: false
|
|
330
|
+
clean: canClean ? webpackConfig.output?.clean : false
|
|
331
331
|
},
|
|
332
332
|
optimization: {
|
|
333
333
|
...webpackConfig.optimization,
|
|
@@ -5,7 +5,7 @@ const make = (props = {}) => {
|
|
|
5
5
|
const linebreak = props.linebreak ?? '';
|
|
6
6
|
const indent = props.indent ?? '';
|
|
7
7
|
const stripSpaces = props.stripSpaces ?? false;
|
|
8
|
-
const shortArraySyntax = props.shortArraySyntax ??
|
|
8
|
+
const shortArraySyntax = props.shortArraySyntax ?? true;
|
|
9
9
|
const arrOpen = shortArraySyntax ? '[' : 'array(';
|
|
10
10
|
const arrClose = shortArraySyntax ? ']' : ')';
|
|
11
11
|
const arrow = stripSpaces ? '=>' : ' => ';
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
export declare class PseudoSemaphore<T> {
|
|
2
|
-
private readonly defaultValue;
|
|
3
2
|
private readonly name;
|
|
4
3
|
private flagSet;
|
|
5
4
|
private readonly flags;
|
|
6
5
|
private readonly debugMode;
|
|
7
|
-
constructor(
|
|
6
|
+
constructor(name: string);
|
|
8
7
|
register(id: string): void;
|
|
9
|
-
resolve(id: string, value: T): void;
|
|
8
|
+
resolve(id: string, value: T | undefined): void;
|
|
10
9
|
reject(id: string): void;
|
|
11
10
|
reset(id: string): void;
|
|
12
11
|
private getFlag;
|
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PseudoSemaphore = void 0;
|
|
4
4
|
class PseudoSemaphore {
|
|
5
|
-
defaultValue;
|
|
6
5
|
name;
|
|
7
6
|
flagSet = 0;
|
|
8
7
|
flags = new Map();
|
|
9
8
|
debugMode = false;
|
|
10
|
-
constructor(
|
|
11
|
-
this.defaultValue = defaultValue;
|
|
9
|
+
constructor(name) {
|
|
12
10
|
this.name = name;
|
|
13
11
|
}
|
|
14
12
|
register(id) {
|
|
@@ -16,7 +14,7 @@ class PseudoSemaphore {
|
|
|
16
14
|
throw new Error();
|
|
17
15
|
}
|
|
18
16
|
this.initializeFlag(id);
|
|
19
|
-
this.resolve(id,
|
|
17
|
+
this.resolve(id, undefined);
|
|
20
18
|
}
|
|
21
19
|
resolve(id, value) {
|
|
22
20
|
if (this.debugMode) {
|
|
@@ -67,7 +65,13 @@ class PseudoSemaphore {
|
|
|
67
65
|
let res;
|
|
68
66
|
do {
|
|
69
67
|
currentFlagSet = this.flagSet;
|
|
70
|
-
|
|
68
|
+
if (this.debugMode) {
|
|
69
|
+
console.log("WAITING FOR:", this.name, currentFlagSet);
|
|
70
|
+
}
|
|
71
|
+
res = (await Promise.all(this.flags.values().map(flag => flag[0]))).filter(r => r !== undefined);
|
|
72
|
+
if (this.debugMode) {
|
|
73
|
+
console.log("POSSIBLY FINISHED WAITING FOR:", this.name, currentFlagSet);
|
|
74
|
+
}
|
|
71
75
|
} while (currentFlagSet !== this.flagSet);
|
|
72
76
|
return res;
|
|
73
77
|
}
|
|
@@ -388,7 +388,9 @@ function buildCommonPluginConfig(webpackConfig, config, bundleAnalyzer, assumeGl
|
|
|
388
388
|
ignore: /block\.json/
|
|
389
389
|
});
|
|
390
390
|
plugins.push(removeEmptyScriptsPlugin, new MiniCSSExtractPluginErrorCleaner_1.MiniCSSExtractPluginErrorCleaner());
|
|
391
|
-
|
|
391
|
+
if (config.useWebpackResourceFiltering) {
|
|
392
|
+
plugins.push(new SpecialAssetHandlingPlugin_1.SpecialAssetHandlingPlugin(config));
|
|
393
|
+
}
|
|
392
394
|
plugins.push(new VariablesJSMonitorPlugin_1.VariablesJSMonitorPlugin(config));
|
|
393
395
|
const dependencyExtractionPluginIndex = plugins.findIndex(plugin => plugin instanceof dependency_extraction_webpack_plugin_1.default);
|
|
394
396
|
if (dependencyExtractionPluginIndex === -1) {
|
|
@@ -446,7 +448,7 @@ function destToKey(dest) {
|
|
|
446
448
|
: dest.externalize?.toString() ?? "undefined";
|
|
447
449
|
return [dest.additionalDependencies.join("_"), dest.assumeGlobalizedPlauditLibraries, dest.bundleAnalyzer, externalize, dest.withLegacyBlocksIn].join("~");
|
|
448
450
|
}
|
|
449
|
-
function processIndividualWebpackConfig(config, webpackConfig, sources) {
|
|
451
|
+
function processIndividualWebpackConfig(config, webpackConfig, sources, canClean) {
|
|
450
452
|
const commonConfig = commonConfigProcessingPrep(config, webpackConfig);
|
|
451
453
|
const { processingModules, scriptExtension } = commonConfig;
|
|
452
454
|
const allSrcRoots = sources.map(([src, dest]) => {
|
|
@@ -465,7 +467,8 @@ function processIndividualWebpackConfig(config, webpackConfig, sources) {
|
|
|
465
467
|
const key = destToKey(entry.dest);
|
|
466
468
|
(groupedSrcRoots[key] ?? (groupedSrcRoots[key] = [])).push(entry);
|
|
467
469
|
}
|
|
468
|
-
|
|
470
|
+
const batches = Object.values(groupedSrcRoots).filter(shared_1.hasAtLeastOneItem);
|
|
471
|
+
return batches.map(currentBatch => {
|
|
469
472
|
const { bundleAnalyzer, assumeGlobalizedPlauditLibraries, externalize, additionalDependencies } = currentBatch[0].dest;
|
|
470
473
|
const { plugins, removeEmptyScriptsPlugin, makeAdditionalDependencyInjectorPlugin } = buildCommonPluginConfig(webpackConfig, config, bundleAnalyzer, assumeGlobalizedPlauditLibraries, externalize, additionalDependencies);
|
|
471
474
|
handleDisablingTSCheckerIfNecessary(currentBatch.flatMap(a => a.srcRoots), scriptExtension, plugins);
|
|
@@ -515,7 +518,7 @@ function processIndividualWebpackConfig(config, webpackConfig, sources) {
|
|
|
515
518
|
const entry = srcIsDirectory // This being true implies that srcRoot is not an array
|
|
516
519
|
? (0, common_config_helpers_1.resolveEntryFromDirectory)(commonConfig, srcRoot, dest)
|
|
517
520
|
: () => ({ [baseDest]: { import: Array.isArray(srcRoot) ? srcRoot : [srcRoot], plauditMetadata: "plain-entrypoint" } });
|
|
518
|
-
plugin = new PlainEntrypointsConfigFileGeneratorPlugin_1.PlainEntrypointsConfigFileGeneratorPlugin(config, process.cwd(), config.outputDir, dest.locations, config.
|
|
521
|
+
plugin = new PlainEntrypointsConfigFileGeneratorPlugin_1.PlainEntrypointsConfigFileGeneratorPlugin(config, process.cwd(), config.outputDir, dest.locations, config.useUnifiedLoader, webpackConfig.context ?? process.cwd(), entry);
|
|
519
522
|
}
|
|
520
523
|
else {
|
|
521
524
|
if (srcIsDirectory) {
|
|
@@ -543,7 +546,7 @@ function processIndividualWebpackConfig(config, webpackConfig, sources) {
|
|
|
543
546
|
}
|
|
544
547
|
}
|
|
545
548
|
plugins.push(new UnifiedLoaderGenerator_1.UnifiedLoaderGenerator(config));
|
|
546
|
-
return (0, common_config_helpers_1.commonMakeWebpackConfig)(config, commonConfig, webpackConfig, externalize, plugins);
|
|
549
|
+
return (0, common_config_helpers_1.commonMakeWebpackConfig)(config, commonConfig, webpackConfig, externalize, plugins, canClean && batches.length < 2);
|
|
547
550
|
}).filter(cfg => cfg !== undefined);
|
|
548
551
|
}
|
|
549
552
|
function stripExtension(filepath) {
|
|
@@ -551,13 +554,16 @@ function stripExtension(filepath) {
|
|
|
551
554
|
}
|
|
552
555
|
module.exports = function (config, webpackConfig = require("@wordpress/scripts/config/webpack.config")) {
|
|
553
556
|
const { cfg, sources } = buildVerifiedConfig(config);
|
|
557
|
+
if (Array.isArray(webpackConfig) && (0, shared_1.hasAtLeastOneItem)(webpackConfig)) {
|
|
558
|
+
webpackConfig = webpackConfig[0];
|
|
559
|
+
}
|
|
554
560
|
if (Array.isArray(webpackConfig)) {
|
|
555
561
|
return webpackConfig.toSorted((a, b) => {
|
|
556
562
|
if (a.output?.module) {
|
|
557
563
|
return b.output?.module ? 0 : -1;
|
|
558
564
|
}
|
|
559
565
|
return b.output?.module ? 1 : 0;
|
|
560
|
-
}).flatMap(wpCfg => processIndividualWebpackConfig(cfg, wpCfg, sources));
|
|
566
|
+
}).flatMap(wpCfg => processIndividualWebpackConfig(cfg, wpCfg, sources, false));
|
|
561
567
|
}
|
|
562
|
-
return processIndividualWebpackConfig(cfg, webpackConfig, sources);
|
|
568
|
+
return processIndividualWebpackConfig(cfg, webpackConfig, sources, true);
|
|
563
569
|
};
|
package/package.json
CHANGED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AbstractMultiPhaseLibraryAndEntryPlugin = void 0;
|
|
4
|
-
const shared_1 = require("../shared");
|
|
5
|
-
const AbstractMultiPhaseLibraryPlugin_1 = require("./AbstractMultiPhaseLibraryPlugin");
|
|
6
|
-
const webpack_1 = require("webpack");
|
|
7
|
-
class AbstractMultiPhaseLibraryAndEntryPlugin extends AbstractMultiPhaseLibraryPlugin_1.AbstractMultiPhaseLibraryPlugin {
|
|
8
|
-
context;
|
|
9
|
-
entry;
|
|
10
|
-
static configuredCompilations = new WeakSet();
|
|
11
|
-
entryMetadataRecord = {};
|
|
12
|
-
constructor(config, libraryType, semaphores, context, entry) {
|
|
13
|
-
super(config, libraryType, semaphores);
|
|
14
|
-
this.context = context;
|
|
15
|
-
this.entry = entry;
|
|
16
|
-
}
|
|
17
|
-
apply(compiler) {
|
|
18
|
-
super.apply(compiler);
|
|
19
|
-
compiler.hooks.compilation.tap(this.constructor.name, (compilation, { normalModuleFactory }) => {
|
|
20
|
-
if (AbstractMultiPhaseLibraryAndEntryPlugin.configuredCompilations.has(compilation)) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
AbstractMultiPhaseLibraryAndEntryPlugin.configuredCompilations.add(compilation);
|
|
24
|
-
const dummyEntry = webpack_1.EntryPlugin.createDependency("", "");
|
|
25
|
-
compilation.dependencyFactories.set(dummyEntry.constructor, normalModuleFactory);
|
|
26
|
-
});
|
|
27
|
-
compiler.hooks.make.tapPromise(this.constructor.name, async (compilation) => {
|
|
28
|
-
const entry = await this.entry();
|
|
29
|
-
const promises = [];
|
|
30
|
-
for (const [name, { plauditMetadata, ...desc }] of Object.entries(entry)) {
|
|
31
|
-
const options = webpack_1.EntryOptionPlugin.entryDescriptionToOptions(compiler, name, desc);
|
|
32
|
-
this.entryMetadataRecord[name] = plauditMetadata;
|
|
33
|
-
for (const entry of desc.import) {
|
|
34
|
-
promises.push(new Promise((resolve, reject) => {
|
|
35
|
-
compilation.addEntry(this.context, webpack_1.EntryPlugin.createDependency(entry, options), options, err => {
|
|
36
|
-
if (err) {
|
|
37
|
-
return reject(err);
|
|
38
|
-
}
|
|
39
|
-
resolve();
|
|
40
|
-
});
|
|
41
|
-
}));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
await Promise.all(promises);
|
|
45
|
-
});
|
|
46
|
-
compiler.hooks.compilation.tap(this.constructor.name, compilation => {
|
|
47
|
-
compilation.hooks.processAssets.tapPromise({ name: this.constructor.name, stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_ANALYSE, additionalAssets: true }, async (assets) => {
|
|
48
|
-
if (!("assets.json" in assets)) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
try {
|
|
52
|
-
//TODO: It should be possible to use EntryPoints to determine the "original" file
|
|
53
|
-
//TODO: There is no reason to not use basically the exact same logic to implement support for this in plain file contexts
|
|
54
|
-
const rawAssetDataSource = assets["assets.json"]?.source();
|
|
55
|
-
if (typeof rawAssetDataSource !== 'string') {
|
|
56
|
-
this.rejectSemaphores();
|
|
57
|
-
compilation.errors.push(new Error("assets.json is unexpectedly missing or not a string"));
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
const rawAssetData = JSON.parse(rawAssetDataSource);
|
|
61
|
-
if (!(0, shared_1.isRawAssetData)(rawAssetData)) {
|
|
62
|
-
this.rejectSemaphores();
|
|
63
|
-
compilation.errors.push(new Error("assets.json is does not match the RawAssetData format"));
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
await this.processAssets(compilation, rawAssetData);
|
|
67
|
-
}
|
|
68
|
-
catch (e) {
|
|
69
|
-
this.rejectSemaphores();
|
|
70
|
-
if (e instanceof Error) {
|
|
71
|
-
compilation.errors.push(e);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
throw e;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
getRelevantEntrypoints(compilation) {
|
|
80
|
-
return compilation.entrypoints.values()
|
|
81
|
-
.map(entrypoint => {
|
|
82
|
-
const name = entrypoint.name;
|
|
83
|
-
if (!name) {
|
|
84
|
-
return undefined;
|
|
85
|
-
}
|
|
86
|
-
const metadata = this.entryMetadataRecord[name];
|
|
87
|
-
if (metadata === undefined) {
|
|
88
|
-
return undefined;
|
|
89
|
-
}
|
|
90
|
-
const srcPath = entrypoint.origins[0]?.request;
|
|
91
|
-
if (!srcPath) {
|
|
92
|
-
return undefined;
|
|
93
|
-
}
|
|
94
|
-
return { entrypoint, srcPath, metadata };
|
|
95
|
-
})
|
|
96
|
-
.filter(item => item !== undefined)
|
|
97
|
-
.toArray();
|
|
98
|
-
}
|
|
99
|
-
extractRelevantAssetData(compilation, rawAssetData) {
|
|
100
|
-
const relevantAssetData = {};
|
|
101
|
-
const relevantEntrypoints = this.getRelevantEntrypoints(compilation);
|
|
102
|
-
for (const { entrypoint, srcPath } of relevantEntrypoints) {
|
|
103
|
-
const fileWithAssetData = entrypoint.getEntrypointChunk().files.values().find(file => rawAssetData[file]);
|
|
104
|
-
if (!fileWithAssetData) {
|
|
105
|
-
compilation.errors.push((0, shared_1.newWebpackErrorForFile)(`assets.json did not contain information for ${srcPath}`, srcPath));
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
relevantAssetData[fileWithAssetData] = rawAssetData[fileWithAssetData];
|
|
109
|
-
}
|
|
110
|
-
return relevantAssetData;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
exports.AbstractMultiPhaseLibraryAndEntryPlugin = AbstractMultiPhaseLibraryAndEntryPlugin;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Compilation, Compiler, type WebpackPluginInstance } from "webpack";
|
|
2
|
-
import { PseudoSemaphore } from "../utils/pseduo-semaphore";
|
|
3
|
-
import type { VerifiedPlauditWordpressWebpackConfig } from "../utils/common-config-helpers";
|
|
4
|
-
export declare abstract class AbstractMultiPhaseLibraryPlugin implements WebpackPluginInstance {
|
|
5
|
-
protected readonly config: VerifiedPlauditWordpressWebpackConfig;
|
|
6
|
-
readonly libraryType: string;
|
|
7
|
-
private readonly semaphores;
|
|
8
|
-
protected static readonly phaseTwoAttached: {
|
|
9
|
-
[key in string]: any;
|
|
10
|
-
};
|
|
11
|
-
protected readonly id: string;
|
|
12
|
-
protected constructor(config: VerifiedPlauditWordpressWebpackConfig, libraryType: string, semaphores: PseudoSemaphore<any>[]);
|
|
13
|
-
apply(compiler: Compiler): void;
|
|
14
|
-
protected resetSemaphores(): void;
|
|
15
|
-
protected rejectSemaphores(): void;
|
|
16
|
-
protected abstract attachSecondPhase(compilation: Compilation): void;
|
|
17
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AbstractMultiPhaseLibraryPlugin = void 0;
|
|
4
|
-
const webpack_1 = require("webpack");
|
|
5
|
-
class AbstractMultiPhaseLibraryPlugin {
|
|
6
|
-
config;
|
|
7
|
-
libraryType;
|
|
8
|
-
semaphores;
|
|
9
|
-
static phaseTwoAttached = {};
|
|
10
|
-
id;
|
|
11
|
-
constructor(config, libraryType, semaphores) {
|
|
12
|
-
this.config = config;
|
|
13
|
-
this.libraryType = libraryType;
|
|
14
|
-
this.semaphores = semaphores;
|
|
15
|
-
this.id = Math.random().toString();
|
|
16
|
-
}
|
|
17
|
-
apply(compiler) {
|
|
18
|
-
webpack_1.library.EnableLibraryPlugin.setEnabled(compiler, this.libraryType);
|
|
19
|
-
for (const semaphore of this.semaphores) {
|
|
20
|
-
semaphore.register(this.id);
|
|
21
|
-
}
|
|
22
|
-
compiler.hooks.compilation.tap(this.constructor.name, compilation => {
|
|
23
|
-
AbstractMultiPhaseLibraryPlugin.phaseTwoAttached[this.libraryType] = false;
|
|
24
|
-
this.resetSemaphores();
|
|
25
|
-
compilation.hooks.beforeChunkIds.tap(this.constructor.name, () => {
|
|
26
|
-
if (!AbstractMultiPhaseLibraryPlugin.phaseTwoAttached[this.libraryType]) {
|
|
27
|
-
AbstractMultiPhaseLibraryPlugin.phaseTwoAttached[this.libraryType] = this;
|
|
28
|
-
this.attachSecondPhase(compilation);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
resetSemaphores() {
|
|
34
|
-
for (const semaphore of this.semaphores) {
|
|
35
|
-
semaphore.reset(this.id);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
rejectSemaphores() {
|
|
39
|
-
for (const semaphore of this.semaphores) {
|
|
40
|
-
semaphore.reject(this.id);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.AbstractMultiPhaseLibraryPlugin = AbstractMultiPhaseLibraryPlugin;
|