@plaudit/webpack-extensions 2.78.1 → 2.79.0

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.
@@ -15,7 +15,7 @@ export declare class UnifiedLoaderGenerator extends AbstractBiPhasicGroupPlugin
15
15
  constructor(config: VerifiedPlauditWordpressWebpackConfig);
16
16
  protected attachStandardPhase(compilation: Compilation): void;
17
17
  protected attachUniquePhase(compilation: Compilation): void;
18
- private static withDistDevLoader;
19
- private static ensureDistExists;
18
+ private withDistDevLoader;
19
+ private ensureDistExists;
20
20
  }
21
21
  export {};
@@ -93,11 +93,11 @@ class UnifiedLoaderGenerator extends AbstractBiPhasicGroupPlugin_1.AbstractBiPha
93
93
  let writer;
94
94
  if (compilation.outputOptions.path?.endsWith("-dev")) {
95
95
  compilation['.gitignore' in compilation.assets ? 'updateAsset' : 'emitAsset']('.gitignore', new webpack_1.sources.RawSource('**'), { size: 2 });
96
- UnifiedLoaderGenerator.ensureDistExists(compilation.outputOptions.path);
96
+ this.ensureDistExists(compilation.outputOptions.path);
97
97
  writer = new php_writer_1.PHPWriter();
98
98
  }
99
99
  else {
100
- writer = UnifiedLoaderGenerator.withDistDevLoader();
100
+ writer = this.withDistDevLoader();
101
101
  }
102
102
  if (groupedLoaderInfo.some(wc => wc.requiresBaseURI)) {
103
103
  (0, shared_1.emitResolveBaseUriFunction)(writer);
@@ -110,7 +110,10 @@ class UnifiedLoaderGenerator extends AbstractBiPhasicGroupPlugin_1.AbstractBiPha
110
110
  }
111
111
  });
112
112
  }
113
- static withDistDevLoader() {
113
+ withDistDevLoader() {
114
+ if (this.config.omitDistDev) {
115
+ return new php_writer_1.PHPWriter();
116
+ }
114
117
  const devLoaderPath = expressions_1.Op.concat(expressions_1.Constants.__DIR__, '-dev/unified-loader.php');
115
118
  return new php_writer_1.PHPWriter()
116
119
  .if(expressions_1.Op.binary(expressions_1.Op.binary(expressions_1.Expr.call('wp_get_environment_type', []), ' === ', 'development'), ' && ', expressions_1.Expr.call('file_exists', [devLoaderPath])))
@@ -118,19 +121,19 @@ class UnifiedLoaderGenerator extends AbstractBiPhasicGroupPlugin_1.AbstractBiPha
118
121
  .append("return;")
119
122
  .endIf();
120
123
  }
121
- static async ensureDistExists(outputPath) {
124
+ async ensureDistExists(outputPath) {
122
125
  if (outputPath.endsWith("-dev")) {
123
126
  outputPath = outputPath.substring(0, outputPath.length - 4);
124
127
  }
125
128
  try {
126
129
  const contents = await (0, promises_1.readFile)((0, node_path_1.join)(outputPath, "unified-loader.php"), 'utf-8');
127
130
  if (!contents.includes("-dev/unified-loader.php")) {
128
- await (0, promises_1.writeFile)((0, node_path_1.join)(outputPath, "unified-loader.php"), UnifiedLoaderGenerator.withDistDevLoader().toString() + contents.substring(5), 'utf-8');
131
+ await (0, promises_1.writeFile)((0, node_path_1.join)(outputPath, "unified-loader.php"), this.withDistDevLoader().toString() + contents.substring(5), 'utf-8');
129
132
  }
130
133
  }
131
134
  catch {
132
135
  await (0, promises_1.mkdir)(outputPath, { recursive: true });
133
- await (0, promises_1.writeFile)((0, node_path_1.join)(outputPath, "unified-loader.php"), UnifiedLoaderGenerator.withDistDevLoader().toString(), 'utf-8');
136
+ await (0, promises_1.writeFile)((0, node_path_1.join)(outputPath, "unified-loader.php"), this.withDistDevLoader().toString(), 'utf-8');
134
137
  }
135
138
  }
136
139
  }
package/build/shared.d.ts CHANGED
@@ -108,6 +108,7 @@ export type PlauditWordpressWebpackConfig = {
108
108
  srcPrefixes?: string[];
109
109
  useUnifiedLoader?: boolean;
110
110
  includePostInitFallback?: boolean;
111
+ omitDistDev?: boolean;
111
112
  };
112
113
  export type FileSegmentBlockEntrypointInfo = {
113
114
  blockJsonOrigin: string;
@@ -105,7 +105,7 @@ function injectPostcssConfigOverrides(rules, config, variables, postcssFunctions
105
105
  }
106
106
  }
107
107
  }
108
- if (rule.test instanceof RegExp && (rule.test.test("index.ts") || rule.test.test("index.mts"))) { // Then this is the javascript and typescript rule
108
+ if (rule.test instanceof RegExp && (rule.test.test("index.ts") || rule.test.test("index.mts"))) { // Then this is the JavaScript and TypeScript rule
109
109
  rule.test = /\.m?[jt]sx?$/; // This hacks in support for mjs and mts files
110
110
  }
111
111
  }
@@ -157,9 +157,9 @@ function injectSupportForInliningSVGsAsStrings(rules) {
157
157
  });
158
158
  }
159
159
  function buildVerifiedConfig(config) {
160
- 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, plainEntrypointsVersion = 1, srcDir = "", useUnifiedLoader = false, includePostInitFallback = false } = config;
160
+ 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, plainEntrypointsVersion = 1, srcDir = "", useUnifiedLoader = false, includePostInitFallback = false, omitDistDev = false } = config;
161
161
  let outputDir = config.outputDir ?? "";
162
- if (outputDir && useUnifiedLoader && (process.env['SERVER_MODE'] ?? 'development') === 'development') {
162
+ if (outputDir && useUnifiedLoader && !omitDistDev && (process.env['SERVER_MODE'] ?? 'development') === 'development') {
163
163
  outputDir += "-dev";
164
164
  }
165
165
  let srcPrefixes;
@@ -209,7 +209,7 @@ function buildVerifiedConfig(config) {
209
209
  }
210
210
  const cfg = {
211
211
  currentVariables, postcss, standaloneBlocks, stats, variablesFilePath, verbose, externals, assumeGlobalizedPlauditLibraries, processTranslationConfigs, combineAssetMetadata,
212
- useWebpackResourceFiltering, outputDir, extensionsVersion, plainEntrypointsVersion, srcDir, srcPrefixes, targetHandlePrefix, useUnifiedLoader, includePostInitFallback
212
+ useWebpackResourceFiltering, outputDir, extensionsVersion, plainEntrypointsVersion, srcDir, srcPrefixes, targetHandlePrefix, useUnifiedLoader, includePostInitFallback, omitDistDev
213
213
  };
214
214
  // Destination -> source map
215
215
  const allocatedDestinations = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "2.78.1",
3
+ "version": "2.79.0",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "files": [
6
6
  "/build"