@plaudit/webpack-extensions 2.65.2 → 2.65.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.
@@ -52,9 +52,8 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
52
52
  finalHandleName = (0, shared_1.convertUsageLocationsHandleToEmittableHandle)(handleName, basename);
53
53
  }
54
54
  else {
55
- const baseFinalHandleName = `${handlePrefix}.${(0, shared_1.kebabCase)(basename)}`;
56
55
  const handleNameMap = usedHandleNames[type];
57
- finalHandleName = (0, shared_1.convertUsageLocationsHandleToEmittableHandle)(handleName, basename);
56
+ const baseFinalHandleName = finalHandleName = `${handlePrefix}.${(0, shared_1.convertUsageLocationsHandleToEmittableHandle)((0, shared_1.kebabCase)(basename), basename)}`;
58
57
  for (let count = 0; finalHandleName in handleNameMap && handleNameMap[finalHandleName] !== src;) {
59
58
  finalHandleName = `${baseFinalHandleName}-${++count}`;
60
59
  }
@@ -202,7 +201,7 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
202
201
  PlainEntrypointsConfigFileGeneratorPlugin.semaphore.resolve(this.id, myAssetHandles);
203
202
  UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.resolve(this.id, myAssetHandles.length
204
203
  ? {
205
- group: this.group, requiresBaseURI: true, action: writer => writer.append("require_once __DIR__.'/plain-entrypoints-loader.php';"),
204
+ group: this.group, requiresBaseURI: true, action: writer => writer.require("/plain-entrypoints-loader.php", { dirRelative: true, once: true }),
206
205
  staticallyLoadedEntrypoints: relevantEntrypoints.flatMap(re => re.entrypoint.getEntrypointChunk().files.values().toArray())
207
206
  }
208
207
  : undefined);
@@ -93,7 +93,7 @@ class PlainEntrypointsStyleBlockJSONPlugin extends AbstractBiPhasicGroupAndEntry
93
93
  group: this.group,
94
94
  requiresBaseURI: false,
95
95
  staticallyLoadedEntrypoints: relevantEntrypoints.flatMap(re => re.entrypoint.getEntrypointChunk().files.values().toArray()),
96
- action: writer => writer.append(`require_once __DIR__.${php_writer_1.Expr.convertJsonToPHP("/" + node_path_1.default.join(this.blocksDest, "blockdir-loader.php"))};`)
96
+ action: writer => writer.require(node_path_1.default.join(this.blocksDest, "blockdir-loader.php"), { dirRelative: true, once: true })
97
97
  } : undefined);
98
98
  }
99
99
  emitBlockLoaderFile(compilation, blockData) {
@@ -48,7 +48,7 @@ class SpecialAssetHandlingPlugin extends AbstractBiPhasicGroupPlugin_1.AbstractB
48
48
  }
49
49
  SpecialAssetHandlingPlugin.semaphore.resolve(this.id, specialAssetData);
50
50
  UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.resolve(this.id, Object.keys(specialAssetData).length > 0
51
- ? { group: 'special-assets', requiresBaseURI: true, action: writer => writer.append("require_once __DIR__.'/special-assets.php';") }
51
+ ? { group: 'special-assets', requiresBaseURI: true, action: writer => writer.require("/special-assets.php", { dirRelative: true, once: true }) }
52
52
  : undefined);
53
53
  }
54
54
  catch (e) {
@@ -130,6 +130,10 @@ export declare abstract class Constants {
130
130
  static readonly __DIR__: EnclosedLiteral;
131
131
  static readonly ABSPATH: EnclosedLiteral;
132
132
  }
133
+ export type AppendExprArgs = {
134
+ chain?: boolean;
135
+ return?: boolean;
136
+ };
133
137
  export type ActionOrFilterArgs = {
134
138
  priority?: number | Expr;
135
139
  functionArgParameters?: string[];
@@ -143,6 +147,10 @@ export type FunctionCreationArgs = {
143
147
  assignToName?: boolean;
144
148
  scopeActionDescription?: string;
145
149
  };
150
+ export type RequireOrIncludeArgs = {
151
+ dirRelative?: boolean;
152
+ once?: boolean;
153
+ } & AppendExprArgs;
146
154
  export declare class PHPWriter {
147
155
  private readonly inlineFirstLine;
148
156
  private readonly scopeStack;
@@ -167,14 +175,8 @@ export declare class PHPWriter {
167
175
  * @param expr This is treated as literal *regardless of its type*
168
176
  * @param opts flags to add additional markup around the expression
169
177
  */
170
- appendExpr(expr: string | Expr, opts?: {
171
- chain?: boolean;
172
- return?: boolean;
173
- }): this;
174
- assign(assignee: ConstructorParameters<typeof Assignment>[0] | string, expression: unknown, opts?: {
175
- chain?: boolean;
176
- return?: boolean;
177
- }): this;
178
+ appendExpr(expr: string | Expr, opts?: AppendExprArgs): this;
179
+ assign(assignee: ConstructorParameters<typeof Assignment>[0] | string, expression: unknown, opts?: AppendExprArgs): this;
178
180
  return(expression: unknown | Expr): this;
179
181
  static(variable: Var | string, opts?: {
180
182
  initializer?: unknown | Literal;
@@ -187,10 +189,8 @@ export declare class PHPWriter {
187
189
  * @param opts
188
190
  */
189
191
  call(func: string | EnclosableExpression, args: unknown[], opts?: {
190
- chain?: boolean;
191
192
  assignTo?: ConstructorParameters<typeof Assignment>[0];
192
- return?: boolean;
193
- }): this;
193
+ } & AppendExprArgs): this;
194
194
  action(name: string | Expr, contents: (writer: PHPWriter) => void, args?: ActionOrFilterArgs): this;
195
195
  filter(name: string | Expr, contents: (writer: PHPWriter) => void, args?: ActionOrFilterArgs): this;
196
196
  actionOrFilter(type: 'action' | 'filter', name: string | Expr, contents: (writer: PHPWriter) => void, args: ActionOrFilterArgs): this;
@@ -207,6 +207,9 @@ export declare class PHPWriter {
207
207
  openPHP(): this;
208
208
  namespace(namespace: string): this;
209
209
  use(...uses: string[]): this;
210
+ require(filePath: string | Expr, args?: RequireOrIncludeArgs): this;
211
+ include(filePath: string | Expr, args?: RequireOrIncludeArgs): this;
212
+ requireOrInclude(type: 'require' | 'include', filePath: string | Expr, args: RequireOrIncludeArgs): this;
210
213
  /**
211
214
  * Starts a scope that, when paired with {@link #closeScope()}, allows for automating unset calls.
212
215
  * All scopes started MUST be paired with either an {@link #closeScope()} or {@link #popScope()} call.
@@ -12,6 +12,7 @@ class Expr {
12
12
  static jsonToPHPConverter = json_to_php_but_with____injection_1.default.make({ shortArraySyntax: true });
13
13
  static convertJsonToPHP = (obj) => obj instanceof Expr ? obj.toString() : Expr.jsonToPHPConverter(obj);
14
14
  constructor() { }
15
+ // noinspection JSUnusedGlobalSymbols - this technically-unused method is necessary for TypeScript to differentiate subclasses of Expr from any
15
16
  typeName() {
16
17
  return this.constructor.name;
17
18
  }
@@ -514,6 +515,20 @@ class PHPWriter {
514
515
  }
515
516
  return this;
516
517
  }
518
+ require(filePath, args = {}) {
519
+ return this.requireOrInclude('require', filePath, args);
520
+ }
521
+ include(filePath, args = {}) {
522
+ return this.requireOrInclude('include', filePath, args);
523
+ }
524
+ requireOrInclude(type, filePath, args) {
525
+ const command = args.once ? `${type}_once` : type;
526
+ if (args.dirRelative && typeof filePath === 'string' && !filePath.startsWith("/")) {
527
+ filePath = "/" + filePath;
528
+ }
529
+ const path = args.dirRelative ? Op.join(Constants.__DIR__, filePath) : Expr.convertJsonToPHP(filePath);
530
+ return this.appendExpr(`${command} ${path}`, args);
531
+ }
517
532
  /**
518
533
  * Starts a scope that, when paired with {@link #closeScope()}, allows for automating unset calls.
519
534
  * All scopes started MUST be paired with either an {@link #closeScope()} or {@link #popScope()} call.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "2.65.2",
3
+ "version": "2.65.3",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "files": [
6
6
  "/build"