@plaudit/webpack-extensions 2.42.4 → 2.43.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.
@@ -78,7 +78,7 @@ function makeDependencyExtractionPluginProps(externals, assumeGlobalizedPlauditL
78
78
  }
79
79
  }
80
80
  const PLAUDIT_NAMESPACE = '@plaudit/';
81
- const EXTERNALIZABLE_PLAUDIT_LIBRARIES = ['@plaudit/library-extensions'];
81
+ const EXTERNALIZABLE_PLAUDIT_LIBRARIES = ['@plaudit/frontend-apis', '@plaudit/library-extensions'];
82
82
  function plauditRequestToExternal(request) {
83
83
  if (EXTERNALIZABLE_PLAUDIT_LIBRARIES.includes(request)) {
84
84
  return ['plaudit', camelCaseDash(request.substring(PLAUDIT_NAMESPACE.length))];
@@ -7,6 +7,7 @@ interface AdvancedOutputConfig {
7
7
  additionalDependencies?: string[];
8
8
  directoryLayout?: 'blocks' | 'extensions' | 'plain';
9
9
  assumeGlobalizedPlauditLibraries?: boolean;
10
+ externalize?: string[] | Required<Configuration>['output']['library'];
10
11
  }
11
12
  type PlauditWordpressWebpackConfig = {
12
13
  standaloneBlocks?: boolean;
@@ -391,13 +391,15 @@ function processIndividualWebpackConfig(config, webpackConfig, sources) {
391
391
  }
392
392
  }
393
393
  }
394
- try {
395
- const wpmlFilePath = node_path_1.default.join(dir, "wpml-config.xml");
396
- await promises_1.default.access(wpmlFilePath);
397
- wpmlFiles.push(wpmlFilePath);
398
- }
399
- catch (e) {
400
- // This just means that the file doesn't exist
394
+ if (!processingModules) {
395
+ try {
396
+ const wpmlFilePath = node_path_1.default.join(dir, "wpml-config.xml");
397
+ await promises_1.default.access(wpmlFilePath);
398
+ wpmlFiles.push(wpmlFilePath);
399
+ }
400
+ catch (e) {
401
+ // This just means that the file doesn't exist
402
+ }
401
403
  }
402
404
  resolve([rawEntrypoints, wpmlFiles]);
403
405
  }));
@@ -422,14 +424,16 @@ function processIndividualWebpackConfig(config, webpackConfig, sources) {
422
424
  BlockJSONManagingPlugin_1.default.recordRawDependency(entry.lazyDependent, key);
423
425
  }
424
426
  }
425
- const wpmlEntrypointFiles = allEntrypoints.flatMap(e => e[1]);
426
- try {
427
- await promises_1.default.access(node_path_1.default.join(srcRoot, "wpml-config.xml"));
428
- currentEntry["wpml-config.xml"] = { import: [node_path_1.default.join(srcRoot, "wpml-config.xml"), ...wpmlEntrypointFiles] };
429
- }
430
- catch (e) {
431
- if (wpmlEntrypointFiles.length) {
432
- currentEntry["wpml-config.xml"] = { import: wpmlEntrypointFiles };
427
+ if (!processingModules) {
428
+ const wpmlEntrypointFiles = allEntrypoints.flatMap(e => e[1]);
429
+ try {
430
+ await promises_1.default.access(node_path_1.default.join(srcRoot, "wpml-config.xml"));
431
+ currentEntry["wpml-config.xml"] = { import: [node_path_1.default.join(srcRoot, "wpml-config.xml"), ...wpmlEntrypointFiles] };
432
+ }
433
+ catch (e) {
434
+ if (wpmlEntrypointFiles.length) {
435
+ currentEntry["wpml-config.xml"] = { import: wpmlEntrypointFiles };
436
+ }
433
437
  }
434
438
  }
435
439
  return currentEntry;
@@ -474,6 +478,30 @@ function processIndividualWebpackConfig(config, webpackConfig, sources) {
474
478
  }
475
479
  const distinctViableRoots = new Set();
476
480
  viableRoots = viableRoots.filter(value => distinctViableRoots.has(value) ? false : distinctViableRoots.add(value) && true);
481
+ let outputLibrary;
482
+ if (typeof dest === 'object' && dest.externalize) {
483
+ if (Array.isArray(dest.externalize) || typeof dest.externalize === 'string') {
484
+ outputLibrary = {
485
+ name: dest.externalize,
486
+ type: "assign"
487
+ };
488
+ }
489
+ else {
490
+ const originalLibrary = webpackConfig.output?.library;
491
+ if (originalLibrary && typeof originalLibrary === 'object' && !Array.isArray(originalLibrary)) {
492
+ outputLibrary = {
493
+ ...originalLibrary,
494
+ ...dest.externalize
495
+ };
496
+ }
497
+ else {
498
+ outputLibrary = dest.externalize;
499
+ }
500
+ }
501
+ }
502
+ else {
503
+ outputLibrary = webpackConfig.output?.library;
504
+ }
477
505
  return {
478
506
  ...webpackConfig,
479
507
  devtool: 'source-map',
@@ -482,7 +510,8 @@ function processIndividualWebpackConfig(config, webpackConfig, sources) {
482
510
  ...webpackConfig.output,
483
511
  path: outPath,
484
512
  chunkFilename: 'webpack-chunks/[id].js',
485
- publicPath: publicPath
513
+ publicPath: publicPath,
514
+ library: outputLibrary
486
515
  },
487
516
  module: {
488
517
  ...webpackConfig.module,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "2.42.4",
3
+ "version": "2.43.0",
4
4
  "license": "UNLICENSED",
5
5
  "scripts": {
6
6
  "prepublishOnly": "rm -rf build && mkdir build && tsc",
@@ -23,7 +23,7 @@
23
23
  "devDependencies": {
24
24
  "@plaudit/gutenberg-api-extensions": "^2.66.1",
25
25
  "@types/browser-sync-webpack-plugin": "^2.2.5",
26
- "@types/node": "^22.13.13",
26
+ "@types/node": "^22.14.0",
27
27
  "@types/postcss-functions": "^4.0.4",
28
28
  "@types/tapable": "^2.2.7",
29
29
  "@types/webpack": "^5.28.5",
@@ -38,16 +38,16 @@
38
38
  "@plaudit/postcss-silent-extend": "^3.0.0",
39
39
  "@plaudit/postcss-strip-units": "^3.0.0",
40
40
  "@plaudit/postcss-variables": "^1.1.0",
41
- "@wordpress/dependency-extraction-webpack-plugin": "^6.20.0",
42
- "@wordpress/scripts": "^30.13.0",
41
+ "@wordpress/dependency-extraction-webpack-plugin": "^6.21.0",
42
+ "@wordpress/scripts": "^30.14.1",
43
43
  "autoprefixer": "^10.4.21",
44
- "browser-sync": "^3.0.3",
44
+ "browser-sync": "^3.0.4",
45
45
  "clean-webpack-plugin": "^4.0.0",
46
46
  "copy-webpack-plugin": "^10.2.4",
47
47
  "cssnano": "^6.1.2",
48
48
  "eslint": "^8.57.1",
49
49
  "eslint-plugin-jsdoc": "^48.11.0",
50
- "fork-ts-checker-webpack-plugin": "^9.0.2",
50
+ "fork-ts-checker-webpack-plugin": "^9.0.3",
51
51
  "http-proxy-middleware": "^3.0.3",
52
52
  "json2php": "^0.0.12",
53
53
  "postcss": "^8.5.3",