@plaudit/webpack-extensions 2.62.1 → 2.62.3
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/AbstractMultiPhaseLibraryPlugin.d.ts +6 -0
- package/build/plugins/AbstractMultiPhaseLibraryPlugin.js +17 -0
- package/build/plugins/ExtensionsConfigFileGeneratorPlugin.js +16 -4
- package/build/plugins/PlainEntrypointsStyleBlockJSONPlugin.js +2 -16
- package/build/utils/php-writer.js +4 -8
- package/package.json +1 -1
|
@@ -11,4 +11,10 @@ export declare abstract class AbstractMultiPhaseLibraryPlugin implements Webpack
|
|
|
11
11
|
apply(compiler: Compiler): void;
|
|
12
12
|
protected resetSemaphores(): void;
|
|
13
13
|
protected abstract attachSecondPhase(compilation: Compilation): void;
|
|
14
|
+
protected getRelevantEntrypoints(compilation: Compilation): {
|
|
15
|
+
entrypoint: import("webpack").Entrypoint;
|
|
16
|
+
entrypointChunk: import("webpack").Chunk;
|
|
17
|
+
entrypointLibrary: import("webpack").LibraryOptions;
|
|
18
|
+
srcPath: string;
|
|
19
|
+
}[];
|
|
14
20
|
}
|
|
@@ -84,5 +84,22 @@ class AbstractMultiPhaseLibraryPlugin {
|
|
|
84
84
|
semaphore.reset(this.id);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
+
getRelevantEntrypoints(compilation) {
|
|
88
|
+
return compilation.entrypoints.values()
|
|
89
|
+
.map(entrypoint => {
|
|
90
|
+
const entrypointChunk = entrypoint.getEntrypointChunk();
|
|
91
|
+
const entrypointLibrary = entrypointChunk.getEntryOptions()?.library;
|
|
92
|
+
if (entrypointLibrary?.type !== this.libraryType) {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
const srcPath = entrypoint.origins[0]?.request;
|
|
96
|
+
if (!srcPath) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
return { entrypoint, entrypointChunk, entrypointLibrary, srcPath };
|
|
100
|
+
})
|
|
101
|
+
.filter(item => item !== undefined)
|
|
102
|
+
.toArray();
|
|
103
|
+
}
|
|
87
104
|
}
|
|
88
105
|
exports.AbstractMultiPhaseLibraryPlugin = AbstractMultiPhaseLibraryPlugin;
|
|
@@ -16,7 +16,7 @@ class ExtensionsConfigFileGeneratorPlugin extends AbstractMultiPhaseLibraryPlugi
|
|
|
16
16
|
config;
|
|
17
17
|
extensionsPath;
|
|
18
18
|
extensionsDest;
|
|
19
|
-
static semaphore = new pseduo_semaphore_1.PseudoSemaphore({ assets: [], setupFiles: [] }, "Extensions");
|
|
19
|
+
static semaphore = new pseduo_semaphore_1.PseudoSemaphore({ libraryType: "", assets: [], setupFiles: [] }, "Extensions");
|
|
20
20
|
constructor(config, extensionsPath, extensionsDest) {
|
|
21
21
|
super(`extensions-v2-${extensionsDest}`, [ExtensionsConfigFileGeneratorPlugin.semaphore, UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore]);
|
|
22
22
|
this.config = config;
|
|
@@ -49,7 +49,9 @@ class ExtensionsConfigFileGeneratorPlugin extends AbstractMultiPhaseLibraryPlugi
|
|
|
49
49
|
try {
|
|
50
50
|
//TODO: It should be possible to use EntryPoints to determine the "original" file
|
|
51
51
|
//TODO: There is no reason to not use basically the exact same logic to implement support for this in plain file contexts
|
|
52
|
-
const myCacheData = { assets: [], setupFiles: [] };
|
|
52
|
+
const myCacheData = { libraryType: this.libraryType, assets: [], setupFiles: [] };
|
|
53
|
+
//TODO: Load up the -setup.php files as "entrypoints" in the same way that we're loading up block.json files
|
|
54
|
+
// That way, we'll be able to distinguish which ones go where
|
|
53
55
|
for (const asset of Object.keys(compilation.assets).map(asset => this.stripExtensionsDest(asset))) {
|
|
54
56
|
const blockSlug = /^(.+?)-setup.php$/i.exec(asset)?.[1];
|
|
55
57
|
if (blockSlug) {
|
|
@@ -68,7 +70,17 @@ class ExtensionsConfigFileGeneratorPlugin extends AbstractMultiPhaseLibraryPlugi
|
|
|
68
70
|
compilation.errors.push(new Error("assets.json is does not match the RawAssetData format"));
|
|
69
71
|
return;
|
|
70
72
|
}
|
|
71
|
-
|
|
73
|
+
const relevantAssetData = {};
|
|
74
|
+
const relevantEntrypoints = this.getRelevantEntrypoints(compilation);
|
|
75
|
+
for (const { entrypointChunk, srcPath } of relevantEntrypoints) {
|
|
76
|
+
const fileWithAssetData = entrypointChunk.files.values().find(file => assetDataSource[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] = assetDataSource[fileWithAssetData];
|
|
82
|
+
}
|
|
83
|
+
myCacheData.assets.push(relevantAssetData);
|
|
72
84
|
compilation.deleteAsset("assets.json");
|
|
73
85
|
ExtensionsConfigFileGeneratorPlugin.semaphore.resolve(this.id, myCacheData);
|
|
74
86
|
UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.resolve(this.id, myCacheData.setupFiles.length > 0 || myCacheData.assets.length > 0 ? {
|
|
@@ -168,7 +180,7 @@ class ExtensionsConfigFileGeneratorPlugin extends AbstractMultiPhaseLibraryPlugi
|
|
|
168
180
|
main.assets.push(...assets);
|
|
169
181
|
main.setupFiles.push(...setupFiles);
|
|
170
182
|
return main;
|
|
171
|
-
}, { assets: [], setupFiles: [] });
|
|
183
|
+
}, { assets: [], setupFiles: [], libraryType: "" });
|
|
172
184
|
if (combinedExtensionData.assets.length > 0 || combinedExtensionData.setupFiles.length > 0 || !this.config.useUnifiedLoader) {
|
|
173
185
|
this.generateVersionTwoConfigFile(compilation, combinedExtensionData);
|
|
174
186
|
}
|
|
@@ -57,21 +57,7 @@ class PlainEntrypointsStyleBlockJSONPlugin extends AbstractMultiPhaseLibraryPlug
|
|
|
57
57
|
.forEach(danglingBlockJsFile => {
|
|
58
58
|
compilation.deleteAsset(danglingBlockJsFile);
|
|
59
59
|
});
|
|
60
|
-
const relevantEntrypoints =
|
|
61
|
-
.map(entrypoint => {
|
|
62
|
-
const entrypointChunk = entrypoint.getEntrypointChunk();
|
|
63
|
-
const entrypointLibrary = entrypointChunk.getEntryOptions()?.library;
|
|
64
|
-
if (entrypointLibrary?.type !== this.libraryType) {
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
67
|
-
const srcPath = entrypoint.origins[0]?.request;
|
|
68
|
-
if (!srcPath) {
|
|
69
|
-
return undefined;
|
|
70
|
-
}
|
|
71
|
-
return { entrypoint, entrypointChunk, entrypointLibrary, srcPath };
|
|
72
|
-
})
|
|
73
|
-
.filter(item => item !== undefined)
|
|
74
|
-
.toArray();
|
|
60
|
+
const relevantEntrypoints = this.getRelevantEntrypoints(compilation);
|
|
75
61
|
const blockJsonOriginToOutputMapping = {};
|
|
76
62
|
for (const { entrypoint, entrypointChunk, entrypointLibrary, srcPath } of relevantEntrypoints) {
|
|
77
63
|
if (node_path_1.default.basename(srcPath).toLowerCase() !== "block.json" || entrypointLibrary.name !== "block-json-inclusion-assurance") {
|
|
@@ -130,7 +116,7 @@ class PlainEntrypointsStyleBlockJSONPlugin extends AbstractMultiPhaseLibraryPlug
|
|
|
130
116
|
applicableBlockJsonFiles[epBlockJson].workableBlockEntrypointsInfo.push(...workableBlockEntrypointsInfo);
|
|
131
117
|
}
|
|
132
118
|
else {
|
|
133
|
-
applicableBlockJsonFiles[epBlockJson] = { sourcePath: workableBlockEntrypointsInfo[0]?.blockJsonOrigin, workableBlockEntrypointsInfo
|
|
119
|
+
applicableBlockJsonFiles[epBlockJson] = { sourcePath: workableBlockEntrypointsInfo[0]?.blockJsonOrigin, workableBlockEntrypointsInfo };
|
|
134
120
|
}
|
|
135
121
|
}
|
|
136
122
|
}
|
|
@@ -207,18 +207,14 @@ class Assignment extends ParenthesesEnclosableExpression {
|
|
|
207
207
|
this.value = value;
|
|
208
208
|
this.push = push;
|
|
209
209
|
this.assignees = Array.isArray(assignees) ? assignees : [assignees];
|
|
210
|
-
if (this.
|
|
211
|
-
|
|
212
|
-
throw new Error("Cannot write to an access chain that does not end with a writable access");
|
|
213
|
-
}
|
|
210
|
+
if (this.assignees.some(a => a instanceof Access && !a.endsWithPotentiallyWritableExpression())) {
|
|
211
|
+
throw new Error("Cannot assign a value to an access chain that does not end in a writable state");
|
|
214
212
|
}
|
|
215
|
-
|
|
213
|
+
if (!this.push && this.assignees.some(a => a instanceof Call || (a instanceof Access && a.endsWithCall()))) {
|
|
214
|
+
throw new Error("Cannot assign a value to an access chain that ends in a function call unless that 'assignment' is a push");
|
|
216
215
|
}
|
|
217
216
|
}
|
|
218
217
|
toString() {
|
|
219
|
-
//TODO: Validate that we're in push mode if assigning to a call
|
|
220
|
-
if (!this.push && this.assignees.some(a => a instanceof Call)) {
|
|
221
|
-
}
|
|
222
218
|
const assignmentValue = isEnclosableExpression(this.value) ? this.value.toEnclosedForm() : Expr.convertJsonToPHP(this.value);
|
|
223
219
|
if (this.push) {
|
|
224
220
|
return this.assignees[0].toEnclosedForm() + "[] = " + assignmentValue;
|