@plaudit/webpack-extensions 2.53.1 → 2.55.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.
Files changed (43) hide show
  1. package/build/{wordpress-scripts-wrapper → plugins}/AdditionalDependencyInjectorPlugin.js +3 -3
  2. package/build/{wordpress-scripts-wrapper → plugins}/BlockJSONManagingPlugin.d.ts +5 -5
  3. package/build/{wordpress-scripts-wrapper → plugins}/BlockJSONManagingPlugin.js +17 -33
  4. package/build/plugins/ExtensionsConfigFileGeneratorPlugin.d.ts +13 -0
  5. package/build/plugins/ExtensionsConfigFileGeneratorPlugin.js +173 -0
  6. package/build/plugins/PlainEntrypointsConfigFileGeneratorPlugin.d.ts +24 -0
  7. package/build/plugins/PlainEntrypointsConfigFileGeneratorPlugin.js +244 -0
  8. package/build/plugins/SpecialAssetHandlingPlugin.d.ts +12 -0
  9. package/build/plugins/SpecialAssetHandlingPlugin.js +135 -0
  10. package/build/{wordpress-scripts-wrapper → plugins}/VariablesJSMonitorPlugin.js +1 -1
  11. package/build/{wordpress-scripts-wrapper → plugins}/WPMLConfigBuilder.d.ts +3 -2
  12. package/build/{wordpress-scripts-wrapper → plugins}/WPMLConfigBuilder.js +7 -3
  13. package/build/{wordpress-scripts-wrapper → plugins}/dependency-extraction-webpack-plugin-config-builder.d.ts +1 -7
  14. package/build/shared.d.ts +86 -9
  15. package/build/shared.js +70 -0
  16. package/build/utils/common-config-helpers.d.ts +26 -0
  17. package/build/utils/common-config-helpers.js +336 -0
  18. package/build/{wordpress-scripts-wrapper → utils}/php-serializer.d.ts +1 -1
  19. package/build/{wordpress-scripts-wrapper → utils}/php-serializer.js +1 -1
  20. package/build/utils/php-writer.d.ts +54 -0
  21. package/build/utils/php-writer.js +191 -0
  22. package/build/utils/pseduo-semaphore.d.ts +13 -0
  23. package/build/utils/pseduo-semaphore.js +63 -0
  24. package/build/wordpress-scripts-wrapper.d.ts +1 -27
  25. package/build/wordpress-scripts-wrapper.js +233 -441
  26. package/package.json +4 -4
  27. package/build/wordpress-scripts-wrapper/ExtensionsConfigFileGeneratorPlugin.d.ts +0 -6
  28. package/build/wordpress-scripts-wrapper/ExtensionsConfigFileGeneratorPlugin.js +0 -52
  29. package/build/wordpress-scripts-wrapper/SpecialAssetHandlingPlugin.d.ts +0 -7
  30. package/build/wordpress-scripts-wrapper/SpecialAssetHandlingPlugin.js +0 -107
  31. /package/build/{wordpress-scripts-wrapper → plugins}/AdditionalDependencyInjectorPlugin.d.ts +0 -0
  32. /package/build/{wordpress-scripts-wrapper → plugins}/BrowserSyncPlugin.d.ts +0 -0
  33. /package/build/{wordpress-scripts-wrapper → plugins}/BrowserSyncPlugin.js +0 -0
  34. /package/build/{wordpress-scripts-wrapper → plugins}/MiniCSSExtractPluginErrorCleaner.d.ts +0 -0
  35. /package/build/{wordpress-scripts-wrapper → plugins}/MiniCSSExtractPluginErrorCleaner.js +0 -0
  36. /package/build/{wordpress-scripts-wrapper → plugins}/PackageConfigSanityChecker.d.ts +0 -0
  37. /package/build/{wordpress-scripts-wrapper → plugins}/PackageConfigSanityChecker.js +0 -0
  38. /package/build/{wordpress-scripts-wrapper → plugins}/VariablesJSMonitorPlugin.d.ts +0 -0
  39. /package/build/{wordpress-scripts-wrapper → plugins}/dependency-extraction-webpack-plugin-config-builder.js +0 -0
  40. /package/build/{wordpress-scripts-wrapper → plugins}/static-configs.d.ts +0 -0
  41. /package/build/{wordpress-scripts-wrapper → plugins}/static-configs.js +0 -0
  42. /package/build/{wordpress-scripts-wrapper → utils}/json-to-php-but-with-__-injection.d.ts +0 -0
  43. /package/build/{wordpress-scripts-wrapper → utils}/json-to-php-but-with-__-injection.js +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "2.53.1",
3
+ "version": "2.55.0",
4
4
  "license": "UNLICENSED",
5
5
  "files": [
6
6
  "/build"
@@ -18,7 +18,7 @@
18
18
  "devDependencies": {
19
19
  "@plaudit/gutenberg-api-extensions": "^2.75.0",
20
20
  "@types/browser-sync-webpack-plugin": "^2.2.5",
21
- "@types/node": "^22.16.5",
21
+ "@types/node": "^22.17.0",
22
22
  "@types/postcss-functions": "^4.0.4",
23
23
  "@types/tapable": "^2.2.7",
24
24
  "@types/webpack": "^5.28.5",
@@ -26,7 +26,7 @@
26
26
  "postcss-load-config": "^4.0.2",
27
27
  "postcss-loader": "^7.3.4",
28
28
  "ts-node": "^10.9.2",
29
- "typescript": "^5.8.3",
29
+ "typescript": "^5.9.2",
30
30
  "webpack-bundle-analyzer": "^4.10.2"
31
31
  },
32
32
  "dependencies": {
@@ -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.100.2",
66
+ "webpack": "^5.101.0",
67
67
  "webpack-remove-empty-scripts": "^1.1.1",
68
68
  "xml-formatter": "^3.6.6"
69
69
  },
@@ -1,6 +0,0 @@
1
- import { type Compiler, type WebpackPluginInstance } from "webpack";
2
- export declare class ExtensionsConfigFileGeneratorPlugin implements WebpackPluginInstance {
3
- private readonly extensionsPath;
4
- constructor(extensionsPath: string);
5
- apply(compiler: Compiler): void;
6
- }
@@ -1,52 +0,0 @@
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
- exports.ExtensionsConfigFileGeneratorPlugin = void 0;
7
- const promises_1 = __importDefault(require("node:fs/promises"));
8
- const node_path_1 = __importDefault(require("node:path"));
9
- const webpack_1 = require("webpack");
10
- const php_serializer_1 = __importDefault(require("./php-serializer"));
11
- class ExtensionsConfigFileGeneratorPlugin {
12
- extensionsPath;
13
- constructor(extensionsPath) {
14
- this.extensionsPath = extensionsPath;
15
- }
16
- apply(compiler) {
17
- compiler.hooks.make.tapPromise(this.constructor.name, async (compilation) => {
18
- if (!compilation.contextDependencies.has(this.extensionsPath)) {
19
- compilation.contextDependencies.add(this.extensionsPath);
20
- }
21
- const emissionPromises = [];
22
- for (const setupFilePath of await promises_1.default.readdir(this.extensionsPath)) {
23
- if (setupFilePath.endsWith("-setup.php")) {
24
- const setupFileSourcePath = node_path_1.default.join(this.extensionsPath, setupFilePath);
25
- compilation.fileDependencies.add(setupFileSourcePath);
26
- emissionPromises.push(promises_1.default.readFile(setupFileSourcePath)
27
- .then(contents => compilation.emitAsset(setupFilePath, new webpack_1.sources.RawSource(contents), { size: Buffer.byteLength(contents) })));
28
- }
29
- }
30
- await Promise.all(emissionPromises);
31
- });
32
- compiler.hooks.thisCompilation.tap(this.constructor.name, compilation => {
33
- compilation.hooks.afterProcessAssets.tap(`${this.constructor.name}_ProcessAssets`, compilationAssets => {
34
- const regex = /^(.+?)-((?:editor-|view-|)(?:style|script|script-module))\.(?:css|m?js)$/i;
35
- const mapping = {};
36
- for (const asset of Object.keys(compilationAssets)) {
37
- let match;
38
- if ((match = /^(.+?)-setup.php$/i.exec(asset)) && match[1]) {
39
- (mapping[match[1]] ?? (mapping[match[1]] = [{}]))[1] = `${asset}`;
40
- }
41
- else if ((match = regex.exec(asset)) && match[1] && match[2]) {
42
- const resourceInfo = (mapping[match[1]] ?? (mapping[match[1]] = [{}]))[0];
43
- const key = match[2].replace(/-[sm]/gi, chars => chars.substring(1).toUpperCase());
44
- (resourceInfo[key] ?? (resourceInfo[key] = [])).push([`plaudit_block-extension_${match[1]}-${match[2]}`, asset]);
45
- }
46
- }
47
- compilation.emitAsset("mapping.config", new webpack_1.sources.RawSource((0, php_serializer_1.default)(mapping)));
48
- });
49
- });
50
- }
51
- }
52
- exports.ExtensionsConfigFileGeneratorPlugin = ExtensionsConfigFileGeneratorPlugin;
@@ -1,7 +0,0 @@
1
- import { Compiler, WebpackPluginInstance } from "webpack";
2
- import { SharedCache } from "../shared";
3
- export declare class SpecialAssetHandlingPlugin implements WebpackPluginInstance {
4
- private readonly cache;
5
- constructor(cache: SharedCache);
6
- apply(compiler: Compiler): void;
7
- }
@@ -1,107 +0,0 @@
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
- exports.SpecialAssetHandlingPlugin = void 0;
7
- const node_path_1 = __importDefault(require("node:path"));
8
- const webpack_1 = require("webpack");
9
- class SpecialAssetHandlingPlugin {
10
- cache;
11
- constructor(cache) {
12
- this.cache = cache;
13
- }
14
- apply(compiler) {
15
- compiler.hooks.compilation.tap(this.constructor.name, compilation => {
16
- this.cache.specialAssets = undefined;
17
- compilation.hooks.processAssets.tap(this.constructor.name, assets => {
18
- for (const pathname of Object.keys(assets)) {
19
- const assetInfo = compilation.assetsInfo.get(pathname);
20
- if (!assetInfo?.sourceFilename) {
21
- continue;
22
- }
23
- const queryStart = assetInfo.sourceFilename.indexOf('?');
24
- if (queryStart < 0) {
25
- continue;
26
- }
27
- const params = new URLSearchParams(assetInfo.sourceFilename.substring(queryStart + 1)
28
- .replace(/(?:fetchPriority|crossOrigin)=/gi, str => str.toLowerCase()) //This ensures consistent capitalization of the fetchPriority parameter
29
- );
30
- if (this.cache.specialAssets === undefined) {
31
- this.cache.specialAssets = { files: {} };
32
- const outputFile = node_path_1.default.join(node_path_1.default.dirname(node_path_1.default.dirname(pathname)), "special-assets.php");
33
- compilation.hooks.afterProcessAssets.tap(`${this.constructor.name}_GeneratePreloadingFile`, () => {
34
- if (!this.cache.specialAssets?.files) {
35
- return;
36
- }
37
- const hookTextLines = [
38
- "<?php",
39
- "add_action('wp_head', function() {",
40
- "\tif (str_starts_with(__DIR__, ABSPATH)) {",
41
- "\t\t$path = ltrim(substr(__DIR__, strlen(ABSPATH)), '/');",
42
- "\t} else if (str_starts_with(__DIR__, '/workspace/website')) {",
43
- "\t\t$path = ltrim(substr(__DIR__, 18), '/');",
44
- "\t} else {",
45
- "\t\terror_log('UNABLE TO FIGURE OUT WHAT THE RELATIVE PATH TO THE FONT DIRECTORY SHOULD BE');",
46
- "\t\treturn;",
47
- "\t}",
48
- "\t$base_uri = trailingslashit(home_url($path));",
49
- "\t?>"
50
- ];
51
- const preloadedFonts = Object.entries(this.cache.specialAssets.files)
52
- .filter(([_, { preload }]) => preload)
53
- .sort(([a], [b]) => a.localeCompare(b));
54
- for (let [filename, { preload, fetchpriority, crossorigin }] of preloadedFonts) {
55
- if (!preload) {
56
- continue;
57
- }
58
- let fileExtension = node_path_1.default.extname(filename);
59
- if (fileExtension.startsWith(".")) {
60
- fileExtension = fileExtension.substring(1).toLowerCase();
61
- }
62
- else {
63
- fileExtension = fileExtension.toLowerCase();
64
- }
65
- const attributes = [];
66
- if (["woff", "woff2", "ttf", "otf", "eot"].includes(fileExtension)) {
67
- if (!crossorigin) {
68
- crossorigin = "anonymous";
69
- }
70
- attributes.push(["as", "font"], ["type", `font/${fileExtension}`]);
71
- }
72
- else if (fileExtension === "svg") {
73
- attributes.push(["as", "image"], ["type", `image/svg+xml`]);
74
- }
75
- else if (fileExtension === "jpeg" || fileExtension === "jpg") {
76
- attributes.push(["as", "image"], ["type", `image/jpeg`]);
77
- }
78
- else if (["png", "webp", "avif", "gif", "bmp"].includes(fileExtension)) {
79
- attributes.push(["as", "image"], ["type", `image/${fileExtension}`]);
80
- }
81
- else {
82
- compilation.errors.push(new Error(`Encountered preloading markup on an unsupported file extension (${fileExtension}). Full resource path: ${assetInfo.sourceFilename}`));
83
- continue;
84
- }
85
- if (fetchpriority && fetchpriority !== 'auto') {
86
- attributes.push(["fetchpriority", fetchpriority]);
87
- }
88
- if (crossorigin || crossorigin === "") {
89
- attributes.push(["crossorigin", crossorigin]);
90
- }
91
- const dynamicAttrs = attributes.map(([k, v]) => v ? `${k}="${v}"` : k).join(" ");
92
- hookTextLines.push(`\t<link rel="preload" href="<?= esc_url($base_uri.'${filename}') ?>" ${dynamicAttrs}>`);
93
- }
94
- hookTextLines.push("\t<?php", "});\n");
95
- compilation.emitAsset(outputFile, new webpack_1.sources.RawSource(hookTextLines.join("\n")));
96
- });
97
- }
98
- const filename = node_path_1.default.join(node_path_1.default.basename(node_path_1.default.dirname(pathname)), node_path_1.default.basename(pathname));
99
- if (params.has("preload")) {
100
- this.cache.specialAssets.files[filename] = { preload: true, fetchpriority: params.get("fetchpriority"), crossorigin: params.get("crossorigin") };
101
- }
102
- }
103
- });
104
- });
105
- }
106
- }
107
- exports.SpecialAssetHandlingPlugin = SpecialAssetHandlingPlugin;