@plaudit/webpack-extensions 2.62.3 → 2.63.1

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.
@@ -211,15 +211,17 @@ function buildVerifiedConfig(config) {
211
211
  const allocatedDestinations = {};
212
212
  const partiallyVerifiedSources = rawSources.map(rawSource => {
213
213
  const destination = rawSource[1].destination;
214
+ const locations = typeof rawSource[1].locations === 'string' || typeof rawSource[1].locations === 'function'
215
+ ? { handle: rawSource[1].locations } : rawSource[1].locations ?? {};
214
216
  if (destination !== undefined) {
215
217
  const effectiveDestination = toEffectiveWebpackDestination(destination);
216
218
  allocatedDestinations[effectiveDestination] = rawSource[0]; // We need to pre-populate the allocatedDestinations map with statically-declared destinations
217
- return [rawSource[0], { ...rawSource[1], destination, effectiveDestination, staticallyDeclaredDestination: true }];
219
+ return [rawSource[0], { ...rawSource[1], locations, destination, effectiveDestination, staticallyDeclaredDestination: true }];
218
220
  }
219
221
  else {
220
222
  const naiveDestination = deriveNaiveDestinationFromUnverifiedSourceEntry(rawSource, srcPrefixes);
221
223
  const effectiveDestination = toEffectiveWebpackDestination(naiveDestination);
222
- return [rawSource[0], { ...rawSource[1], destination: naiveDestination, effectiveDestination, staticallyDeclaredDestination: false }];
224
+ return [rawSource[0], { ...rawSource[1], locations, destination: naiveDestination, effectiveDestination, staticallyDeclaredDestination: false }];
223
225
  }
224
226
  });
225
227
  const dynamicEffectiveDestinationsWithExpectedNaiveDuplicates = partiallyVerifiedSources
@@ -482,31 +484,47 @@ function processIndividualWebpackConfig(config, webpackConfig, sources) {
482
484
  }
483
485
  function makeBlocksWebpackConfig(config, commonConfig, webpackConfig, dest, src, srcRoot, plugins) {
484
486
  const { processingModules } = commonConfig;
485
- const blockJSONManagingPlugin = new PlainEntrypointsStyleBlockJSONPlugin_1.PlainEntrypointsStyleBlockJSONPlugin(config, dest.destination, plugins.find(p => p instanceof webpack_remove_empty_scripts_1.default));
487
+ const blockJSONManagingPlugin = new PlainEntrypointsStyleBlockJSONPlugin_1.PlainEntrypointsStyleBlockJSONPlugin(config, dest.destination, plugins.find(p => p instanceof webpack_remove_empty_scripts_1.default), webpackConfig.context ?? process.cwd(), (0, common_config_helpers_1.resolveEntryFromDirectory)(commonConfig, srcRoot, dest));
486
488
  plugins.push(blockJSONManagingPlugin);
487
489
  if (config.processTranslationConfigs && !processingModules) {
488
490
  plugins.push(new WPMLConfigBuilder_1.WPMLConfigBuilderPlugin(dest.destination));
489
491
  }
490
- return (0, common_config_helpers_1.commonMakeWebpackConfig)(config, commonConfig, webpackConfig, true, dest, src, srcRoot, (0, common_config_helpers_1.resolveEntryFromDirectory)(commonConfig, srcRoot, dest), plugins);
492
+ return (0, common_config_helpers_1.commonMakeWebpackConfig)(config, commonConfig, webpackConfig, true, dest, src, srcRoot, {}, plugins);
491
493
  }
492
494
  function makeExtensionsWebpackConfig(config, commonConfig, webpackConfig, dest, src, srcRoot, plugins) {
493
- const plugin = config.extensionsVersion > 1
494
- ? new ExtensionsConfigFileGeneratorPlugin_1.ExtensionsConfigFileGeneratorPlugin(config, srcRoot, dest.destination)
495
- : new ExtensionsConfigFileGeneratorPluginV1_1.ExtensionsConfigFileGeneratorPluginV1(dest.destination);
496
- plugins.push(plugin);
497
- const entry = async () => {
498
- const rawEntrypoints = [];
499
- for await (const dirent of await promises_1.default.opendir(srcRoot)) {
500
- if (dirent.isFile() && !dirent.name.startsWith("~")) {
501
- if (commonConfig.scriptExtension.test(dirent.name) || shared_1.styleExtension.test(dirent.name)) {
502
- const file = (0, common_config_helpers_1.joinPossiblyAbsolutePaths)(srcRoot, dirent.name);
503
- rawEntrypoints.push([node_path_1.default.join(dest.destination, node_path_1.default.basename(file, node_path_1.default.extname(file))), { import: file, library: { type: plugin.libraryType } }]);
495
+ if (config.extensionsVersion > 1) {
496
+ const entry = async () => {
497
+ const rawEntrypoints = [];
498
+ for await (const dirent of await promises_1.default.opendir(srcRoot)) {
499
+ if (dirent.isFile() && !dirent.name.startsWith("~")) {
500
+ if (commonConfig.scriptExtension.test(dirent.name) || shared_1.styleExtension.test(dirent.name)) {
501
+ const file = (0, common_config_helpers_1.joinPossiblyAbsolutePaths)(srcRoot, dirent.name);
502
+ rawEntrypoints.push([node_path_1.default.join(dest.destination, node_path_1.default.basename(file, node_path_1.default.extname(file))), { import: [file], plauditMetadata: "entrypoint-v2" }]);
503
+ }
504
504
  }
505
505
  }
506
- }
507
- return Object.fromEntries(rawEntrypoints);
508
- };
509
- return (0, common_config_helpers_1.commonMakeWebpackConfig)(config, commonConfig, webpackConfig, true, dest, src, srcRoot, entry, plugins);
506
+ return Object.fromEntries(rawEntrypoints);
507
+ };
508
+ plugins.push(new ExtensionsConfigFileGeneratorPlugin_1.ExtensionsConfigFileGeneratorPlugin(config, srcRoot, dest, webpackConfig.context ?? process.cwd(), entry));
509
+ return (0, common_config_helpers_1.commonMakeWebpackConfig)(config, commonConfig, webpackConfig, true, dest, src, srcRoot, {}, plugins);
510
+ }
511
+ else {
512
+ const plugin = new ExtensionsConfigFileGeneratorPluginV1_1.ExtensionsConfigFileGeneratorPluginV1(dest.destination);
513
+ plugins.push(plugin);
514
+ const entry = async () => {
515
+ const rawEntrypoints = [];
516
+ for await (const dirent of await promises_1.default.opendir(srcRoot)) {
517
+ if (dirent.isFile() && !dirent.name.startsWith("~")) {
518
+ if (commonConfig.scriptExtension.test(dirent.name) || shared_1.styleExtension.test(dirent.name)) {
519
+ const file = (0, common_config_helpers_1.joinPossiblyAbsolutePaths)(srcRoot, dirent.name);
520
+ rawEntrypoints.push([node_path_1.default.join(dest.destination, node_path_1.default.basename(file, node_path_1.default.extname(file))), file]);
521
+ }
522
+ }
523
+ }
524
+ return Object.fromEntries(rawEntrypoints);
525
+ };
526
+ return (0, common_config_helpers_1.commonMakeWebpackConfig)(config, commonConfig, webpackConfig, true, dest, src, srcRoot, entry, plugins);
527
+ }
510
528
  }
511
529
  function makePlainV1WebpackConfig(config, commonConfig, webpackConfig, dest, src, srcRoot, plugins, srcIsDirectory) {
512
530
  const baseDest = stripExtension(dest.destination);
@@ -516,13 +534,13 @@ function makePlainV1WebpackConfig(config, commonConfig, webpackConfig, dest, src
516
534
  return (0, common_config_helpers_1.commonMakeWebpackConfig)(config, commonConfig, webpackConfig, srcIsDirectory, dest, src, srcRoot, entry, plugins);
517
535
  }
518
536
  function makePlainV2WebpackConfig(config, commonConfig, webpackConfig, dest, src, srcRoot, plugins, srcIsDirectory) {
519
- const locations = typeof dest.locations === 'string' ? { handle: dest.locations } : dest.locations ?? {};
520
- plugins.push(new PlainEntrypointsConfigFileGeneratorPlugin_1.PlainEntrypointsConfigFileGeneratorPlugin(process.cwd(), config.outputDir, locations, config.plainEntrypointsHandlePrefix, config.useUnifiedLoader));
521
537
  const baseDest = stripExtension(dest.destination);
522
538
  const entry = srcIsDirectory // This being true implies that srcRoot is not an array
523
539
  ? (0, common_config_helpers_1.resolveEntryFromDirectory)(commonConfig, srcRoot, dest)
524
- : () => ({ [baseDest]: srcRoot });
525
- return (0, common_config_helpers_1.commonMakeWebpackConfig)(config, commonConfig, webpackConfig, srcIsDirectory, dest, src, srcRoot, entry, plugins);
540
+ : () => ({ [baseDest]: { import: Array.isArray(srcRoot) ? srcRoot : [srcRoot], plauditMetadata: "plain-entrypoint" } });
541
+ const requester = new PlainEntrypointsConfigFileGeneratorPlugin_1.PlainEntrypointsConfigFileGeneratorPlugin(process.cwd(), config.outputDir, dest.locations, config.plainEntrypointsHandlePrefix, config.useUnifiedLoader, webpackConfig.context ?? process.cwd(), entry);
542
+ plugins.push(requester);
543
+ return (0, common_config_helpers_1.commonMakeWebpackConfig)(config, commonConfig, webpackConfig, srcIsDirectory, dest, src, srcRoot, {}, plugins);
526
544
  }
527
545
  function stripExtension(filepath) {
528
546
  return node_path_1.default.join(node_path_1.default.dirname(filepath), node_path_1.default.basename(filepath, node_path_1.default.extname(filepath)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "2.62.3",
3
+ "version": "2.63.1",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
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.29.0",
39
- "@wordpress/scripts": "^30.22.0",
38
+ "@wordpress/dependency-extraction-webpack-plugin": "^6.30.0",
39
+ "@wordpress/scripts": "^30.23.0",
40
40
  "autoprefixer": "^10.4.21",
41
41
  "browser-sync": "^3.0.4",
42
42
  "clean-webpack-plugin": "^4.0.0",