@plaudit/webpack-extensions 2.64.0 → 2.65.1
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/AbstractBiPhasicGroupAndEntryPlugin.d.ts +33 -0
- package/build/plugins/AbstractBiPhasicGroupAndEntryPlugin.js +86 -0
- package/build/plugins/AbstractBiPhasicGroupPlugin.d.ts +33 -0
- package/build/plugins/AbstractBiPhasicGroupPlugin.js +93 -0
- package/build/plugins/AdditionalDependencyInjectorPlugin.d.ts +8 -6
- package/build/plugins/AdditionalDependencyInjectorPlugin.js +37 -39
- package/build/plugins/EnhancedDynamicEntryPlugin.d.ts +4 -5
- 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 +7 -8
- 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 +6 -6
- package/build/plugins/PlainEntrypointsStyleBlockJSONPlugin.js +10 -9
- 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 +10 -14
- package/build/shared.js +19 -23
- package/build/utils/common-config-helpers.d.ts +6 -6
- package/build/utils/common-config-helpers.js +11 -8
- 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 +21 -15
- package/package.json +3 -3
- package/build/plugins/AbstractMultiPhaseLibraryAndEntryPlugin.d.ts +0 -21
- package/build/plugins/AbstractMultiPhaseLibraryAndEntryPlugin.js +0 -113
- package/build/plugins/AbstractMultiPhaseLibraryPlugin.d.ts +0 -17
- package/build/plugins/AbstractMultiPhaseLibraryPlugin.js +0 -44
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ParsedAssetsJson, VerifiedAdvancedOutputConfig } from "../shared";
|
|
2
|
+
import type { ExtensibleEntryObject, VerifiedPlauditWordpressWebpackConfig } from "../utils/common-config-helpers";
|
|
3
|
+
import { PseudoSemaphore } from "../utils/pseduo-semaphore";
|
|
4
|
+
import { AbstractBiPhasicGroupPlugin } from "./AbstractBiPhasicGroupPlugin";
|
|
5
|
+
import { Compilation, Compiler, Entrypoint } from "webpack";
|
|
6
|
+
export type EntryProvider<M extends {
|
|
7
|
+
dest: VerifiedAdvancedOutputConfig;
|
|
8
|
+
} = {
|
|
9
|
+
dest: VerifiedAdvancedOutputConfig;
|
|
10
|
+
}> = () => ExtensibleEntryObject<M> | Promise<ExtensibleEntryObject<M>>;
|
|
11
|
+
export declare abstract class AbstractBiPhasicGroupAndEntryPlugin<M extends {
|
|
12
|
+
dest: VerifiedAdvancedOutputConfig;
|
|
13
|
+
} = {
|
|
14
|
+
dest: VerifiedAdvancedOutputConfig;
|
|
15
|
+
}> extends AbstractBiPhasicGroupPlugin {
|
|
16
|
+
private readonly context;
|
|
17
|
+
private readonly entry;
|
|
18
|
+
private static readonly configuredCompilations;
|
|
19
|
+
private readonly entryMetadataRecord;
|
|
20
|
+
protected constructor(config: VerifiedPlauditWordpressWebpackConfig, group: string, semaphores: PseudoSemaphore<any>[], context: string, entry: EntryProvider<M>);
|
|
21
|
+
apply(compiler: Compiler): void;
|
|
22
|
+
protected attachStandardPhase(compilation: Compilation): void;
|
|
23
|
+
/**
|
|
24
|
+
* NOTE: This function returns an ITERATOR. Call .toArray() on it if you need to use the result multiple times
|
|
25
|
+
*/
|
|
26
|
+
getRelevantEntrypoints(compilation: Compilation): IteratorObject<{
|
|
27
|
+
entrypoint: Entrypoint;
|
|
28
|
+
srcPath: string;
|
|
29
|
+
metadata: M;
|
|
30
|
+
}, undefined, unknown>;
|
|
31
|
+
protected abstract processAssets(compilation: Compilation, parsedAssetsJson: ParsedAssetsJson): Promise<void> | void;
|
|
32
|
+
protected extractRelevantAssetData(compilation: Compilation, parsedAssetsJson: ParsedAssetsJson): ParsedAssetsJson;
|
|
33
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbstractBiPhasicGroupAndEntryPlugin = void 0;
|
|
4
|
+
const shared_1 = require("../shared");
|
|
5
|
+
const AbstractBiPhasicGroupPlugin_1 = require("./AbstractBiPhasicGroupPlugin");
|
|
6
|
+
const webpack_1 = require("webpack");
|
|
7
|
+
class AbstractBiPhasicGroupAndEntryPlugin extends AbstractBiPhasicGroupPlugin_1.AbstractBiPhasicGroupPlugin {
|
|
8
|
+
context;
|
|
9
|
+
entry;
|
|
10
|
+
static configuredCompilations = new WeakSet();
|
|
11
|
+
entryMetadataRecord = {};
|
|
12
|
+
constructor(config, group, semaphores, context, entry) {
|
|
13
|
+
super(config, group, 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 (!AbstractBiPhasicGroupAndEntryPlugin.configuredCompilations.has(compilation)) {
|
|
21
|
+
AbstractBiPhasicGroupAndEntryPlugin.configuredCompilations.add(compilation);
|
|
22
|
+
const dummyEntry = webpack_1.EntryPlugin.createDependency("", "");
|
|
23
|
+
compilation.dependencyFactories.set(dummyEntry.constructor, normalModuleFactory);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
compiler.hooks.make.tapPromise(this.constructor.name, async (compilation) => {
|
|
27
|
+
const entry = await this.entry();
|
|
28
|
+
const promises = [];
|
|
29
|
+
for (const [name, { plauditMetadata, ...desc }] of Object.entries(entry)) {
|
|
30
|
+
const options = webpack_1.EntryOptionPlugin.entryDescriptionToOptions(compiler, name, desc);
|
|
31
|
+
this.entryMetadataRecord[name] = plauditMetadata;
|
|
32
|
+
for (const entry of desc.import) {
|
|
33
|
+
promises.push(new Promise((resolve, reject) => {
|
|
34
|
+
compilation.addEntry(this.context, webpack_1.EntryPlugin.createDependency(entry, options), options, err => {
|
|
35
|
+
if (err) {
|
|
36
|
+
return reject(err);
|
|
37
|
+
}
|
|
38
|
+
resolve();
|
|
39
|
+
});
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
await Promise.all(promises);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
attachStandardPhase(compilation) {
|
|
47
|
+
this.tapWithParsedAssetsJson(compilation, async (parsedAssetsJson) => {
|
|
48
|
+
await this.processAssets(compilation, parsedAssetsJson);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* NOTE: This function returns an ITERATOR. Call .toArray() on it if you need to use the result multiple times
|
|
53
|
+
*/
|
|
54
|
+
getRelevantEntrypoints(compilation) {
|
|
55
|
+
return compilation.entrypoints.values()
|
|
56
|
+
.map(entrypoint => {
|
|
57
|
+
const name = entrypoint.name;
|
|
58
|
+
if (!name) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
const metadata = this.entryMetadataRecord[name];
|
|
62
|
+
if (metadata === undefined) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
const srcPath = entrypoint.origins[0]?.request;
|
|
66
|
+
if (!srcPath) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
return { entrypoint, srcPath, metadata };
|
|
70
|
+
})
|
|
71
|
+
.filter(item => item !== undefined);
|
|
72
|
+
}
|
|
73
|
+
extractRelevantAssetData(compilation, parsedAssetsJson) {
|
|
74
|
+
const relevantAssetData = {};
|
|
75
|
+
for (const { entrypoint, srcPath } of this.getRelevantEntrypoints(compilation)) {
|
|
76
|
+
const fileWithAssetData = entrypoint.getEntrypointChunk().files.values().find(file => parsedAssetsJson[file]);
|
|
77
|
+
if (!fileWithAssetData) {
|
|
78
|
+
compilation.errors.push((0, shared_1.newWebpackErrorForFile)(`assets.json did not contain information for ${srcPath}`, srcPath));
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
relevantAssetData[fileWithAssetData] = parsedAssetsJson[fileWithAssetData];
|
|
82
|
+
}
|
|
83
|
+
return relevantAssetData;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.AbstractBiPhasicGroupAndEntryPlugin = AbstractBiPhasicGroupAndEntryPlugin;
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
import { ParsedAssetsJson } from "../shared";
|
|
5
|
+
type TapWithAssetsJsonOptions = {
|
|
6
|
+
name?: string;
|
|
7
|
+
stage?: (typeof Compilation.PROCESS_ASSETS_STAGE_REPORT) | (typeof Compilation.PROCESS_ASSETS_STAGE_ANALYSE);
|
|
8
|
+
additionalAssets?: any;
|
|
9
|
+
};
|
|
10
|
+
type TapWithAssetsJsonFn = Parameters<Compilation['hooks']['processAssets']['tapPromise']>[1];
|
|
11
|
+
type TapWithParsedAssetsJsonFn = (parsedAssetsJson: ParsedAssetsJson, assets: Parameters<TapWithAssetsJsonFn>[0]) => Promise<void> | void;
|
|
12
|
+
export declare abstract class AbstractBiPhasicGroupPlugin implements WebpackPluginInstance {
|
|
13
|
+
protected readonly config: VerifiedPlauditWordpressWebpackConfig;
|
|
14
|
+
readonly group: string;
|
|
15
|
+
private readonly semaphores;
|
|
16
|
+
protected static readonly uniquePhaseAttached: {
|
|
17
|
+
[key in string]: any;
|
|
18
|
+
};
|
|
19
|
+
protected readonly id: string;
|
|
20
|
+
protected constructor(config: VerifiedPlauditWordpressWebpackConfig, group: string, semaphores: PseudoSemaphore<any>[]);
|
|
21
|
+
apply(compiler: Compiler): void;
|
|
22
|
+
protected resetSemaphores(): void;
|
|
23
|
+
protected rejectSemaphores(): void;
|
|
24
|
+
protected abstract attachStandardPhase(compilation: Compilation): void;
|
|
25
|
+
protected abstract attachUniquePhase(compilation: Compilation): void;
|
|
26
|
+
protected tapRequiringAssetsJson(compilation: Compilation, fnOrOptions: TapWithAssetsJsonFn): void;
|
|
27
|
+
protected tapRequiringAssetsJson(compilation: Compilation, fnOrOptions: TapWithAssetsJsonOptions, fnIfOptions: TapWithAssetsJsonFn): void;
|
|
28
|
+
protected tapWithParsedAssetsJson(compilation: Compilation, fnOrOptions: TapWithParsedAssetsJsonFn): void;
|
|
29
|
+
protected tapWithParsedAssetsJson(compilation: Compilation, fnOrOptions: TapWithAssetsJsonOptions, fnIfOptions: TapWithParsedAssetsJsonFn): void;
|
|
30
|
+
private sharedTapLogicForAssetsJsonHelpers;
|
|
31
|
+
private extractTapAndFunction;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbstractBiPhasicGroupPlugin = void 0;
|
|
4
|
+
const webpack_1 = require("webpack");
|
|
5
|
+
const shared_1 = require("../shared");
|
|
6
|
+
class AbstractBiPhasicGroupPlugin {
|
|
7
|
+
config;
|
|
8
|
+
group;
|
|
9
|
+
semaphores;
|
|
10
|
+
static uniquePhaseAttached = {};
|
|
11
|
+
id;
|
|
12
|
+
constructor(config, group, semaphores) {
|
|
13
|
+
this.config = config;
|
|
14
|
+
this.group = group;
|
|
15
|
+
this.semaphores = semaphores;
|
|
16
|
+
this.id = Math.random().toString();
|
|
17
|
+
}
|
|
18
|
+
apply(compiler) {
|
|
19
|
+
webpack_1.library.EnableLibraryPlugin.setEnabled(compiler, this.group);
|
|
20
|
+
for (const semaphore of this.semaphores) {
|
|
21
|
+
semaphore.register(this.id);
|
|
22
|
+
}
|
|
23
|
+
compiler.hooks.compilation.tap(this.constructor.name, compilation => {
|
|
24
|
+
AbstractBiPhasicGroupPlugin.uniquePhaseAttached[this.group] = false;
|
|
25
|
+
this.resetSemaphores();
|
|
26
|
+
compilation.hooks.beforeChunkIds.tap(this.constructor.name, () => {
|
|
27
|
+
if (!AbstractBiPhasicGroupPlugin.uniquePhaseAttached[this.group]) {
|
|
28
|
+
AbstractBiPhasicGroupPlugin.uniquePhaseAttached[this.group] = this;
|
|
29
|
+
this.attachUniquePhase(compilation);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
this.attachStandardPhase(compilation);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
resetSemaphores() {
|
|
36
|
+
for (const semaphore of this.semaphores) {
|
|
37
|
+
semaphore.reset(this.id);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
rejectSemaphores() {
|
|
41
|
+
for (const semaphore of this.semaphores) {
|
|
42
|
+
semaphore.reject(this.id);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
tapRequiringAssetsJson(compilation, fnOrOptions, fnIfOptions) {
|
|
46
|
+
this.sharedTapLogicForAssetsJsonHelpers(compilation, this.extractTapAndFunction(fnOrOptions, fnIfOptions));
|
|
47
|
+
}
|
|
48
|
+
tapWithParsedAssetsJson(compilation, fnOrOptions, fnIfOptions) {
|
|
49
|
+
const { tap, earlyStage, fn } = this.extractTapAndFunction(fnOrOptions, fnIfOptions);
|
|
50
|
+
this.sharedTapLogicForAssetsJsonHelpers(compilation, { tap, earlyStage, fn: async (assets) => {
|
|
51
|
+
try {
|
|
52
|
+
await fn((0, shared_1.getAssetsJson)(compilation), assets);
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
console.error(e);
|
|
56
|
+
this.rejectSemaphores();
|
|
57
|
+
if (e instanceof Error) {
|
|
58
|
+
compilation.errors.push(e);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
throw e;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
} });
|
|
65
|
+
}
|
|
66
|
+
sharedTapLogicForAssetsJsonHelpers(compilation, { tap, earlyStage, fn }) {
|
|
67
|
+
compilation.hooks.processAssets.tapPromise({ ...tap, additionalAssets: true }, async (assets, ...args) => {
|
|
68
|
+
if (!earlyStage || "assets.json" in assets) {
|
|
69
|
+
await fn(assets, ...args);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
extractTapAndFunction(fnOrOptions, fnIfOptions) {
|
|
74
|
+
let tap = { name: this.constructor.name, stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_ANALYSE };
|
|
75
|
+
let fn;
|
|
76
|
+
if (typeof fnOrOptions === 'function') {
|
|
77
|
+
fn = fnOrOptions;
|
|
78
|
+
}
|
|
79
|
+
else if (!fnIfOptions) {
|
|
80
|
+
throw new Error("Somehow reached an impossible state. Make sure that you're using TypeScript.");
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
tap = { ...tap, ...fnOrOptions };
|
|
84
|
+
fn = fnIfOptions;
|
|
85
|
+
}
|
|
86
|
+
const earlyStage = tap.stage === webpack_1.Compilation.PROCESS_ASSETS_STAGE_ANALYSE;
|
|
87
|
+
if (earlyStage && tap.additionalAssets === undefined) {
|
|
88
|
+
tap.additionalAssets = true;
|
|
89
|
+
}
|
|
90
|
+
return { tap, earlyStage, fn };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.AbstractBiPhasicGroupPlugin = AbstractBiPhasicGroupPlugin;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { AbstractBiPhasicGroupPlugin } from "./AbstractBiPhasicGroupPlugin";
|
|
2
|
+
import type { AbstractBiPhasicGroupAndEntryPlugin } from "./AbstractBiPhasicGroupAndEntryPlugin";
|
|
3
|
+
import { VerifiedPlauditWordpressWebpackConfig } from "../utils/common-config-helpers";
|
|
4
|
+
import { Compilation } from "webpack";
|
|
5
|
+
export declare class AdditionalDependencyInjectorPlugin extends AbstractBiPhasicGroupPlugin {
|
|
5
6
|
private readonly processingModules;
|
|
6
7
|
private readonly addExternalizedDep;
|
|
7
8
|
private readonly referencePlugin;
|
|
8
|
-
constructor(
|
|
9
|
-
|
|
9
|
+
constructor(config: VerifiedPlauditWordpressWebpackConfig, processingModules: boolean, addExternalizedDep: (dep: string) => void, referencePlugin: AbstractBiPhasicGroupAndEntryPlugin<any>);
|
|
10
|
+
protected attachStandardPhase(compilation: Compilation): void;
|
|
11
|
+
protected attachUniquePhase(): void;
|
|
10
12
|
}
|
|
@@ -4,57 +4,55 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.AdditionalDependencyInjectorPlugin = void 0;
|
|
7
|
-
const
|
|
7
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
8
|
+
const AbstractBiPhasicGroupPlugin_1 = require("./AbstractBiPhasicGroupPlugin");
|
|
9
|
+
const shared_1 = require("../shared");
|
|
8
10
|
const webpack_1 = require("webpack");
|
|
9
|
-
class AdditionalDependencyInjectorPlugin {
|
|
10
|
-
entrypointAdditionalDependencies;
|
|
11
|
+
class AdditionalDependencyInjectorPlugin extends AbstractBiPhasicGroupPlugin_1.AbstractBiPhasicGroupPlugin {
|
|
11
12
|
processingModules;
|
|
12
13
|
addExternalizedDep;
|
|
13
14
|
referencePlugin;
|
|
14
|
-
constructor(
|
|
15
|
-
|
|
15
|
+
constructor(config, processingModules, addExternalizedDep, referencePlugin) {
|
|
16
|
+
super(config, "additional-dependency-injector-plugin", []);
|
|
16
17
|
this.processingModules = processingModules;
|
|
17
18
|
this.addExternalizedDep = addExternalizedDep;
|
|
18
19
|
this.referencePlugin = referencePlugin;
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const firstLine = node_fs_1.default.readFileSync(req, 'utf8').trim().split(/\r?\n/)[0];
|
|
34
|
-
if (firstLine?.startsWith("//ADDITIONAL_DEPENDENCIES:")) {
|
|
35
|
-
additionalDependencies.push(...firstLine.substring(26).trim().split(',').map(dep => dep.trim()));
|
|
36
|
-
}
|
|
37
|
-
const chunk = entrypoint.getEntrypointChunk();
|
|
38
|
-
for (const additionalDep of additionalDependencies) {
|
|
39
|
-
this.addExternalizedDep(additionalDep);
|
|
40
|
-
compilation.chunkGraph.connectChunkAndModule(chunk, new webpack_1.ExternalModule("__REMOVE_ME__", "", additionalDep));
|
|
41
|
-
}
|
|
21
|
+
attachStandardPhase(compilation) {
|
|
22
|
+
const usableEntrypointTest = this.processingModules ? shared_1.scriptWithModuleExtension : shared_1.scriptWithoutModuleExtension;
|
|
23
|
+
compilation.hooks.processAssets.tapPromise({
|
|
24
|
+
name: `${this.constructor.name}_ProcessAssets_AddFakeModules`,
|
|
25
|
+
stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
|
|
26
|
+
}, async () => {
|
|
27
|
+
await Promise.all(this.referencePlugin.getRelevantEntrypoints(compilation)
|
|
28
|
+
.filter(re => usableEntrypointTest.test(re.srcPath))
|
|
29
|
+
.map(async ({ entrypoint, metadata, srcPath }) => {
|
|
30
|
+
const additionalDependencies = [...metadata.dest.additionalDependencies];
|
|
31
|
+
const firstLine = (await promises_1.default.readFile(srcPath, 'utf-8')).trim().split(/\r?\n/)[0];
|
|
32
|
+
if (firstLine?.startsWith("//ADDITIONAL_DEPENDENCIES:")) {
|
|
33
|
+
additionalDependencies.push(...firstLine.substring(26).trim().split(',').map(dep => dep.trim()));
|
|
42
34
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
35
|
+
const chunk = entrypoint.getEntrypointChunk();
|
|
36
|
+
for (const additionalDep of additionalDependencies) {
|
|
37
|
+
this.addExternalizedDep(additionalDep);
|
|
38
|
+
compilation.chunkGraph.connectChunkAndModule(chunk, new webpack_1.ExternalModule("__REMOVE_ME__", "", additionalDep));
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
});
|
|
42
|
+
compilation.hooks.processAssets.tap({
|
|
43
|
+
name: `${this.constructor.name}_ProcessAssets_RemoveFakeModules`,
|
|
44
|
+
stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_REPORT
|
|
45
|
+
}, () => {
|
|
46
|
+
for (const { entrypoint } of this.referencePlugin.getRelevantEntrypoints(compilation)) {
|
|
47
|
+
const entrypointChunk = entrypoint.getEntrypointChunk();
|
|
48
|
+
for (const module of compilation.chunkGraph.getChunkModules(entrypointChunk)) {
|
|
49
|
+
if (module instanceof webpack_1.ExternalModule && module.request === '__REMOVE_ME__') {
|
|
50
|
+
compilation.chunkGraph.disconnectChunkAndModule(entrypointChunk, module);
|
|
54
51
|
}
|
|
55
52
|
}
|
|
56
|
-
}
|
|
53
|
+
}
|
|
57
54
|
});
|
|
58
55
|
}
|
|
56
|
+
attachUniquePhase() { }
|
|
59
57
|
}
|
|
60
58
|
exports.AdditionalDependencyInjectorPlugin = AdditionalDependencyInjectorPlugin;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { UnpackedBlockEntrypointInfo } from "../shared";
|
|
1
|
+
import { AbstractBiPhasicGroupAndEntryPlugin, EntryProvider } from "./AbstractBiPhasicGroupAndEntryPlugin";
|
|
3
2
|
import type { VerifiedPlauditWordpressWebpackConfig } from "../utils/common-config-helpers";
|
|
4
|
-
export declare class EnhancedDynamicEntryPlugin extends
|
|
5
|
-
constructor(config: VerifiedPlauditWordpressWebpackConfig, context: string, entry: EntryProvider
|
|
6
|
-
protected
|
|
3
|
+
export declare class EnhancedDynamicEntryPlugin extends AbstractBiPhasicGroupAndEntryPlugin {
|
|
4
|
+
constructor(config: VerifiedPlauditWordpressWebpackConfig, context: string, entry: EntryProvider);
|
|
5
|
+
protected attachUniquePhase(): void;
|
|
7
6
|
protected processAssets(): void;
|
|
8
7
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EnhancedDynamicEntryPlugin = void 0;
|
|
4
|
-
const
|
|
5
|
-
class EnhancedDynamicEntryPlugin extends
|
|
4
|
+
const AbstractBiPhasicGroupAndEntryPlugin_1 = require("./AbstractBiPhasicGroupAndEntryPlugin");
|
|
5
|
+
class EnhancedDynamicEntryPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.AbstractBiPhasicGroupAndEntryPlugin {
|
|
6
6
|
constructor(config, context, entry) {
|
|
7
7
|
super(config, `enhanced-dynamic-entries`, [], context, entry);
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
attachUniquePhase() { }
|
|
10
10
|
processAssets() { }
|
|
11
11
|
}
|
|
12
12
|
exports.EnhancedDynamicEntryPlugin = EnhancedDynamicEntryPlugin;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AbstractBiPhasicGroupAndEntryPlugin, EntryProvider } from "./AbstractBiPhasicGroupAndEntryPlugin";
|
|
2
|
+
import { ParsedAssetsJson, VerifiedAdvancedOutputConfig } from "../shared";
|
|
3
3
|
import type { VerifiedPlauditWordpressWebpackConfig } from "../utils/common-config-helpers";
|
|
4
4
|
import { Compilation, type Compiler } from "webpack";
|
|
5
|
-
export declare class ExtensionsConfigFileGeneratorPlugin extends
|
|
6
|
-
private readonly
|
|
5
|
+
export declare class ExtensionsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAndEntryPlugin {
|
|
6
|
+
private readonly extensionsSrcPath;
|
|
7
7
|
private readonly dest;
|
|
8
8
|
private static readonly semaphore;
|
|
9
|
-
private
|
|
10
|
-
constructor(config: VerifiedPlauditWordpressWebpackConfig,
|
|
9
|
+
private setupFiles;
|
|
10
|
+
constructor(config: VerifiedPlauditWordpressWebpackConfig, extensionsSrcPath: string, dest: VerifiedAdvancedOutputConfig, context: string, entry: EntryProvider);
|
|
11
|
+
get extensionsDestPath(): string;
|
|
11
12
|
apply(compiler: Compiler): void;
|
|
12
13
|
private generateVersionTwoConfigFile;
|
|
13
|
-
protected
|
|
14
|
-
protected processAssets(compilation: Compilation, rawAssetData:
|
|
14
|
+
protected attachUniquePhase(compilation: Compilation): void;
|
|
15
|
+
protected processAssets(compilation: Compilation, rawAssetData: ParsedAssetsJson): void;
|
|
15
16
|
}
|