@plaudit/webpack-extensions 2.56.1 → 2.56.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.
|
@@ -166,7 +166,7 @@ class PlainEntrypointsConfigFileGeneratorPlugin {
|
|
|
166
166
|
PlainEntrypointsConfigFileGeneratorPlugin.emitResolveBaseUriFunction(writer);
|
|
167
167
|
for (const [priority, prioritizedHandleList] of PlainEntrypointsConfigFileGeneratorPlugin.separateHandleListByPriority(handleLists.register)) {
|
|
168
168
|
writer.action("init", writer => {
|
|
169
|
-
writer.call("plaudit_webpack_extensions__resolve_base_uri", [], { assignTo: "$base_uri" });
|
|
169
|
+
writer.call("plaudit_webpack_extensions__resolve_base_uri", [new php_writer_1.Expr('__DIR__')], { assignTo: "$base_uri" });
|
|
170
170
|
for (const { handle, type, data } of prioritizedHandleList) {
|
|
171
171
|
writer.call(`wp_register_${type}`, [handle, new php_writer_1.Expr(`$base_uri.${php_writer_1.Expr.jsonToPHPConverter(node_path_1.default.relative(emitDir, data.src))}`), ...data.rest]);
|
|
172
172
|
}
|
|
@@ -245,18 +245,20 @@ class PlainEntrypointsConfigFileGeneratorPlugin {
|
|
|
245
245
|
* The primary benefit of emitting a function instead of baking its contents into each function that uses it is that it allows us to avoid recomputing the base uri multiple times
|
|
246
246
|
*/
|
|
247
247
|
static emitResolveBaseUriFunction(writer) {
|
|
248
|
-
writer.function("plaudit_webpack_extensions__resolve_base_uri", [], () => {
|
|
248
|
+
writer.function("plaudit_webpack_extensions__resolve_base_uri", ["$dir"], () => {
|
|
249
249
|
writer
|
|
250
|
-
.static("$
|
|
251
|
-
.
|
|
252
|
-
.
|
|
253
|
-
.elseIf("str_starts_with(
|
|
254
|
-
.append("$path = ltrim(substr(
|
|
250
|
+
.static("$base_uris", { initializer: [] })
|
|
251
|
+
.if("isset($base_uris[$dir])")
|
|
252
|
+
.return("$base_uris[$dir]")
|
|
253
|
+
.elseIf("str_starts_with($dir, ABSPATH)")
|
|
254
|
+
.append("$path = ltrim(substr($dir, strlen(ABSPATH)), '/');")
|
|
255
|
+
.elseIf("str_starts_with($dir, '/workspace/website')")
|
|
256
|
+
.append("$path = ltrim(substr($dir, 18), '/');")
|
|
255
257
|
.else()
|
|
256
258
|
.call("error_log", ["UNABLE TO FIGURE OUT WHAT THE RELATIVE PATH TO THE BUILT FILES DIRECTORY SHOULD BE"])
|
|
257
259
|
.append("$path = '';")
|
|
258
260
|
.endIf()
|
|
259
|
-
.
|
|
261
|
+
.return("$base_uris[$dir] = trailingslashit(home_url($path))");
|
|
260
262
|
}, { returnType: "string", includeExistenceCheck: true });
|
|
261
263
|
}
|
|
262
264
|
}
|
|
@@ -86,7 +86,7 @@ class SpecialAssetHandlingPlugin {
|
|
|
86
86
|
}
|
|
87
87
|
PlainEntrypointsConfigFileGeneratorPlugin_1.PlainEntrypointsConfigFileGeneratorPlugin.emitResolveBaseUriFunction(writer);
|
|
88
88
|
writer.action("wp_head", writer => {
|
|
89
|
-
writer.call("plaudit_webpack_extensions__resolve_base_uri", [], { assignTo: "$base_uri" }).closePHP();
|
|
89
|
+
writer.call("plaudit_webpack_extensions__resolve_base_uri", [new php_writer_1.Expr('__DIR__')], { assignTo: "$base_uri" }).closePHP();
|
|
90
90
|
for (let [filename, { preload, fetchpriority, crossorigin }] of preloadedAssets) {
|
|
91
91
|
if (!preload) {
|
|
92
92
|
continue;
|
|
@@ -28,8 +28,9 @@ export declare class PHPWriter {
|
|
|
28
28
|
indent(): this;
|
|
29
29
|
outdent(): this;
|
|
30
30
|
append(...lines: (string | Expr)[]): this;
|
|
31
|
+
return(line: string | Expr): this;
|
|
31
32
|
static(variable: string, opts?: {
|
|
32
|
-
initializer?:
|
|
33
|
+
initializer?: unknown | Expr;
|
|
33
34
|
withTest?: boolean | 'chainable';
|
|
34
35
|
}): this;
|
|
35
36
|
linebreak(): this;
|
|
@@ -44,6 +44,9 @@ class PHPWriter {
|
|
|
44
44
|
}
|
|
45
45
|
return this;
|
|
46
46
|
}
|
|
47
|
+
return(line) {
|
|
48
|
+
return this.append(`return ${line};`);
|
|
49
|
+
}
|
|
47
50
|
static(variable, opts = {}) {
|
|
48
51
|
const initializer = opts.initializer ? Expr.convertJsonToPHP(opts.initializer) : "null";
|
|
49
52
|
this.append(`static ${variable} = ${initializer};`);
|
|
@@ -46,7 +46,7 @@ class PseudoSemaphore {
|
|
|
46
46
|
controller.resolve = resolve;
|
|
47
47
|
controller.reject = reject;
|
|
48
48
|
});
|
|
49
|
-
this.flags.set(id, [promise, controller, false
|
|
49
|
+
this.flags.set(id, [promise, controller, false]);
|
|
50
50
|
this.flagSet++;
|
|
51
51
|
promise.catch(() => { });
|
|
52
52
|
}
|
|
@@ -55,7 +55,7 @@ class PseudoSemaphore {
|
|
|
55
55
|
let res;
|
|
56
56
|
do {
|
|
57
57
|
currentFlagSet = this.flagSet;
|
|
58
|
-
res = await Promise.all(this.flags.values().
|
|
58
|
+
res = await Promise.all(this.flags.values().map(flag => flag[0]));
|
|
59
59
|
} while (currentFlagSet !== this.flagSet);
|
|
60
60
|
return res;
|
|
61
61
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plaudit/webpack-extensions",
|
|
3
|
-
"version": "2.56.
|
|
3
|
+
"version": "2.56.3",
|
|
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.28.0",
|
|
39
|
+
"@wordpress/scripts": "^30.21.0",
|
|
40
40
|
"autoprefixer": "^10.4.21",
|
|
41
41
|
"browser-sync": "^3.0.4",
|
|
42
42
|
"clean-webpack-plugin": "^4.0.0",
|