@plaudit/webpack-extensions 2.56.2 → 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("$base_uri", { withTest: 'chainable' })
251
- .elseIf("str_starts_with(__DIR__, ABSPATH)")
252
- .append("$path = ltrim(substr(__DIR__, strlen(ABSPATH)), '/');")
253
- .elseIf("str_starts_with(__DIR__, '/workspace/website')")
254
- .append("$path = ltrim(substr(__DIR__, 18), '/');")
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
- .append("return $base_uri = trailingslashit(home_url($path));");
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?: string | Expr;
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};`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "2.56.2",
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.27.0",
39
- "@wordpress/scripts": "^30.20.0",
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",