@plaudit/webpack-extensions 2.58.2 → 2.58.4
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/BlockJSONManagingPlugin.js +2 -1
- package/build/plugins/ExtensionsConfigFileGeneratorPlugin.js +23 -27
- package/build/plugins/PlainEntrypointsConfigFileGeneratorPlugin.js +2 -2
- package/build/plugins/SpecialAssetHandlingPlugin.js +1 -1
- package/build/plugins/UnifiedLoaderGenerator.d.ts +1 -0
- package/build/plugins/UnifiedLoaderGenerator.js +5 -4
- package/build/plugins/WPMLConfigBuilder.js +1 -0
- package/build/utils/php-writer.d.ts +1 -1
- package/build/utils/php-writer.js +2 -2
- package/package.json +4 -4
|
@@ -322,7 +322,8 @@ class BlockJSONManagingPlugin {
|
|
|
322
322
|
const blockDirConfigData = {};
|
|
323
323
|
compilation.hooks.processAssets.tap({ name: `${this.constructor.name}_UnifiedLoaderGeneratorIntegration`, stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_DERIVED }, () => {
|
|
324
324
|
UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.resolve(this.id, {
|
|
325
|
-
group:
|
|
325
|
+
group: `block-json-${this.blocksDest}`,
|
|
326
|
+
requiresBaseURI: false,
|
|
326
327
|
action: writer => {
|
|
327
328
|
writer
|
|
328
329
|
.use("Plaudit\\Common\\ACF\\BlockManager")
|
|
@@ -59,34 +59,9 @@ class ExtensionsConfigFileGeneratorPlugin {
|
|
|
59
59
|
main.setupFiles.push(...setupFiles);
|
|
60
60
|
return main;
|
|
61
61
|
}, { assets: [], setupFiles: [] });
|
|
62
|
-
if (combinedExtensionData.assets.length > 0 || combinedExtensionData.setupFiles.length > 0) {
|
|
63
|
-
UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.resolve(this.id, {
|
|
64
|
-
group: 'extensions-config-v2',
|
|
65
|
-
action: writer => {
|
|
66
|
-
let finalExtensionsDest = this.extensionsDest.endsWith("/") ? this.extensionsDest : this.extensionsDest + "/";
|
|
67
|
-
if (!finalExtensionsDest.startsWith("/")) {
|
|
68
|
-
finalExtensionsDest = "/" + finalExtensionsDest;
|
|
69
|
-
}
|
|
70
|
-
writer
|
|
71
|
-
.use("Plaudit\\Base\\API\\ThemeUtils")
|
|
72
|
-
.withScope(writer => writer
|
|
73
|
-
.assign("$filePathPrefix", new php_writer_1.Expr(`__DIR__.${php_writer_1.Expr.convertJsonToPHP(finalExtensionsDest)}`))
|
|
74
|
-
.call("plaudit_webpack_extensions__resolve_base_uri", [new php_writer_1.Expr("$filePathPrefix")], { assignTo: "$fileUriPrefix" })
|
|
75
|
-
.call("ThemeUtils::loadExtensionsV2", [
|
|
76
|
-
new php_writer_1.Expr(`__DIR__.${php_writer_1.Expr.convertJsonToPHP(finalExtensionsDest + "mapping.config.php")}`),
|
|
77
|
-
new php_writer_1.Expr(`$filePathPrefix`), new php_writer_1.Expr("$fileUriPrefix"),
|
|
78
|
-
`${this.config.plainEntrypointsHandlePrefix || node_path_1.default.basename(process.cwd())}_extension_`
|
|
79
|
-
]));
|
|
80
|
-
}
|
|
81
|
-
});
|
|
62
|
+
if (combinedExtensionData.assets.length > 0 || combinedExtensionData.setupFiles.length > 0 || !this.config.useUnifiedLoader) {
|
|
82
63
|
this.generateVersionTwoConfigFile(compilation, combinedExtensionData);
|
|
83
64
|
}
|
|
84
|
-
else {
|
|
85
|
-
if (!this.config.useUnifiedLoader) {
|
|
86
|
-
this.generateVersionTwoConfigFile(compilation, combinedExtensionData);
|
|
87
|
-
}
|
|
88
|
-
UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.resolve(this.id, undefined);
|
|
89
|
-
}
|
|
90
65
|
});
|
|
91
66
|
}
|
|
92
67
|
});
|
|
@@ -120,9 +95,30 @@ class ExtensionsConfigFileGeneratorPlugin {
|
|
|
120
95
|
myCacheData.assets.push(assetDataSource);
|
|
121
96
|
compilation.deleteAsset("assets.json");
|
|
122
97
|
ExtensionsConfigFileGeneratorPlugin.semaphore.resolve(this.id, myCacheData);
|
|
98
|
+
UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.resolve(this.id, myCacheData.setupFiles.length > 0 || myCacheData.assets.length > 0 ? {
|
|
99
|
+
group: `extensions-config-v2-${this.extensionsDest}`,
|
|
100
|
+
requiresBaseURI: true,
|
|
101
|
+
action: writer => {
|
|
102
|
+
let finalExtensionsDest = this.extensionsDest.endsWith("/") ? this.extensionsDest : this.extensionsDest + "/";
|
|
103
|
+
if (!finalExtensionsDest.startsWith("/")) {
|
|
104
|
+
finalExtensionsDest = "/" + finalExtensionsDest;
|
|
105
|
+
}
|
|
106
|
+
writer
|
|
107
|
+
.use("Plaudit\\Base\\API\\ThemeUtils")
|
|
108
|
+
.withScope(writer => writer
|
|
109
|
+
.assign("$filePathPrefix", new php_writer_1.Expr(`__DIR__.${php_writer_1.Expr.convertJsonToPHP(finalExtensionsDest)}`))
|
|
110
|
+
.call("plaudit_webpack_extensions__resolve_base_uri", [new php_writer_1.Expr("$filePathPrefix")], { assignTo: "$fileUriPrefix" })
|
|
111
|
+
.call("ThemeUtils::loadExtensionsV2", [
|
|
112
|
+
new php_writer_1.Expr(`__DIR__.${php_writer_1.Expr.convertJsonToPHP(finalExtensionsDest + "mapping.config.php")}`),
|
|
113
|
+
new php_writer_1.Expr(`$filePathPrefix`), new php_writer_1.Expr("$fileUriPrefix"),
|
|
114
|
+
`${this.config.plainEntrypointsHandlePrefix || node_path_1.default.basename(process.cwd())}_extension_`
|
|
115
|
+
]));
|
|
116
|
+
}
|
|
117
|
+
} : undefined);
|
|
123
118
|
}
|
|
124
119
|
catch (e) {
|
|
125
120
|
ExtensionsConfigFileGeneratorPlugin.semaphore.reject(this.id);
|
|
121
|
+
UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.reject(this.id);
|
|
126
122
|
if (e instanceof Error) {
|
|
127
123
|
compilation.errors.push(e);
|
|
128
124
|
return;
|
|
@@ -136,7 +132,7 @@ class ExtensionsConfigFileGeneratorPlugin {
|
|
|
136
132
|
compiler.hooks.thisCompilation.tap(this.constructor.name, compilation => {
|
|
137
133
|
UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.reset(this.id);
|
|
138
134
|
compilation.hooks.processAssets.tap({ name: `${this.constructor.name}_UnifiedLoaderGeneratorIntegration`, stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_DERIVED }, () => {
|
|
139
|
-
UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.resolve(this.id, { group:
|
|
135
|
+
UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.resolve(this.id, { group: `extensions-config-v1-${this.extensionsDest}`, requiresBaseURI: false, action: writer => {
|
|
140
136
|
writer
|
|
141
137
|
.use("Plaudit\\Base\\API\\ThemeUtils")
|
|
142
138
|
.call("ThemeUtils::installExtensionSupport", [new php_writer_1.Expr(`__DIR__.${php_writer_1.Expr.convertJsonToPHP(this.extensionsDest)}`)]);
|
|
@@ -104,7 +104,7 @@ class PlainEntrypointsConfigFileGeneratorPlugin {
|
|
|
104
104
|
compilation.deleteAsset("assets.json");
|
|
105
105
|
PlainEntrypointsConfigFileGeneratorPlugin.semaphore.resolve(this.id, myAssetHandles);
|
|
106
106
|
UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.resolve(this.id, myAssetHandles.length
|
|
107
|
-
? { group: 'plain-entrypoints-v2', action: writer => writer.append("require_once __DIR__.'/plain-entrypoints-loader.php';") }
|
|
107
|
+
? { group: 'plain-entrypoints-v2', requiresBaseURI: true, action: writer => writer.append("require_once __DIR__.'/plain-entrypoints-loader.php';") }
|
|
108
108
|
: undefined);
|
|
109
109
|
}
|
|
110
110
|
catch (e) {
|
|
@@ -257,7 +257,7 @@ class PlainEntrypointsConfigFileGeneratorPlugin {
|
|
|
257
257
|
writer
|
|
258
258
|
.static("$base_uris", { initializer: [] })
|
|
259
259
|
.if("isset($base_uris[$dir])")
|
|
260
|
-
.return("$base_uris[$dir]")
|
|
260
|
+
.return(new php_writer_1.Expr("$base_uris[$dir]"))
|
|
261
261
|
.elseIf("str_starts_with($dir, ABSPATH)")
|
|
262
262
|
.append("$path = ltrim(substr($dir, strlen(ABSPATH)), '/');")
|
|
263
263
|
.elseIf("str_starts_with($dir, '/workspace/website')")
|
|
@@ -65,7 +65,7 @@ class SpecialAssetHandlingPlugin {
|
|
|
65
65
|
}
|
|
66
66
|
SpecialAssetHandlingPlugin.semaphore.resolve(this.id, specialAssetData);
|
|
67
67
|
UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.resolve(this.id, Object.keys(specialAssetData).length > 0
|
|
68
|
-
? { group: 'special-assets', action: writer => writer.append("require_once __DIR__.'/special-assets.php';") }
|
|
68
|
+
? { group: 'special-assets', requiresBaseURI: true, action: writer => writer.append("require_once __DIR__.'/special-assets.php';") }
|
|
69
69
|
: undefined);
|
|
70
70
|
}
|
|
71
71
|
catch (e) {
|
|
@@ -30,14 +30,15 @@ class UnifiedLoaderGenerator {
|
|
|
30
30
|
const ap = a.priority ?? 0, bp = b.priority ?? 0;
|
|
31
31
|
return ap === bp ? a.group.localeCompare(b.group) : bp - ap;
|
|
32
32
|
})
|
|
33
|
-
.filter(a => !alreadyAllocatedGroups.has(a.group) && alreadyAllocatedGroups.add(a.group))
|
|
34
|
-
.map(a => a.action);
|
|
33
|
+
.filter(a => !alreadyAllocatedGroups.has(a.group) && alreadyAllocatedGroups.add(a.group));
|
|
35
34
|
if (writerCallbacks.length > 0) {
|
|
36
35
|
compilation.hooks.afterProcessAssets.tap(this.constructor.name, () => {
|
|
37
36
|
const writer = new php_writer_1.PHPWriter();
|
|
38
|
-
|
|
37
|
+
if (writerCallbacks.some(wc => wc.requiresBaseURI)) {
|
|
38
|
+
PlainEntrypointsConfigFileGeneratorPlugin_1.PlainEntrypointsConfigFileGeneratorPlugin.emitResolveBaseUriFunction(writer);
|
|
39
|
+
}
|
|
39
40
|
for (const writerCallback of writerCallbacks) {
|
|
40
|
-
writerCallback(writer);
|
|
41
|
+
writerCallback.action(writer);
|
|
41
42
|
}
|
|
42
43
|
writer.emitAsset(compilation, "unified-loader.php");
|
|
43
44
|
});
|
|
@@ -21,6 +21,7 @@ class WPMLConfigBuilderPlugin {
|
|
|
21
21
|
this.destDir = destDir;
|
|
22
22
|
}
|
|
23
23
|
apply(compiler) {
|
|
24
|
+
//TODO: Filter by library here as well
|
|
24
25
|
compiler.hooks.compilation.tap(this.constructor.name, compilation => {
|
|
25
26
|
compilation.hooks.processAssets.tapPromise({ name: `${this.constructor.name}__processXML`, stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL }, async (assets) => {
|
|
26
27
|
const entrypoint = compilation.entrypoints.get("wpml-config.xml");
|
|
@@ -33,7 +33,7 @@ export declare class PHPWriter {
|
|
|
33
33
|
chain?: boolean;
|
|
34
34
|
return?: boolean;
|
|
35
35
|
}): this;
|
|
36
|
-
return(
|
|
36
|
+
return(expression: unknown | Expr): this;
|
|
37
37
|
static(variable: string, opts?: {
|
|
38
38
|
initializer?: unknown | Expr;
|
|
39
39
|
withTest?: boolean | 'chainable';
|
|
@@ -65,8 +65,8 @@ class PHPWriter {
|
|
|
65
65
|
lineComponents.push(Expr.convertJsonToPHP(expression));
|
|
66
66
|
return this.append(!opts.chain ? lineComponents.join(" ") + ';' : lineComponents.join(" "));
|
|
67
67
|
}
|
|
68
|
-
return(
|
|
69
|
-
return this.append(`return ${
|
|
68
|
+
return(expression) {
|
|
69
|
+
return this.append(`return ${Expr.convertJsonToPHP(expression)};`);
|
|
70
70
|
}
|
|
71
71
|
static(variable, opts = {}) {
|
|
72
72
|
const initializer = opts.initializer ? Expr.convertJsonToPHP(opts.initializer) : "null";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plaudit/webpack-extensions",
|
|
3
|
-
"version": "2.58.
|
|
3
|
+
"version": "2.58.4",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"files": [
|
|
6
6
|
"/build"
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"@plaudit/postcss-silent-extend": "^3.0.0",
|
|
36
36
|
"@plaudit/postcss-strip-units": "^3.0.0",
|
|
37
37
|
"@plaudit/postcss-variables": "^1.1.0",
|
|
38
|
-
"@wordpress/dependency-extraction-webpack-plugin": "^6.
|
|
39
|
-
"@wordpress/scripts": "^30.
|
|
38
|
+
"@wordpress/dependency-extraction-webpack-plugin": "^6.29.0",
|
|
39
|
+
"@wordpress/scripts": "^30.22.0",
|
|
40
40
|
"autoprefixer": "^10.4.21",
|
|
41
41
|
"browser-sync": "^3.0.4",
|
|
42
42
|
"clean-webpack-plugin": "^4.0.0",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"postcss-url": "^10.1.3",
|
|
64
64
|
"react": "^18.3.1",
|
|
65
65
|
"react-dom": "^18.3.1",
|
|
66
|
-
"webpack": "^5.101.
|
|
66
|
+
"webpack": "^5.101.3",
|
|
67
67
|
"webpack-remove-empty-scripts": "^1.1.1",
|
|
68
68
|
"xml-formatter": "^3.6.6"
|
|
69
69
|
},
|