@plaudit/webpack-extensions 2.46.0 → 2.48.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.
package/README.md CHANGED
@@ -2,12 +2,6 @@
2
2
  To test locally, either set up yarn to pull from this folder or (ideally) build and copy the resulting built files into another project for testing purposes.
3
3
 
4
4
  # To Deploy
5
- If you haven't
6
5
  ```
7
- yarn global add genversion
8
- ```
9
-
10
- To deploy
11
- ```
12
- ./publish.sh y
6
+ publish-pnpm-package
13
7
  ```
@@ -0,0 +1,11 @@
1
+ export type SharedCache = {
2
+ specialAssets?: {
3
+ files: {
4
+ [k: string]: {
5
+ preload?: true;
6
+ fetchpriority?: string | null;
7
+ crossorigin?: string | null;
8
+ };
9
+ };
10
+ };
11
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ import { Compiler, WebpackPluginInstance } from "webpack";
2
+ import { SharedCache } from "../shared";
3
+ export default class SpecialAssetHandlingPlugin implements WebpackPluginInstance {
4
+ private readonly cache;
5
+ constructor(cache: SharedCache);
6
+ apply(compiler: Compiler): void;
7
+ }
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_path_1 = __importDefault(require("node:path"));
7
+ const webpack_1 = require("webpack");
8
+ class SpecialAssetHandlingPlugin {
9
+ cache;
10
+ constructor(cache) {
11
+ this.cache = cache;
12
+ }
13
+ apply(compiler) {
14
+ compiler.hooks.compilation.tap(this.constructor.name, compilation => {
15
+ this.cache.specialAssets = undefined;
16
+ compilation.hooks.processAssets.tap(this.constructor.name, assets => {
17
+ for (const pathname of Object.keys(assets)) {
18
+ const assetInfo = compilation.assetsInfo.get(pathname);
19
+ if (!assetInfo?.sourceFilename) {
20
+ continue;
21
+ }
22
+ const queryStart = assetInfo.sourceFilename.indexOf('?');
23
+ if (queryStart < 0) {
24
+ continue;
25
+ }
26
+ const params = new URLSearchParams(assetInfo.sourceFilename.substring(queryStart + 1)
27
+ .replace(/(?:fetchPriority|crossOrigin)=/gi, str => str.toLowerCase()) //This ensures consistent capitalization of the fetchPriority parameter
28
+ );
29
+ if (this.cache.specialAssets === undefined) {
30
+ this.cache.specialAssets = { files: {} };
31
+ const outputFile = node_path_1.default.join(node_path_1.default.dirname(node_path_1.default.dirname(pathname)), "special-assets.php");
32
+ compilation.hooks.afterProcessAssets.tap(`${this.constructor.name}_GeneratePreloadingFile`, () => {
33
+ if (!this.cache.specialAssets?.files) {
34
+ return;
35
+ }
36
+ const hookTextLines = [
37
+ "<?php",
38
+ "add_action('wp_head', function() {",
39
+ "\tif (str_starts_with(__DIR__, ABSPATH)) {",
40
+ "\t\t$path = ltrim(substr(__DIR__, strlen(ABSPATH)), '/');",
41
+ "\t} else if (str_starts_with(__DIR__, '/workspace/website')) {",
42
+ "\t\t$path = ltrim(substr(__DIR__, 18), '/');",
43
+ "\t} else {",
44
+ "\t\terror_log('UNABLE TO FIGURE OUT WHAT THE RELATIVE PATH TO THE FONT DIRECTORY SHOULD BE');",
45
+ "\t\treturn;",
46
+ "\t}",
47
+ "\t$base_uri = trailingslashit(home_url($path));",
48
+ "\t?>"
49
+ ];
50
+ const preloadedFonts = Object.entries(this.cache.specialAssets.files)
51
+ .filter(([_, { preload }]) => preload)
52
+ .sort(([a], [b]) => a.localeCompare(b));
53
+ for (let [filename, { preload, fetchpriority, crossorigin }] of preloadedFonts) {
54
+ if (!preload) {
55
+ continue;
56
+ }
57
+ let fileExtension = node_path_1.default.extname(filename);
58
+ if (fileExtension.startsWith(".")) {
59
+ fileExtension = fileExtension.substring(1).toLowerCase();
60
+ }
61
+ else {
62
+ fileExtension = fileExtension.toLowerCase();
63
+ }
64
+ const attributes = [];
65
+ if (["woff", "woff2", "ttf", "otf", "eot"].includes(fileExtension)) {
66
+ if (!crossorigin) {
67
+ crossorigin = "anonymous";
68
+ }
69
+ attributes.push(["as", "font"], ["type", `font/${fileExtension}`]);
70
+ }
71
+ else if (fileExtension === "svg") {
72
+ attributes.push(["as", "image"], ["type", `image/svg+xml`]);
73
+ }
74
+ else if (fileExtension === "jpeg" || fileExtension === "jpg") {
75
+ attributes.push(["as", "image"], ["type", `image/jpeg`]);
76
+ }
77
+ else if (["png", "webp", "avif", "gif", "bmp"].includes(fileExtension)) {
78
+ attributes.push(["as", "image"], ["type", `image/${fileExtension}`]);
79
+ }
80
+ else {
81
+ compilation.errors.push(new Error(`Encountered preloading markup on an unsupported file extension (${fileExtension}). Full resource path: ${assetInfo.sourceFilename}`));
82
+ continue;
83
+ }
84
+ if (fetchpriority && fetchpriority !== 'auto') {
85
+ attributes.push(["fetchpriority", fetchpriority]);
86
+ }
87
+ if (crossorigin || crossorigin === "") {
88
+ attributes.push(["crossorigin", crossorigin]);
89
+ }
90
+ const dynamicAttrs = attributes.map(([k, v]) => v ? `${k}="${v}"` : k).join(" ");
91
+ hookTextLines.push(`\t<link rel="preload" href="<?= esc_url($base_uri.'${filename}') ?>" ${dynamicAttrs}>`);
92
+ }
93
+ hookTextLines.push("\t<?php", "});\n");
94
+ compilation.emitAsset(outputFile, new webpack_1.sources.RawSource(hookTextLines.join("\n")));
95
+ });
96
+ }
97
+ const filename = node_path_1.default.join(node_path_1.default.basename(node_path_1.default.dirname(pathname)), node_path_1.default.basename(pathname));
98
+ if (params.has("preload")) {
99
+ this.cache.specialAssets.files[filename] = { preload: true, fetchpriority: params.get("fetchpriority"), crossorigin: params.get("crossorigin") };
100
+ }
101
+ }
102
+ });
103
+ });
104
+ }
105
+ }
106
+ exports.default = SpecialAssetHandlingPlugin;
@@ -1,4 +1,5 @@
1
1
  import DependencyExtractionWebpackPlugin from "@wordpress/dependency-extraction-webpack-plugin";
2
+ import type { Configuration } from "webpack";
2
3
  export type IndividualExternalDepConfig = string | {
3
4
  import?: string | [string, ...string[]];
4
5
  handle: string;
@@ -6,7 +7,7 @@ export type IndividualExternalDepConfig = string | {
6
7
  export type Externals = {
7
8
  [dep: string]: IndividualExternalDepConfig;
8
9
  };
9
- export declare function makeDependencyExtractionPlugin(externals: Externals | undefined, assumeGlobalizedPlauditLibraries: boolean, wantsGroupedDepData: boolean): {
10
+ export declare function makeDependencyExtractionPlugin(externals: Externals | undefined, assumeGlobalizedPlauditLibraries: boolean, wantsGroupedDepData: boolean, externalizing: Required<Configuration>['output']['library']): {
10
11
  instance: DependencyExtractionWebpackPlugin;
11
12
  addExternalizedDep: (dep: string) => void;
12
13
  };
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.makeDependencyExtractionPlugin = makeDependencyExtractionPlugin;
7
7
  const dependency_extraction_webpack_plugin_1 = __importDefault(require("@wordpress/dependency-extraction-webpack-plugin"));
8
- function makeDependencyExtractionPlugin(externals, assumeGlobalizedPlauditLibraries, wantsGroupedDepData) {
9
- const baseProps = makeDependencyExtractionPluginProps(externals, assumeGlobalizedPlauditLibraries);
8
+ function makeDependencyExtractionPlugin(externals, assumeGlobalizedPlauditLibraries, wantsGroupedDepData, externalizing) {
9
+ const baseProps = makeDependencyExtractionPluginProps(externals, assumeGlobalizedPlauditLibraries, externalizing);
10
10
  const instance = new dependency_extraction_webpack_plugin_1.default(wantsGroupedDepData ? { ...baseProps, outputFormat: "json", combineAssets: true } : baseProps);
11
11
  return {
12
12
  instance,
@@ -15,11 +15,11 @@ function makeDependencyExtractionPlugin(externals, assumeGlobalizedPlauditLibrar
15
15
  }
16
16
  };
17
17
  }
18
- function makeDependencyExtractionPluginProps(externals, assumeGlobalizedPlauditLibraries) {
18
+ function makeDependencyExtractionPluginProps(externals, assumeGlobalizedPlauditLibraries, externalizing) {
19
19
  if (!externals) {
20
20
  if (assumeGlobalizedPlauditLibraries) {
21
21
  return {
22
- requestToExternal: plauditRequestToExternal,
22
+ requestToExternal: plauditRequestToExternal(externalizing),
23
23
  requestToHandle: plauditRequestToHandle
24
24
  };
25
25
  }
@@ -38,11 +38,11 @@ function makeDependencyExtractionPluginProps(externals, assumeGlobalizedPlauditL
38
38
  }
39
39
  const resolvePossibleExternal = (request) => {
40
40
  if (request in exactExternals) {
41
- return exactExternals[request];
41
+ return handleExternalizingEqualsPossibleExternal(exactExternals[request], externalizing);
42
42
  }
43
43
  for (const [key, value] of suffixExternals) {
44
44
  if (request.endsWith(key)) {
45
- return value;
45
+ return handleExternalizingEqualsPossibleExternal(value, externalizing);
46
46
  }
47
47
  }
48
48
  return undefined;
@@ -66,7 +66,7 @@ function makeDependencyExtractionPluginProps(externals, assumeGlobalizedPlauditL
66
66
  };
67
67
  if (assumeGlobalizedPlauditLibraries) {
68
68
  return {
69
- requestToExternal: curryRequestHandlers(baselineRequestToExternal, plauditRequestToExternal),
69
+ requestToExternal: curryRequestHandlers(baselineRequestToExternal, plauditRequestToExternal(externalizing)),
70
70
  requestToHandle: curryRequestHandlers(baselineRequestToHandle, plauditRequestToHandle),
71
71
  };
72
72
  }
@@ -77,16 +77,29 @@ function makeDependencyExtractionPluginProps(externals, assumeGlobalizedPlauditL
77
77
  };
78
78
  }
79
79
  }
80
- const PLAUDIT_NAMESPACE = '@plaudit/';
81
- const EXTERNALIZABLE_PLAUDIT_LIBRARIES = ['@plaudit/frontend-apis', '@plaudit/library-extensions'];
82
- function plauditRequestToExternal(request) {
83
- if (EXTERNALIZABLE_PLAUDIT_LIBRARIES.includes(request)) {
84
- return ['plaudit', camelCaseDash(request.substring(PLAUDIT_NAMESPACE.length))];
80
+ function firstLayersEqual(first, second) {
81
+ if (first.length !== second.length) {
82
+ return false;
85
83
  }
86
- else if (request.startsWith('@plaudit/gutenberg-api-extensions')) {
87
- return ['plaudit', 'gutenbergApiExtensions'];
84
+ for (let i = 0; i < first.length; i++) {
85
+ if (first[i] !== second[i]) {
86
+ return false;
87
+ }
88
88
  }
89
- return undefined;
89
+ return true;
90
+ }
91
+ const PLAUDIT_NAMESPACE = '@plaudit/';
92
+ const EXTERNALIZABLE_PLAUDIT_LIBRARIES = ['@plaudit/frontend-apis', '@plaudit/library-extensions'];
93
+ function plauditRequestToExternal(ext) {
94
+ return function (request) {
95
+ if (EXTERNALIZABLE_PLAUDIT_LIBRARIES.includes(request)) {
96
+ return handleExternalizingEqualsPossibleExternal({ import: ['plaudit', camelCaseDash(request.substring(PLAUDIT_NAMESPACE.length))], handle: "" }, ext)?.import;
97
+ }
98
+ else if (request.startsWith('@plaudit/gutenberg-api-extensions')) {
99
+ return handleExternalizingEqualsPossibleExternal({ import: ['plaudit', 'gutenbergApiExtensions'], handle: "" }, ext)?.import;
100
+ }
101
+ return undefined;
102
+ };
90
103
  }
91
104
  function plauditRequestToHandle(request) {
92
105
  if (EXTERNALIZABLE_PLAUDIT_LIBRARIES.includes(request)) {
@@ -106,3 +119,39 @@ function curryRequestHandlers(primary, secondary) {
106
119
  function camelCaseDash(string) {
107
120
  return string.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
108
121
  }
122
+ function handleExternalizingEqualsPossibleExternal(possibleExternal, ext) {
123
+ if (!ext || !possibleExternal) {
124
+ return possibleExternal;
125
+ }
126
+ const possibleImport = typeof possibleExternal === 'string' ? possibleExternal : possibleExternal['import'];
127
+ if (!possibleImport) {
128
+ return possibleExternal;
129
+ }
130
+ if (typeof ext === 'string') {
131
+ if (typeof possibleImport === 'string') {
132
+ return ext !== possibleImport ? possibleExternal : undefined;
133
+ }
134
+ else {
135
+ return possibleImport.length !== 1 || ext !== possibleImport[0] ? possibleExternal : undefined;
136
+ }
137
+ }
138
+ else if (Array.isArray(ext)) {
139
+ if (typeof possibleImport === 'string') {
140
+ return ext.length !== 1 || ext[0] !== possibleImport ? possibleExternal : undefined;
141
+ }
142
+ else {
143
+ return !firstLayersEqual(ext, possibleImport) ? possibleExternal : undefined;
144
+ }
145
+ }
146
+ else if ('name' in ext) {
147
+ return handleExternalizingEqualsPossibleExternal(possibleExternal, ext.name);
148
+ }
149
+ else {
150
+ for (const key of ['amd', 'commonjs', 'root']) {
151
+ if (key in ext && handleExternalizingEqualsPossibleExternal(possibleExternal, ext[key])) {
152
+ return undefined;
153
+ }
154
+ }
155
+ }
156
+ return possibleExternal;
157
+ }
@@ -7,7 +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
+ externalize?: Required<Configuration>['output']['library'];
11
11
  }
12
12
  type PlauditWordpressWebpackConfig = {
13
13
  standaloneBlocks?: boolean;
@@ -22,6 +22,7 @@ type PlauditWordpressWebpackConfig = {
22
22
  assumeGlobalizedPlauditLibraries?: boolean;
23
23
  processTranslationConfigs?: boolean;
24
24
  combineAssetMetadata?: boolean;
25
+ useWebpackResourceFiltering?: boolean;
25
26
  };
26
27
  declare const _default: (config: PlauditWordpressWebpackConfig, webpackConfig?: Configuration[] | Configuration) => Configuration[];
27
28
  export = _default;
@@ -9,6 +9,7 @@ const AdditionalDependencyInjectorPlugin_1 = __importDefault(require("./wordpres
9
9
  const BlockJSONManagingPlugin_1 = __importDefault(require("./wordpress-scripts-wrapper/BlockJSONManagingPlugin"));
10
10
  const dependency_extraction_webpack_plugin_config_builder_1 = require("./wordpress-scripts-wrapper/dependency-extraction-webpack-plugin-config-builder");
11
11
  const ExtensionsConfigFileGeneratorPlugin_1 = __importDefault(require("./wordpress-scripts-wrapper/ExtensionsConfigFileGeneratorPlugin"));
12
+ const SpecialAssetHandlingPlugin_1 = __importDefault(require("./wordpress-scripts-wrapper/SpecialAssetHandlingPlugin"));
12
13
  const MiniCSSExtractPluginErrorCleaner_1 = __importDefault(require("./wordpress-scripts-wrapper/MiniCSSExtractPluginErrorCleaner"));
13
14
  const VariablesJSMonitorPlugin_1 = __importDefault(require("./wordpress-scripts-wrapper/VariablesJSMonitorPlugin"));
14
15
  const BrowserSyncPlugin_1 = require("./wordpress-scripts-wrapper/BrowserSyncPlugin");
@@ -130,35 +131,38 @@ function testForDuplicatedEntryPaths(config) {
130
131
  process.exit(1);
131
132
  }
132
133
  }
133
- function replaceDefaultURLProcessing(rules) {
134
- const cssLoader = require.resolve('css-loader');
135
- if (cssLoader) {
136
- return rules.map(rule => {
137
- if (rule && typeof rule === 'object' && "use" in rule && Array.isArray(rule.use)) {
138
- return {
139
- ...rule,
140
- use: rule.use.map(useElement => {
141
- if (useElement && typeof useElement === 'object' && useElement.loader === cssLoader && typeof useElement.options === 'object') {
142
- return {
143
- ...useElement,
144
- options: {
145
- ...useElement.options,
146
- url: {
147
- filter(url) {
148
- return !url.startsWith("/") && !!url.match(/\.(woff|woff2|eot|ttf|otf|png|jpe?g|svg|webp|avif|gif)[^.]*?(\?.*)?/i);
134
+ function replaceDefaultURLProcessing(useWebpackResourceFiltering) {
135
+ return (rules) => {
136
+ const cssLoader = require.resolve('css-loader');
137
+ if (cssLoader) {
138
+ return rules.map(rule => {
139
+ if (rule && typeof rule === 'object' && "use" in rule && Array.isArray(rule.use)) {
140
+ return {
141
+ ...rule,
142
+ use: rule.use.map(useElement => {
143
+ if (useElement && typeof useElement === 'object' && useElement.loader === cssLoader && typeof useElement.options === 'object') {
144
+ return {
145
+ ...useElement,
146
+ options: {
147
+ ...useElement.options,
148
+ url: {
149
+ filter(url) {
150
+ return (useWebpackResourceFiltering || !url.startsWith("/"))
151
+ && !!url.match(/\.(woff2?|eot|ttf|otf|png|jpe?g|svg|webp|avif|gif|bmp)[^.]*?(\?.*)?/i);
152
+ }
149
153
  }
150
154
  }
151
- }
152
- };
153
- }
154
- return useElement;
155
- })
156
- };
157
- }
158
- return rule;
159
- });
160
- }
161
- return rules;
155
+ };
156
+ }
157
+ return useElement;
158
+ })
159
+ };
160
+ }
161
+ return rule;
162
+ });
163
+ }
164
+ return rules;
165
+ };
162
166
  }
163
167
  function injectPostcssConfigOverrides(rules, variables, postcssFunctionsConfig, verbose) {
164
168
  const postcssConfig = (0, static_configs_1.postcssConfigBuilder)(verbose, name => variables(name) ?? (name === 'ENV' ? '' : undefined), postcssFunctionsConfig);
@@ -236,7 +240,7 @@ function parseEntrypointsJSON(dir) {
236
240
  });
237
241
  }
238
242
  }
239
- function processIndividualWebpackConfig(config, webpackConfig, sources) {
243
+ function processIndividualWebpackConfig(config, webpackConfig, sources, sharedCache) {
240
244
  let scriptExtension; // This is only used in non-block contexts. It might not actually be necessary, but it is good to have
241
245
  let entrypointFields;
242
246
  const processingModules = webpackConfig.output?.module ?? false;
@@ -251,7 +255,7 @@ function processIndividualWebpackConfig(config, webpackConfig, sources) {
251
255
  const { standaloneBlocks, variablesFilePath, verbose, externals, assumeGlobalizedPlauditLibraries, combineAssetMetadata } = config;
252
256
  let currentVariables = config.currentVariables;
253
257
  const fixedRules = [
254
- replaceDefaultURLProcessing,
258
+ replaceDefaultURLProcessing(config.useWebpackResourceFiltering),
255
259
  (rules) => {
256
260
  return injectPostcssConfigOverrides(rules, name => currentVariables[name], config.postcss.functions ?? (() => ({})), verbose);
257
261
  },
@@ -323,6 +327,9 @@ function processIndividualWebpackConfig(config, webpackConfig, sources) {
323
327
  stage: webpack_remove_empty_scripts_1.default.STAGE_AFTER_PROCESS_PLUGINS,
324
328
  extensions: ['css', 'scss', 'sass', 'less', 'styl', 'pcss']
325
329
  }), new MiniCSSExtractPluginErrorCleaner_1.default());
330
+ if (config.useWebpackResourceFiltering) {
331
+ plugins.push(new SpecialAssetHandlingPlugin_1.default(sharedCache));
332
+ }
326
333
  if (variablesFilePath) {
327
334
  plugins.push(new VariablesJSMonitorPlugin_1.default(variablesFilePath));
328
335
  }
@@ -339,8 +346,8 @@ function processIndividualWebpackConfig(config, webpackConfig, sources) {
339
346
  console.error("Cannot apply externals when they have been disabled via CLI flag. This will greatly increase bundle size and will likely cause the build to file");
340
347
  }
341
348
  else {
342
- const localAssumeGlobalizedPlauditLibraries = typeof dest !== 'string' ? dest.assumeGlobalizedPlauditLibraries : undefined;
343
- const builtDependencyExtractionWebpackPlugin = (0, dependency_extraction_webpack_plugin_config_builder_1.makeDependencyExtractionPlugin)(externals, localAssumeGlobalizedPlauditLibraries ?? assumeGlobalizedPlauditLibraries, combineAssetMetadata && !processingModules && forBlocksDirectory);
349
+ const localAssumeGlobalizedPlauditLibraries = (typeof dest !== 'string' ? dest.assumeGlobalizedPlauditLibraries : undefined) ?? assumeGlobalizedPlauditLibraries;
350
+ const builtDependencyExtractionWebpackPlugin = (0, dependency_extraction_webpack_plugin_config_builder_1.makeDependencyExtractionPlugin)(externals, localAssumeGlobalizedPlauditLibraries, combineAssetMetadata && !processingModules && forBlocksDirectory, typeof dest !== 'string' ? dest.externalize : undefined);
344
351
  plugins[pluginIndex] = builtDependencyExtractionWebpackPlugin.instance;
345
352
  plugins.push(new AdditionalDependencyInjectorPlugin_1.default(typeof dest !== 'string' && dest.additionalDependencies ? dest.additionalDependencies : [], processingModules, builtDependencyExtractionWebpackPlugin.addExternalizedDep));
346
353
  }
@@ -577,21 +584,25 @@ function processIndividualWebpackConfig(config, webpackConfig, sources) {
577
584
  }
578
585
  module.exports = function (config, webpackConfig = require("@wordpress/scripts/config/webpack.config")) {
579
586
  testForDuplicatedEntryPaths(config);
580
- 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 } = config;
587
+ 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 } = config;
581
588
  let variablesFilePath = undefined;
582
589
  const currentVariables = rawVariables ?? {};
583
590
  if (!rawVariables) {
584
591
  variablesFilePath = ["variables.js", "src/site/variables.js"].map(p => node_path_1.default.join(process.cwd(), p)).filter(p => node_fs_1.default.existsSync(p))[0];
585
592
  }
586
- const cfg = { currentVariables, postcss, standaloneBlocks, stats, variablesFilePath, verbose, externals, assumeGlobalizedPlauditLibraries, processTranslationConfigs, combineAssetMetadata };
593
+ const cfg = {
594
+ currentVariables, postcss, standaloneBlocks, stats, variablesFilePath, verbose, externals, assumeGlobalizedPlauditLibraries, processTranslationConfigs, combineAssetMetadata,
595
+ useWebpackResourceFiltering
596
+ };
587
597
  const sources = Array.isArray(config.src) ? config.src.map(s => [s, s]) : Object.entries(config.src);
598
+ const sharedCache = {};
588
599
  if (Array.isArray(webpackConfig)) {
589
600
  return webpackConfig.toSorted((a, b) => {
590
601
  if (a.output?.module) {
591
602
  return b.output?.module ? 0 : -1;
592
603
  }
593
604
  return b.output?.module ? 1 : 0;
594
- }).flatMap(wpCfg => processIndividualWebpackConfig(cfg, wpCfg, sources));
605
+ }).flatMap(wpCfg => processIndividualWebpackConfig(cfg, wpCfg, sources, sharedCache));
595
606
  }
596
- return processIndividualWebpackConfig(cfg, webpackConfig, sources);
607
+ return processIndividualWebpackConfig(cfg, webpackConfig, sources, sharedCache);
597
608
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "2.46.0",
3
+ "version": "2.48.0",
4
4
  "license": "UNLICENSED",
5
5
  "files": [
6
6
  "/build"
@@ -16,9 +16,9 @@
16
16
  }
17
17
  },
18
18
  "devDependencies": {
19
- "@plaudit/gutenberg-api-extensions": "^2.66.1",
19
+ "@plaudit/gutenberg-api-extensions": "^2.69.0",
20
20
  "@types/browser-sync-webpack-plugin": "^2.2.5",
21
- "@types/node": "^22.15.3",
21
+ "@types/node": "^22.15.19",
22
22
  "@types/postcss-functions": "^4.0.4",
23
23
  "@types/tapable": "^2.2.7",
24
24
  "@types/webpack": "^5.28.5",
@@ -34,8 +34,8 @@
34
34
  "@plaudit/postcss-silent-extend": "^3.0.0",
35
35
  "@plaudit/postcss-strip-units": "^3.0.0",
36
36
  "@plaudit/postcss-variables": "^1.1.0",
37
- "@wordpress/dependency-extraction-webpack-plugin": "^6.22.0",
38
- "@wordpress/scripts": "^30.15.0",
37
+ "@wordpress/dependency-extraction-webpack-plugin": "^6.23.0",
38
+ "@wordpress/scripts": "^30.16.0",
39
39
  "autoprefixer": "^10.4.21",
40
40
  "browser-sync": "^3.0.4",
41
41
  "clean-webpack-plugin": "^4.0.0",
@@ -62,15 +62,17 @@
62
62
  "postcss-url": "^10.1.3",
63
63
  "react": "^18.3.1",
64
64
  "react-dom": "^18.3.1",
65
- "webpack": "^5.99.7",
65
+ "webpack": "^5.99.8",
66
66
  "webpack-remove-empty-scripts": "^1.0.4",
67
- "xml-formatter": "^3.6.5"
67
+ "xml-formatter": "^3.6.6"
68
68
  },
69
69
  "engines": {
70
70
  "node": ">=20"
71
71
  },
72
72
  "scripts": {
73
73
  "build": "tsc",
74
+ "clean": "rm -rf build && mkdir build",
75
+ "build:clean": "pnpm run clean && pnpm run build",
74
76
  "watch": "tsc -w"
75
77
  }
76
78
  }