@plaudit/webpack-extensions 2.57.0 → 2.57.2

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.
@@ -6,12 +6,13 @@ export declare class PlainEntrypointsConfigFileGeneratorPlugin implements Webpac
6
6
  private readonly outputDir;
7
7
  private readonly usageLocations;
8
8
  private readonly handlePrefix;
9
+ private readonly useUnifiedLoader;
9
10
  private static readonly semaphore;
10
11
  private static cache?;
11
12
  private readonly id;
12
- constructor(buildRoot: string, outputDir: string, usageLocations: UsageLocations, handlePrefix: string);
13
+ constructor(buildRoot: string, outputDir: string, usageLocations: UsageLocations, handlePrefix: string, useUnifiedLoader: boolean);
13
14
  apply(compiler: Compiler): void;
14
- private static afterProcessAssets;
15
+ private afterProcessAssets;
15
16
  private static addHandlesToHandleLists;
16
17
  private static appendEnqueuingHandleLists;
17
18
  private static separateHandleListByPriority;
@@ -15,14 +15,16 @@ class PlainEntrypointsConfigFileGeneratorPlugin {
15
15
  outputDir;
16
16
  usageLocations;
17
17
  handlePrefix;
18
+ useUnifiedLoader;
18
19
  static semaphore = new pseduo_semaphore_1.PseudoSemaphore([], "Plain");
19
20
  static cache = undefined;
20
21
  id;
21
- constructor(buildRoot, outputDir, usageLocations, handlePrefix) {
22
+ constructor(buildRoot, outputDir, usageLocations, handlePrefix, useUnifiedLoader) {
22
23
  this.buildRoot = buildRoot;
23
24
  this.outputDir = outputDir;
24
25
  this.usageLocations = usageLocations;
25
26
  this.handlePrefix = handlePrefix;
27
+ this.useUnifiedLoader = useUnifiedLoader;
26
28
  this.id = Math.random().toString();
27
29
  PlainEntrypointsConfigFileGeneratorPlugin.semaphore.register(this.id);
28
30
  UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.register(this.id);
@@ -40,11 +42,10 @@ class PlainEntrypointsConfigFileGeneratorPlugin {
40
42
  });
41
43
  compilation.hooks.processAssets.tapPromise(tapName, async (assets) => {
42
44
  try {
43
- const emitDir = node_path_1.default.join(this.buildRoot, this.outputDir);
44
45
  if (PlainEntrypointsConfigFileGeneratorPlugin.cache === undefined) {
45
46
  PlainEntrypointsConfigFileGeneratorPlugin.cache = { assets: [] };
46
47
  compilation.hooks.afterProcessAssets.tap(`${this.constructor.name}_CompileLoader`, () => {
47
- PlainEntrypointsConfigFileGeneratorPlugin.afterProcessAssets(compilation, emitDir);
48
+ this.afterProcessAssets(compilation);
48
49
  });
49
50
  }
50
51
  const rawAssetDataSource = assets["assets.json"]?.source();
@@ -113,7 +114,8 @@ class PlainEntrypointsConfigFileGeneratorPlugin {
113
114
  });
114
115
  });
115
116
  }
116
- static afterProcessAssets(compilation, emitDir) {
117
+ afterProcessAssets(compilation) {
118
+ const emitDir = node_path_1.default.join(this.buildRoot, this.outputDir);
117
119
  //TODO: Add support for editorStyles via the 'block_editor_settings_all' filter
118
120
  const handleLists = {
119
121
  register: [],
@@ -171,7 +173,9 @@ class PlainEntrypointsConfigFileGeneratorPlugin {
171
173
  }
172
174
  const writer = new php_writer_1.PHPWriter();
173
175
  if (handleLists.register.length > 0) {
174
- PlainEntrypointsConfigFileGeneratorPlugin.emitResolveBaseUriFunction(writer);
176
+ if (!this.useUnifiedLoader) {
177
+ PlainEntrypointsConfigFileGeneratorPlugin.emitResolveBaseUriFunction(writer);
178
+ }
175
179
  for (const [priority, prioritizedHandleList] of PlainEntrypointsConfigFileGeneratorPlugin.separateHandleListByPriority(handleLists.register)) {
176
180
  writer.action("init", writer => {
177
181
  writer.call("plaudit_webpack_extensions__resolve_base_uri", [new php_writer_1.Expr('__DIR__')], { assignTo: "$base_uri" });
@@ -1,11 +1,12 @@
1
1
  import { type Compiler, type WebpackPluginInstance } from "webpack";
2
2
  export declare class SpecialAssetHandlingPlugin implements WebpackPluginInstance {
3
3
  private readonly outputDir;
4
+ private readonly useUnifiedLoader;
4
5
  private static readonly semaphore;
5
6
  private static hasAttachedAssetCollatorForCurrentBatch;
6
7
  private static validPathname?;
7
8
  private readonly id;
8
- constructor(outputDir: string);
9
+ constructor(outputDir: string, useUnifiedLoader: boolean);
9
10
  apply(compiler: Compiler): void;
10
11
  private collateAssets;
11
12
  }
@@ -12,12 +12,14 @@ const webpack_1 = require("webpack");
12
12
  const UnifiedLoaderGenerator_1 = require("./UnifiedLoaderGenerator");
13
13
  class SpecialAssetHandlingPlugin {
14
14
  outputDir;
15
+ useUnifiedLoader;
15
16
  static semaphore = new pseduo_semaphore_1.PseudoSemaphore({}, "Special");
16
17
  static hasAttachedAssetCollatorForCurrentBatch = false;
17
18
  static validPathname = undefined;
18
19
  id;
19
- constructor(outputDir) {
20
+ constructor(outputDir, useUnifiedLoader) {
20
21
  this.outputDir = outputDir;
22
+ this.useUnifiedLoader = useUnifiedLoader;
21
23
  this.id = Math.random().toString();
22
24
  SpecialAssetHandlingPlugin.semaphore.register(this.id);
23
25
  UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.register(this.id);
@@ -85,7 +87,9 @@ class SpecialAssetHandlingPlugin {
85
87
  writer.emitAsset(compilation, outputFile);
86
88
  return;
87
89
  }
88
- PlainEntrypointsConfigFileGeneratorPlugin_1.PlainEntrypointsConfigFileGeneratorPlugin.emitResolveBaseUriFunction(writer);
90
+ if (!this.useUnifiedLoader) {
91
+ PlainEntrypointsConfigFileGeneratorPlugin_1.PlainEntrypointsConfigFileGeneratorPlugin.emitResolveBaseUriFunction(writer);
92
+ }
89
93
  writer.action("wp_head", writer => {
90
94
  writer.call("plaudit_webpack_extensions__resolve_base_uri", [new php_writer_1.Expr('__DIR__')], { assignTo: "$base_uri" }).closePHP();
91
95
  for (let [filename, { preload, fetchpriority, crossorigin }] of preloadedAssets) {
package/build/shared.d.ts CHANGED
@@ -69,6 +69,7 @@ export type PlauditWordpressWebpackConfig = {
69
69
  plainEntrypointsVersion?: 1 | 2;
70
70
  srcDir?: string;
71
71
  srcPrefixes?: string[];
72
+ useUnifiedLoader?: boolean;
72
73
  };
73
74
  export declare function makeEmittableConfigPHP(data: any): string;
74
75
  export type Sync<V> = {
@@ -169,7 +169,7 @@ function injectSupportForInliningSVGsAsStrings(rules) {
169
169
  });
170
170
  }
171
171
  function buildVerifiedConfig(config) {
172
- const { standaloneBlocks = false, stats = 'errors-warnings', variables: rawVariables, verbose = process.argv.includes('--verbose') || process.env['VERBOSE'] === 'true', postcss = {}, externals, assumeGlobalizedPlauditLibraries = true, processTranslationConfigs = true, combineAssetMetadata = true, useWebpackResourceFiltering = true, outputDir = "", extensionsVersion = 1, plainEntrypointsVersion = 1, srcDir = "" } = config;
172
+ const { standaloneBlocks = false, stats = 'errors-warnings', variables: rawVariables, verbose = process.argv.includes('--verbose') || process.env['VERBOSE'] === 'true', postcss = {}, externals, assumeGlobalizedPlauditLibraries = true, processTranslationConfigs = true, combineAssetMetadata = true, useWebpackResourceFiltering = true, outputDir = "", extensionsVersion = 1, plainEntrypointsVersion = 1, srcDir = "", useUnifiedLoader = false } = config;
173
173
  let srcPrefixes;
174
174
  const trailingSlashedSrcDir = srcDir && !srcDir.endsWith("/") ? srcDir + "/" : srcDir;
175
175
  if (config.srcPrefixes === undefined) {
@@ -238,7 +238,7 @@ function buildVerifiedConfig(config) {
238
238
  }
239
239
  const cfg = {
240
240
  currentVariables, postcss, standaloneBlocks, stats, variablesFilePath, verbose, externals, assumeGlobalizedPlauditLibraries, processTranslationConfigs, combineAssetMetadata,
241
- useWebpackResourceFiltering, outputDir, extensionsVersion, plainEntrypointsVersion, plainEntrypointsHandlePrefix, srcDir, srcPrefixes
241
+ useWebpackResourceFiltering, outputDir, extensionsVersion, plainEntrypointsVersion, plainEntrypointsHandlePrefix, srcDir, srcPrefixes, useUnifiedLoader
242
242
  };
243
243
  return cfg.outputDir ? { cfg, sources } : withDerivedOutputDir(cfg, sources);
244
244
  }
@@ -380,11 +380,11 @@ function buildCommonPluginConfig(srcRoot, scriptExtension, webpackConfig, dest,
380
380
  extensions: ['css', 'scss', 'sass', 'less', 'styl', 'pcss']
381
381
  });
382
382
  plugins.push(removeEmptyScriptsPlugin, new MiniCSSExtractPluginErrorCleaner_1.MiniCSSExtractPluginErrorCleaner());
383
- if (config.outputDir) {
383
+ if (config.useUnifiedLoader) {
384
384
  plugins.push(new UnifiedLoaderGenerator_1.UnifiedLoaderGenerator());
385
385
  }
386
386
  if (config.useWebpackResourceFiltering) {
387
- plugins.push(new SpecialAssetHandlingPlugin_1.SpecialAssetHandlingPlugin(config.outputDir));
387
+ plugins.push(new SpecialAssetHandlingPlugin_1.SpecialAssetHandlingPlugin(config.outputDir, config.useUnifiedLoader));
388
388
  }
389
389
  if (variablesFilePath) {
390
390
  plugins.push(new VariablesJSMonitorPlugin_1.VariablesJSMonitorPlugin(variablesFilePath));
@@ -520,7 +520,7 @@ function makePlainV1WebpackConfig(config, commonConfig, webpackConfig, dest, src
520
520
  return (0, common_config_helpers_1.commonMakeWebpackConfig)(config, commonConfig, webpackConfig, srcIsDirectory, dest, src, srcRoot, entry, plugins);
521
521
  }
522
522
  function makePlainV2WebpackConfig(config, commonConfig, webpackConfig, dest, src, srcRoot, plugins, srcIsDirectory) {
523
- plugins.push(new PlainEntrypointsConfigFileGeneratorPlugin_1.PlainEntrypointsConfigFileGeneratorPlugin(process.cwd(), config.outputDir, dest.locations ?? {}, config.plainEntrypointsHandlePrefix));
523
+ plugins.push(new PlainEntrypointsConfigFileGeneratorPlugin_1.PlainEntrypointsConfigFileGeneratorPlugin(process.cwd(), config.outputDir, dest.locations ?? {}, config.plainEntrypointsHandlePrefix, config.useUnifiedLoader));
524
524
  const baseDest = stripExtension(dest.destination);
525
525
  const entry = srcIsDirectory // This being true implies that srcRoot is not an array
526
526
  ? (0, common_config_helpers_1.resolveEntryFromDirectory)(commonConfig, srcRoot, dest)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "2.57.0",
3
+ "version": "2.57.2",
4
4
  "license": "UNLICENSED",
5
5
  "files": [
6
6
  "/build"
@@ -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.0",
66
+ "webpack": "^5.101.1",
67
67
  "webpack-remove-empty-scripts": "^1.1.1",
68
68
  "xml-formatter": "^3.6.6"
69
69
  },