@plaudit/webpack-extensions 2.89.2 → 3.0.0-rc.2

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 (55) hide show
  1. package/CHANGELOG.md +0 -106
  2. package/USER-GUIDE.md +81 -117
  3. package/{dist → build}/plugins/EnhancedBlockJSONPlugin.d.ts +4 -7
  4. package/{dist → build}/plugins/EnhancedBlockJSONPlugin.js +53 -116
  5. package/{dist → build}/plugins/ExtensionsConfigFileGeneratorPlugin.d.ts +3 -7
  6. package/{dist → build}/plugins/ExtensionsConfigFileGeneratorPlugin.js +10 -74
  7. package/{dist → build}/plugins/ExtensionsConfigFileGeneratorPluginV1.d.ts +1 -1
  8. package/{dist → build}/plugins/ExtensionsConfigFileGeneratorPluginV1.js +0 -4
  9. package/{dist → build}/plugins/PlainEntrypointsConfigFileGeneratorPlugin.js +20 -46
  10. package/{dist → build}/plugins/UnifiedLoaderGenerator.d.ts +2 -1
  11. package/build/plugins/static-configs.d.ts +3 -0
  12. package/build/plugins/static-configs.js +33 -0
  13. package/{dist → build}/shared.d.ts +18 -86
  14. package/{dist → build}/shared.js +11 -124
  15. package/{dist → build}/utils/common-config-helpers.d.ts +1 -1
  16. package/{dist → build}/utils/common-config-helpers.js +49 -126
  17. package/{dist → build}/wordpress-scripts-wrapper.js +36 -70
  18. package/package.json +26 -35
  19. package/dist/plugins/static-configs.d.ts +0 -3
  20. package/dist/plugins/static-configs.js +0 -91
  21. package/dist/utils/entrypoint-resolution-logic.d.ts +0 -10
  22. package/dist/utils/entrypoint-resolution-logic.js +0 -82
  23. package/dist/utils/location-encoding-filename-parser.d.ts +0 -26
  24. package/dist/utils/location-encoding-filename-parser.js +0 -118
  25. package/dist/utils/path-query-and-related-helpers.d.ts +0 -58
  26. package/dist/utils/path-query-and-related-helpers.js +0 -263
  27. /package/{dist → build}/plugins/AbstractBiPhasicGroupAndEntryPlugin.d.ts +0 -0
  28. /package/{dist → build}/plugins/AbstractBiPhasicGroupAndEntryPlugin.js +0 -0
  29. /package/{dist → build}/plugins/AbstractBiPhasicGroupPlugin.d.ts +0 -0
  30. /package/{dist → build}/plugins/AbstractBiPhasicGroupPlugin.js +0 -0
  31. /package/{dist → build}/plugins/AdditionalDependencyInjectorPlugin.d.ts +0 -0
  32. /package/{dist → build}/plugins/AdditionalDependencyInjectorPlugin.js +0 -0
  33. /package/{dist → build}/plugins/BrowserSyncPlugin.d.ts +0 -0
  34. /package/{dist → build}/plugins/BrowserSyncPlugin.js +0 -0
  35. /package/{dist → build}/plugins/EnhancedDynamicEntryPlugin.d.ts +0 -0
  36. /package/{dist → build}/plugins/EnhancedDynamicEntryPlugin.js +0 -0
  37. /package/{dist → build}/plugins/MiniCSSExtractPluginErrorCleaner.d.ts +0 -0
  38. /package/{dist → build}/plugins/MiniCSSExtractPluginErrorCleaner.js +0 -0
  39. /package/{dist → build}/plugins/PackageConfigSanityChecker.d.ts +0 -0
  40. /package/{dist → build}/plugins/PackageConfigSanityChecker.js +0 -0
  41. /package/{dist → build}/plugins/PlainEntrypointsConfigFileGeneratorPlugin.d.ts +0 -0
  42. /package/{dist → build}/plugins/SpecialAssetHandlingPlugin.d.ts +0 -0
  43. /package/{dist → build}/plugins/SpecialAssetHandlingPlugin.js +0 -0
  44. /package/{dist → build}/plugins/UnifiedLoaderGenerator.js +0 -0
  45. /package/{dist → build}/plugins/VariablesJSMonitorPlugin.d.ts +0 -0
  46. /package/{dist → build}/plugins/VariablesJSMonitorPlugin.js +0 -0
  47. /package/{dist → build}/plugins/WPMLConfigBuilder.d.ts +0 -0
  48. /package/{dist → build}/plugins/WPMLConfigBuilder.js +0 -0
  49. /package/{dist → build}/plugins/dependency-extraction-webpack-plugin-config-builder.d.ts +0 -0
  50. /package/{dist → build}/plugins/dependency-extraction-webpack-plugin-config-builder.js +0 -0
  51. /package/{dist → build}/utils/css-writer.d.ts +0 -0
  52. /package/{dist → build}/utils/css-writer.js +0 -0
  53. /package/{dist → build}/utils/pseduo-semaphore.d.ts +0 -0
  54. /package/{dist → build}/utils/pseduo-semaphore.js +0 -0
  55. /package/{dist → build}/wordpress-scripts-wrapper.d.ts +0 -0
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.PlainEntrypointsConfigFileGeneratorPlugin = void 0;
4
- const node_path_1 = require("node:path");
7
+ const node_path_1 = __importDefault(require("node:path"));
5
8
  const php_writer_1 = require("@plaudit/php-writer");
6
9
  const expressions_1 = require("@plaudit/php-writer/expressions");
7
10
  const shared_1 = require("../shared");
8
11
  const pseduo_semaphore_1 = require("../utils/pseduo-semaphore");
9
- const path_query_and_related_helpers_1 = require("../utils/path-query-and-related-helpers");
10
12
  const AbstractBiPhasicGroupAndEntryPlugin_1 = require("./AbstractBiPhasicGroupAndEntryPlugin");
11
13
  const UnifiedLoaderGenerator_1 = require("./UnifiedLoaderGenerator");
12
14
  const webpack_1 = require("webpack");
@@ -24,10 +26,9 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
24
26
  this.useUnifiedLoader = useUnifiedLoader;
25
27
  }
26
28
  generatePlainEntrypointsLoader(compilation, assets) {
27
- const emitDir = (0, node_path_1.join)(this.buildRoot, this.outputDir);
29
+ const emitDir = node_path_1.default.join(this.buildRoot, this.outputDir);
28
30
  const handleLists = {
29
31
  register: [],
30
- inline: [],
31
32
  ...Object.fromEntries((0, shared_1.constantKeys)(shared_1.standardLocationNamesMeta).map(sln => [sln, []]))
32
33
  };
33
34
  const allNamedHandles = assets
@@ -40,21 +41,21 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
40
41
  .map(handle => [handle.handleName, handle.src]))]));
41
42
  const plainEntrypointsConfig = { scriptHandles: {}, script_moduleHandles: {}, styleHandles: {} };
42
43
  for (const { handles, handlePrefix } of assets) {
43
- for (const { src, rest, locations, type, handleName, lazyLoader, ...otherProps } of handles) {
44
- const cleanBasename = (0, node_path_1.basename)(src).replace(/_(?:script(?:-\d+)?\.js|style(?:-\d+)?\.css)$|(?<!_(script|style))\.(js|css)$/, "");
44
+ for (const { src, rest, locations, type, handleName, lazyLoader } of handles) {
45
+ const basename = node_path_1.default.basename(src).replace(/_(?:script(?:-\d+)?\.js|style(?:-\d+)?\.css)$|(?<!_(script|style))\.(js|css)$/, "");
45
46
  let finalHandleName;
46
47
  if (typeof handleName === 'string') {
47
- finalHandleName = (0, shared_1.convertUsageLocationsHandleToEmittableHandle)(handleName, cleanBasename);
48
+ finalHandleName = (0, shared_1.convertUsageLocationsHandleToEmittableHandle)(handleName, basename);
48
49
  }
49
50
  else {
50
51
  const handleNameMap = usedHandleNames[type];
51
- const baseFinalHandleName = finalHandleName = `${handlePrefix}.${(0, shared_1.convertUsageLocationsHandleToEmittableHandle)((0, shared_1.kebabCase)(cleanBasename), cleanBasename)}`;
52
+ const baseFinalHandleName = finalHandleName = `${handlePrefix}.${(0, shared_1.convertUsageLocationsHandleToEmittableHandle)((0, shared_1.kebabCase)(basename), basename)}`;
52
53
  for (let count = 0; finalHandleName in handleNameMap && handleNameMap[finalHandleName] !== src;) {
53
54
  finalHandleName = `${baseFinalHandleName}-${++count}`;
54
55
  }
55
56
  handleNameMap[finalHandleName] = src;
56
57
  }
57
- plainEntrypointsConfig[`${type}Handles`][finalHandleName] = { src, rest, locations, type, lazyLoader, ...otherProps };
58
+ plainEntrypointsConfig[`${type}Handles`][finalHandleName] = { src, rest, locations, type, lazyLoader };
58
59
  }
59
60
  }
60
61
  PlainEntrypointsConfigFileGeneratorPlugin.addHandlesToHandleLists('script', Object.entries(plainEntrypointsConfig.scriptHandles)
@@ -78,26 +79,7 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
78
79
  writer.action("init", writer => {
79
80
  writer.call("plaudit_webpack_extensions__resolve_base_uri", [expressions_1.Constants.__DIR__], { assignTo: baseUriVar });
80
81
  for (const { handle, type, data } of prioritizedHandleList) {
81
- const { inlinedAsset, rest, src } = data;
82
- const emittedSrc = inlinedAsset === undefined
83
- ? expressions_1.Op.concat(baseUriVar, (0, node_path_1.relative)(emitDir, src))
84
- : false;
85
- writer.call(`wp_register_${type}`, [handle, emittedSrc, ...rest]);
86
- if (inlinedAsset !== undefined) {
87
- (0, shared_1.appendAddInlineAssetCall)(compilation, writer, handle, type, inlinedAsset, data, src);
88
- }
89
- }
90
- }, { priority, accountForAlreadyDoing: this.config.includePostInitFallback });
91
- }
92
- for (const [priority, prioritizedHandleList] of PlainEntrypointsConfigFileGeneratorPlugin.separateHandleListByPriority(handleLists.inline)) {
93
- writer.action("init", writer => {
94
- writer.call("plaudit_webpack_extensions__resolve_base_uri", [expressions_1.Constants.__DIR__], { assignTo: baseUriVar });
95
- for (const { handle, type, data } of prioritizedHandleList) {
96
- const { inlinedAsset, rest, src } = data;
97
- writer.call(`wp_register_${type}`, [handle, false, ...rest]);
98
- if (inlinedAsset !== undefined) {
99
- (0, shared_1.appendAddInlineAssetCall)(compilation, writer, handle, type, inlinedAsset, data, src);
100
- }
82
+ writer.call(`wp_register_${type}`, [handle, expressions_1.Op.concat(baseUriVar, node_path_1.default.relative(emitDir, data.src)), ...data.rest]);
101
83
  }
102
84
  }, { priority, accountForAlreadyDoing: this.config.includePostInitFallback });
103
85
  }
@@ -114,7 +96,7 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
114
96
  if (sortedEditorStyleHandles.length > 0) {
115
97
  writer.linebreak();
116
98
  for (const handleSrc of sortedEditorStyleHandles) {
117
- const handlePath = (0, node_path_1.join)(this.outputDir, (0, node_path_1.relative)(emitDir, handleSrc));
99
+ const handlePath = node_path_1.default.join(this.outputDir, node_path_1.default.relative(emitDir, handleSrc));
118
100
  writer.call("add_editor_style", [(0, shared_1.leadingSlashIt)(handlePath)]);
119
101
  }
120
102
  }
@@ -145,9 +127,6 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
145
127
  if (data.locations.register !== false) {
146
128
  handleLists.register.push({ handle, type, data, priority: typeof data.locations.register === 'number' ? data.locations.register : 10 });
147
129
  }
148
- else if (data.inlinedAsset !== undefined) {
149
- handleLists.inline.push({ handle, type, data, priority: typeof data.locations.inline === 'number' ? data.locations.inline : 10 });
150
- }
151
130
  for (const location of (0, shared_1.constantKeys)(shared_1.standardLocationNamesMeta)) {
152
131
  let priority, hook_name;
153
132
  const dataLocation = data.locations[location];
@@ -294,23 +273,18 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
294
273
  chunkFiles[0][1] = true;
295
274
  }
296
275
  for (const [file, useHandleName] of chunkFiles) {
297
- const extension = (0, node_path_1.extname)(file).toLowerCase();
276
+ const extension = node_path_1.default.extname(file).toLowerCase();
298
277
  const type = extension === ".js" ? 'script' : (extension === ".mjs" ? 'script_module' : 'style');
299
278
  const isScript = type !== 'style';
300
279
  const dependencies = isScript === entrypointChunkIsScript ? assetData.dependencies : [];
301
- const { lazyLoader, locations } = this.dest;
302
- const { flags } = (0, path_query_and_related_helpers_1.unpackEnqueuingControlFlagsFromPathQueryParameters)(typeof locations.registerScriptArgs === 'object' ? locations.registerScriptArgs : { strategy: locations.registerScriptArgs }, file, "registerScriptArgs");
303
- const { inlinedAsset, scriptArgsObject } = (0, path_query_and_related_helpers_1.convertEnqueuingControlFlagsToScriptArgsObject)(compilation, file, (0, path_query_and_related_helpers_1.mergeTwoEnqueuingControlFlagSets)(file, flags, this.dest.enqueuingFlags));
304
- const rest = isScript && scriptArgsObject !== undefined ? [dependencies, assetData.version, scriptArgsObject] : [dependencies, assetData.version];
305
- const destPath = (0, node_path_1.join)(compilation.outputOptions.path, file);
280
+ const { registerScriptArgs } = this.dest.locations;
281
+ const rest = isScript && registerScriptArgs !== undefined ? [dependencies, assetData.version, registerScriptArgs] : [dependencies, assetData.version];
282
+ const destPath = node_path_1.default.join(compilation.outputOptions.path, file);
306
283
  handles.push({
307
- src: destPath,
308
- rest,
309
- type,
310
- locations,
311
- handleName: useHandleName ? locations.handle : undefined,
312
- lazyLoader,
313
- inlinedAsset
284
+ src: destPath, rest, type,
285
+ locations: this.dest.locations,
286
+ handleName: useHandleName ? this.dest.locations.handle : undefined,
287
+ lazyLoader: this.dest.lazyLoader
314
288
  });
315
289
  }
316
290
  myAssetHandles.push({ handles, handlePrefix: this.config.targetHandlePrefix });
@@ -3,7 +3,7 @@ import { AbstractBiPhasicGroupPlugin } from "./AbstractBiPhasicGroupPlugin";
3
3
  import type { VerifiedPlauditWordpressWebpackConfig } from "../utils/common-config-helpers";
4
4
  import { PseudoSemaphore } from "../utils/pseduo-semaphore";
5
5
  import { Compilation } from "webpack";
6
- export type LoaderInfo = {
6
+ type LoaderInfo = {
7
7
  group: string;
8
8
  action(writer: PHPWriter): void;
9
9
  requiresBaseURI: boolean;
@@ -18,3 +18,4 @@ export declare class UnifiedLoaderGenerator extends AbstractBiPhasicGroupPlugin
18
18
  private withDistDevLoader;
19
19
  private ensureDistExists;
20
20
  }
21
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { Options as PostcssFunctionsOptions } from "postcss-functions";
2
+ import type { PostCSSLoaderOptions } from "postcss-loader/dist/config";
3
+ export declare function postcssConfigBuilder(variables: (name: string) => string | number | undefined, postCSSFunctions: (variables: (name: string) => unknown) => PostcssFunctionsOptions['functions']): PostCSSLoaderOptions;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.postcssConfigBuilder = postcssConfigBuilder;
4
+ // Options: calc
5
+ const calcOptions = { precision: 4, mediaQueries: true, selectors: true };
6
+ // Options: autoprefixerOptions
7
+ const autoprefixerOptions = { grid: "autoplace" };
8
+ function makeDefaultPostCSSFunctions(variables) {
9
+ const magnitude = new Intl.NumberFormat("en-US", { maximumFractionDigits: 4 });
10
+ return {
11
+ pxAsRem(value) {
12
+ return value ? `${magnitude.format(parseFloat(value.toString()) / (variables("font_size") || 16))}rem` : "1rem";
13
+ }
14
+ };
15
+ }
16
+ function postcssConfigBuilder(variables, postCSSFunctions) {
17
+ return {
18
+ plugins: [
19
+ require("postcss-import")(), // Once
20
+ require("postcss-mixins")(), // Once
21
+ require("@plaudit/postcss-variables")({ variables }), // Once
22
+ require("postcss-functions")({ functions: { ...makeDefaultPostCSSFunctions(variables), ...postCSSFunctions(variables) } }),
23
+ require("postcss-property-lookup")({ logLevel: "warn" }), // Rule
24
+ require("@plaudit/postcss-strip-units")(), // AtRule, Declaration
25
+ require("postcss-nested")(), // Rule
26
+ require("postcss-url")(),
27
+ require("postcss-calc")(calcOptions), // OnceExit
28
+ require("@plaudit/postcss-color-function")(), // OnceExit
29
+ require("autoprefixer")(autoprefixerOptions), // OnceExit
30
+ require("postcss-reporter")({ clearReportedMessages: true }), // OnceExit
31
+ ]
32
+ };
33
+ }
@@ -1,28 +1,20 @@
1
1
  import { PHPWriter } from "@plaudit/php-writer";
2
2
  import type { Options as PostcssFunctionsOptions } from "postcss-functions";
3
- import { type AssetInfo, type Compilation, type Configuration, type Entrypoint, WebpackError, type Compiler } from "webpack";
4
- import { SourceType } from "./utils/entrypoint-resolution-logic";
5
- import type { NormalizedEnqueuingControlFlags } from "./utils/path-query-and-related-helpers";
6
- export * from "./utils/entrypoint-resolution-logic";
3
+ import { AssetInfo, Compilation, Configuration, Entrypoint, WebpackError, Compiler } from "webpack";
7
4
  export type ParsedAssetsJson = Record<string, {
8
5
  dependencies: string[];
9
6
  version: string;
10
7
  }>;
11
8
  export declare function isParsedAssetsJson(thing: any): thing is ParsedAssetsJson;
12
- export type ScriptArgsObject = {
9
+ type ScriptArgsObject = {
13
10
  strategy?: 'defer' | 'async';
14
11
  in_footer?: boolean;
15
12
  fetchpriority?: 'auto' | 'low' | 'high';
16
13
  };
17
14
  type BaseRestType = [/* dependencies: */ string[], /* version: */ string];
18
- export type InlinedAsset = {
19
- contents: string;
20
- position?: 'before' | 'after';
21
- };
22
15
  export type HandleData = {
23
16
  src: string;
24
- rest: BaseRestType | [...BaseRestType, ScriptArgsObject];
25
- inlinedAsset?: InlinedAsset;
17
+ rest: BaseRestType | [...BaseRestType, ScriptArgsObject | boolean];
26
18
  };
27
19
  export declare const standardLocationNamesMeta: {
28
20
  readonly clientView: {
@@ -57,34 +49,34 @@ export type StandardLocationNameMeta = {
57
49
  };
58
50
  };
59
51
  export type StandardLocationNames = keyof typeof standardLocationNamesMeta;
60
- export declare function isStandardLocationName(name: string): name is StandardLocationNames;
61
52
  type LocationWithHookNameSupport = boolean | number | string | string[] | {
62
53
  hook_name?: string | string[];
63
54
  priority?: number;
64
55
  };
65
- type InputRegisterScriptArgs = ScriptArgsObject | boolean | 'lazy' | 'eager' | 'inline';
66
- export declare function isRegisterScriptArgsShorthandName(name: string): name is Extract<InputRegisterScriptArgs, string>;
67
- export type RealUsageLocations = {
56
+ export type UsageLocations = {
68
57
  [K in StandardLocationNames]?: typeof standardLocationNamesMeta[K] extends {
69
58
  supports_hook_name: true;
70
59
  } ? LocationWithHookNameSupport : boolean | number;
71
- };
72
- export type UsageLocations = RealUsageLocations & {
60
+ } & {
73
61
  register?: boolean | number;
74
- inline?: number;
75
62
  handle?: string | ((generatedHandle: string) => string);
76
- registerScriptArgs?: InputRegisterScriptArgs;
63
+ registerScriptArgs?: ScriptArgsObject | boolean | 'lazy';
77
64
  };
78
65
  export type NormalizedUsageLocations = Omit<UsageLocations, 'registerScriptArgs'> & {
79
- registerScriptArgs?: InputRegisterScriptArgs;
66
+ registerScriptArgs?: ScriptArgsObject | boolean;
80
67
  };
81
68
  export declare function isNormalizedUsageLocations(usageLocations: UsageLocations): usageLocations is NormalizedUsageLocations;
82
69
  export declare function constantKeys<K extends string, V>(object: {
83
- [k in K]?: V;
70
+ [k in K]: V;
84
71
  }): K[];
85
72
  export declare function constantEntries<K extends string, V>(object: {
86
73
  [k in K]: V;
87
74
  }): [K, V][];
75
+ export declare const enum SourceType {
76
+ blocks = "blocks",
77
+ extensions = "extensions",
78
+ plain = "plain"
79
+ }
88
80
  export declare function determineCurrentSourceType(dest: string | AdvancedOutputConfig, srcIsDirectory: boolean): SourceType;
89
81
  export interface WebpackPlugin {
90
82
  apply(compiler: Compiler): void;
@@ -107,21 +99,17 @@ export type AdvancedOutputConfig = {
107
99
  bundleAnalyzer?: boolean;
108
100
  locations?: UsageLocations | UsageLocations['handle'];
109
101
  lazyLoader?: string;
110
- pathQueryParameters?: PathQueryParameters;
111
- enqueuingFlags?: NormalizedEnqueuingControlFlags;
112
102
  };
113
- type OptionalCfgFields = 'directoryLayout' | 'externalize' | 'lazyLoader' | 'pathQueryParameters';
114
- export type VerifiedAdvancedOutputConfig = Required<Omit<AdvancedOutputConfig, 'locations' | 'enqueuingFlags' | OptionalCfgFields>> & Pick<AdvancedOutputConfig, OptionalCfgFields> & {
115
- enqueuingFlags: NormalizedEnqueuingControlFlags | undefined;
103
+ type OptionalCfgFields = 'directoryLayout' | 'externalize' | 'lazyLoader';
104
+ export type VerifiedAdvancedOutputConfig = Required<Omit<AdvancedOutputConfig, 'locations' | OptionalCfgFields>> & Pick<AdvancedOutputConfig, OptionalCfgFields> & {
116
105
  locations: NormalizedUsageLocations;
117
106
  };
118
107
  export type SourcesObject = Record<string, string | AdvancedOutputConfig | boolean>;
119
108
  export type PlauditWordpressWebpackConfig = {
120
- standard?: '2026-03-13';
121
109
  standaloneBlocks?: boolean;
122
110
  variables?: Record<string, any>;
123
111
  verbose?: boolean;
124
- src?: string[] | SourcesObject;
112
+ src: string[] | SourcesObject;
125
113
  stats?: Configuration['stats'];
126
114
  postcss?: {
127
115
  functions?: (variables: (name: string) => unknown) => PostcssFunctionsOptions['functions'];
@@ -142,41 +130,6 @@ export type PlauditWordpressWebpackConfig = {
142
130
  omitDistDev?: boolean;
143
131
  onlyRunPostCSSOnPCSS?: boolean;
144
132
  };
145
- export declare function applyStandards(config: PlauditWordpressWebpackConfig): {
146
- readonly standard?: "2026-03-13";
147
- readonly standaloneBlocks?: boolean;
148
- readonly variables?: Record<string, any>;
149
- readonly verbose?: boolean;
150
- readonly src?: string[] | SourcesObject;
151
- readonly stats?: Configuration["stats"];
152
- readonly postcss?: {
153
- functions?: (variables: (name: string) => unknown) => PostcssFunctionsOptions["functions"];
154
- };
155
- readonly externals?: Externals;
156
- readonly assumeGlobalizedPlauditLibraries?: boolean;
157
- readonly processTranslationConfigs?: boolean;
158
- readonly combineAssetMetadata?: boolean;
159
- useWebpackResourceFiltering?: boolean;
160
- outputDir?: string;
161
- extensionsVersion?: 1 | 2 | 3;
162
- readonly targetHandlePrefix?: string;
163
- plainEntrypointsVersion?: 1 | 2;
164
- srcDir?: string;
165
- readonly srcPrefixes?: string[];
166
- useUnifiedLoader?: boolean;
167
- readonly includePostInitFallback?: boolean;
168
- readonly omitDistDev?: boolean;
169
- onlyRunPostCSSOnPCSS?: boolean;
170
- };
171
- export declare function resolveStandard(standard: PlauditWordpressWebpackConfig['standard']): {
172
- readonly useWebpackResourceFiltering: true;
173
- readonly extensionsVersion: 3;
174
- readonly plainEntrypointsVersion: 2;
175
- readonly srcDir: "src";
176
- readonly outputDir: "dist";
177
- readonly useUnifiedLoader: true;
178
- readonly onlyRunPostCSSOnPCSS: true;
179
- } | undefined;
180
133
  export type FileSegmentBlockEntrypointInfo = {
181
134
  blockJsonOrigin: string;
182
135
  entrypointField: EntrypointFields[number];
@@ -186,10 +139,7 @@ export type FileSegmentBlockEntrypointInfo = {
186
139
  handle: string;
187
140
  dest: VerifiedAdvancedOutputConfig;
188
141
  absoluteSrc: string;
189
- pathQueryParameters: PathQueryParameters | undefined;
190
- enqueuingFlags: NormalizedEnqueuingControlFlags | undefined;
191
142
  };
192
- export type PathQueryParameters = Record<string, unknown | [unknown, ...unknown[]]>;
193
143
  export type BlockEntrypointInfo = FileSegmentBlockEntrypointInfo | {
194
144
  dest: VerifiedAdvancedOutputConfig;
195
145
  purpose: string;
@@ -209,11 +159,10 @@ export declare const scriptExtension: RegExp;
209
159
  export declare const scriptWithoutModuleExtension: RegExp;
210
160
  export declare const scriptWithModuleExtension: RegExp;
211
161
  export declare const styleExtension: RegExp;
212
- export declare function scriptOrStyleTest(entryPath: string, scriptExtension: RegExp): "script" | "style" | "";
162
+ export declare function scriptOrStyleTest(entryPath: string, scriptExtension: RegExp): "style" | "script" | "";
213
163
  export declare function isStyleField(field: string): field is 'style' | 'viewStyle' | 'editorStyle';
214
164
  export declare function isScriptModuleField(field: string): field is 'viewScriptModule';
215
165
  export declare function getHandleGroup(field: string): 'styleHandles' | 'scriptHandles' | 'scriptModuleHandles';
216
- export type StripFirstTwoItems<A extends any[]> = A extends [any, any, ...rest: infer R] ? R : never;
217
166
  export declare function hasAtLeastOneItem<T>(list: T[]): list is [T, ...T[]];
218
167
  export type TupleOf<T, N extends number> = N extends N ? number extends N ? T[] : _TupleOf<T, N, []> : never;
219
168
  type _TupleOf<T, N extends number, R extends unknown[]> = R['length'] extends N ? R : _TupleOf<T, N, [T, ...R]>;
@@ -221,7 +170,6 @@ export declare function arrayIsLength<T, N extends number>(arr: T[] | null | und
221
170
  export declare function kebabCase(value: string): string;
222
171
  export declare function loadEnvFile(filePath: string): Promise<Record<string, string>>;
223
172
  export declare function parseEnvFile(contents: string): Record<string, string>;
224
- export declare function newCleanWebpackError(error: string | ConstructorParameters<typeof WebpackError>): WebpackError;
225
173
  export declare function newWebpackErrorForFile(error: string | ConstructorParameters<typeof WebpackError>, file: string): WebpackError;
226
174
  /**
227
175
  * The primary benefit of emitting a function instead of baking its contents into each function that uses it is that it allows us to avoid recomputing the base uri multiple times
@@ -239,20 +187,4 @@ export declare function getParsedAssetsJsonDataForEntrypoint(compilation: Compil
239
187
  export declare function emitPHPWriterAsAsset(writer: PHPWriter, compilation: Compilation, file: string, assetInfo?: AssetInfo): void;
240
188
  export declare function dedent(text: TemplateStringsArray): string;
241
189
  export declare function resolveLegacyBlockScriptsInFolder(folder: string): string[];
242
- /**
243
- * @param compilation
244
- * @param writer
245
- * @param handle
246
- * @param type 'script_module' is NOT supported at this time; however, it is *handled* in this function
247
- * @param inlinedAsset
248
- * @param handleData
249
- * @param file something that represents the file that is being inlined (this is purely for error-reporting purposes)
250
- */
251
- export declare function appendAddInlineAssetCall(compilation: Compilation, writer: PHPWriter, handle: string, type: 'script' | 'style' | 'script_module', inlinedAsset: InlinedAsset, handleData: HandleData, file: string): void;
252
- export declare function synchronousDirIterator(dirPath: string): Generator<import("node:fs").Dirent<string>, void, unknown>;
253
- /**
254
- * A type-guarded version of `instanceof Error` for Node.js.
255
- * @author Joseph JDBar Barron
256
- * @link https://dev.to/jdbar
257
- */
258
- export declare function instanceOfNodeError<T extends new (...args: any) => Error>(value: unknown, errorType: T): value is InstanceType<T> & NodeJS.ErrnoException;
190
+ export {};
@@ -1,32 +1,14 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
17
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
4
  };
19
5
  Object.defineProperty(exports, "__esModule", { value: true });
20
6
  exports.styleExtension = exports.scriptWithModuleExtension = exports.scriptWithoutModuleExtension = exports.scriptExtension = exports.entrypointFields = exports.standardLocationNamesMeta = void 0;
21
7
  exports.isParsedAssetsJson = isParsedAssetsJson;
22
- exports.isStandardLocationName = isStandardLocationName;
23
- exports.isRegisterScriptArgsShorthandName = isRegisterScriptArgsShorthandName;
24
8
  exports.isNormalizedUsageLocations = isNormalizedUsageLocations;
25
9
  exports.constantKeys = constantKeys;
26
10
  exports.constantEntries = constantEntries;
27
11
  exports.determineCurrentSourceType = determineCurrentSourceType;
28
- exports.applyStandards = applyStandards;
29
- exports.resolveStandard = resolveStandard;
30
12
  exports.convertUsageLocationsHandleToEmittableHandle = convertUsageLocationsHandleToEmittableHandle;
31
13
  exports.makeEmittableConfigPHP = makeEmittableConfigPHP;
32
14
  exports.convertEntrypointFieldForAssetType = convertEntrypointFieldForAssetType;
@@ -40,7 +22,6 @@ exports.arrayIsLength = arrayIsLength;
40
22
  exports.kebabCase = kebabCase;
41
23
  exports.loadEnvFile = loadEnvFile;
42
24
  exports.parseEnvFile = parseEnvFile;
43
- exports.newCleanWebpackError = newCleanWebpackError;
44
25
  exports.newWebpackErrorForFile = newWebpackErrorForFile;
45
26
  exports.emitResolveBaseUriFunction = emitResolveBaseUriFunction;
46
27
  exports.getAssetsJson = getAssetsJson;
@@ -48,17 +29,12 @@ exports.getParsedAssetsJsonDataForEntrypoint = getParsedAssetsJsonDataForEntrypo
48
29
  exports.emitPHPWriterAsAsset = emitPHPWriterAsAsset;
49
30
  exports.dedent = dedent;
50
31
  exports.resolveLegacyBlockScriptsInFolder = resolveLegacyBlockScriptsInFolder;
51
- exports.appendAddInlineAssetCall = appendAddInlineAssetCall;
52
- exports.synchronousDirIterator = synchronousDirIterator;
53
- exports.instanceOfNodeError = instanceOfNodeError;
54
- const node_crypto_1 = require("node:crypto");
55
- const node_fs_1 = require("node:fs");
56
- const promises_1 = require("node:fs/promises");
32
+ const node_fs_1 = __importDefault(require("node:fs"));
33
+ const promises_1 = __importDefault(require("node:fs/promises"));
57
34
  const node_path_1 = __importDefault(require("node:path"));
58
35
  const php_writer_1 = require("@plaudit/php-writer");
59
36
  const expressions_1 = require("@plaudit/php-writer/expressions");
60
37
  const webpack_1 = require("webpack");
61
- __exportStar(require("./utils/entrypoint-resolution-logic"), exports);
62
38
  function isParsedAssetsJson(thing) {
63
39
  if (!thing || typeof thing !== 'object') {
64
40
  return false;
@@ -81,12 +57,6 @@ exports.standardLocationNamesMeta = {
81
57
  customizer: { action: "customize_controls_enqueue_scripts" },
82
58
  analytics: { action: "plaudit_enqueue_analytics" },
83
59
  };
84
- function isStandardLocationName(name) {
85
- return name in exports.standardLocationNamesMeta;
86
- }
87
- function isRegisterScriptArgsShorthandName(name) {
88
- return ['lazy', 'eager', 'inline'].includes(name);
89
- }
90
60
  function isNormalizedUsageLocations(usageLocations) {
91
61
  return typeof usageLocations.registerScriptArgs !== 'string';
92
62
  }
@@ -112,35 +82,6 @@ function determineCurrentSourceType(dest, srcIsDirectory) {
112
82
  return dest.directoryLayout;
113
83
  }
114
84
  }
115
- function applyStandards(config) {
116
- switch (config.standard) {
117
- case '2026-03-13':
118
- return {
119
- ...resolveStandard('2026-03-13'),
120
- ...config
121
- };
122
- case undefined:
123
- return config;
124
- default:
125
- throw `Invalid standard: ${config.standard}`;
126
- }
127
- }
128
- function resolveStandard(standard) {
129
- switch (standard) {
130
- case "2026-03-13":
131
- return {
132
- useWebpackResourceFiltering: true,
133
- extensionsVersion: 3,
134
- plainEntrypointsVersion: 2,
135
- srcDir: "src",
136
- outputDir: "dist",
137
- useUnifiedLoader: true,
138
- onlyRunPostCSSOnPCSS: true,
139
- };
140
- default:
141
- return undefined;
142
- }
143
- }
144
85
  function convertUsageLocationsHandleToEmittableHandle(handle, generatedHandle) {
145
86
  const emittableHandle = typeof handle === 'string' ? handle : handle?.(generatedHandle) ?? generatedHandle;
146
87
  return emittableHandle.replaceAll("{basename}", generatedHandle);
@@ -162,9 +103,9 @@ function leadingSlashIt(pathOrSomething) {
162
103
  return pathOrSomething.startsWith('/') ? pathOrSomething : ('/' + pathOrSomething);
163
104
  }
164
105
  exports.scriptExtension = /(?<filename>.+)(?<extension>\.m?[jt]sx?)$/i;
165
- exports.scriptWithoutModuleExtension = /(?<filename>.+)(?<extension>\.[jt]sx?)($|\?)/i;
166
- exports.scriptWithModuleExtension = /(?<filename>.+)(?<extension>\.m[jt]sx?)($|\?)/i;
167
- exports.styleExtension = /(?<filename>.+)(?<extension>\.([ps]?c|sa)ss)($|\?)/i;
106
+ exports.scriptWithoutModuleExtension = /(?<filename>.+)(?<extension>\.[jt]sx?)$/i;
107
+ exports.scriptWithModuleExtension = /(?<filename>.+)(?<extension>\.m[jt]sx?)$/i;
108
+ exports.styleExtension = /(?<filename>.+)(?<extension>\.(p?c|sa)ss)$/i;
168
109
  function scriptOrStyleTest(entryPath, scriptExtension) {
169
110
  return scriptExtension.test(entryPath) ? "script" : (exports.styleExtension.test(entryPath) ? "style" : "");
170
111
  }
@@ -194,7 +135,7 @@ function kebabCase(value) {
194
135
  return kebabCaseRegexes.reduce((str, [pattern, replacement]) => str.replace(pattern, replacement), value).toLowerCase();
195
136
  }
196
137
  async function loadEnvFile(filePath) {
197
- return (0, promises_1.readFile)(filePath, 'utf-8').then(parseEnvFile, () => ({}));
138
+ return promises_1.default.readFile(filePath, 'utf-8').then(parseEnvFile, () => ({}));
198
139
  }
199
140
  function parseEnvFile(contents) {
200
141
  return Object.fromEntries(contents.split(/(\r?\n)+/).map(line => line.trim())
@@ -204,13 +145,9 @@ function parseEnvFile(contents) {
204
145
  return equalsPos === -1 ? [line, ""] : [line.substring(0, equalsPos), line.substring(equalsPos + 1)];
205
146
  }));
206
147
  }
207
- function newCleanWebpackError(error) {
148
+ function newWebpackErrorForFile(error, file) {
208
149
  const res = typeof error === 'string' ? new webpack_1.WebpackError(error) : new webpack_1.WebpackError(...error);
209
150
  res.hideStack = true;
210
- return res;
211
- }
212
- function newWebpackErrorForFile(error, file) {
213
- const res = newCleanWebpackError(error);
214
151
  res.file = file;
215
152
  return res;
216
153
  }
@@ -301,65 +238,15 @@ function dedent(text) {
301
238
  }
302
239
  function resolveLegacyBlockScriptsInFolder(folder) {
303
240
  const blockScriptEntrypoints = [];
304
- for (const blockDir of (0, node_fs_1.readdirSync)(folder)) {
241
+ for (const blockDir of node_fs_1.default.readdirSync(folder)) {
305
242
  const fullBlockDir = node_path_1.default.join(folder, blockDir);
306
243
  const packageJSON = node_path_1.default.join(fullBlockDir, 'package.json');
307
- if ((0, node_fs_1.existsSync)(packageJSON)) {
308
- const main = JSON.parse((0, node_fs_1.readFileSync)(packageJSON, 'utf8'))['main'];
309
- if (main && (0, node_fs_1.existsSync)(node_path_1.default.join(fullBlockDir, main))) {
244
+ if (node_fs_1.default.existsSync(packageJSON)) {
245
+ const main = JSON.parse(node_fs_1.default.readFileSync(packageJSON, 'utf8'))['main'];
246
+ if (main && node_fs_1.default.existsSync(node_path_1.default.join(fullBlockDir, main))) {
310
247
  blockScriptEntrypoints.push(node_path_1.default.join(fullBlockDir, main));
311
248
  }
312
249
  }
313
250
  }
314
251
  return blockScriptEntrypoints;
315
252
  }
316
- /**
317
- * @param compilation
318
- * @param writer
319
- * @param handle
320
- * @param type 'script_module' is NOT supported at this time; however, it is *handled* in this function
321
- * @param inlinedAsset
322
- * @param handleData
323
- * @param file something that represents the file that is being inlined (this is purely for error-reporting purposes)
324
- */
325
- function appendAddInlineAssetCall(compilation, writer, handle, type, inlinedAsset, handleData, file) {
326
- if (type === 'script_module') {
327
- throw newWebpackErrorForFile("WordPress does not support inlined script modules", file);
328
- }
329
- if (handleData.rest[0]?.length) { // If there are any dependencies
330
- compilation.errors.push(newWebpackErrorForFile("Inlined scripts MUST NOT have dependencies. It WILL cause runtime inconsistencies and potentially cause sever performance issues", handleData.src));
331
- }
332
- let contents;
333
- if (compilation.outputOptions.path?.endsWith("-dev")) {
334
- contents = inlinedAsset.contents;
335
- }
336
- else {
337
- contents = inlinedAsset.contents.replaceAll(/\/\*#\s+sourceMappingURL=.*?\*\/|\/\/#\s+sourceMappingURL=[^\r\n]*?([\r\n]|$)/gis, "$1");
338
- }
339
- const args = [handle, new expressions_1.HereOrNowDoc(`plaudit_inlined_${type}_${(0, node_crypto_1.createHash)('md5').update(handle).digest("hex")}`, contents.trim(), false)];
340
- if (type === 'script' && inlinedAsset.position === 'before') {
341
- args.push('before');
342
- }
343
- writer.call(`wp_add_inline_${type}`, args);
344
- }
345
- function* synchronousDirIterator(dirPath) {
346
- try {
347
- using dir = (0, node_fs_1.opendirSync)(dirPath);
348
- for (let dirent; (dirent = dir.readSync()) !== null;) {
349
- yield dirent;
350
- }
351
- }
352
- catch (e) {
353
- if (!instanceOfNodeError(e, Error) || e.code !== 'ENOENT') {
354
- throw e;
355
- }
356
- }
357
- }
358
- /**
359
- * A type-guarded version of `instanceof Error` for Node.js.
360
- * @author Joseph JDBar Barron
361
- * @link https://dev.to/jdbar
362
- */
363
- function instanceOfNodeError(value, errorType) {
364
- return !!value && value instanceof errorType;
365
- }
@@ -3,7 +3,7 @@ import type { AdditionalDependencyInjectorPlugin } from "../plugins/AdditionalDe
3
3
  import { EntrypointFields, PlauditWordpressWebpackConfig, BlockEntrypointInfo, VerifiedAdvancedOutputConfig, MinimumViableMetadata, WebpackPlugin } from "../shared";
4
4
  import type { Compiler, Configuration, DynamicEntryPlugin, WebpackPluginInstance } from "webpack";
5
5
  import type WebpackRemoveEmptyScriptsPlugin from "webpack-remove-empty-scripts";
6
- export type VerifiedPlauditWordpressWebpackConfig = Required<Omit<PlauditWordpressWebpackConfig, 'variables' | 'src' | 'externals' | 'standard'>> & {
6
+ export type VerifiedPlauditWordpressWebpackConfig = Required<Omit<PlauditWordpressWebpackConfig, 'variables' | 'src' | 'externals'>> & {
7
7
  variablesFilePath?: string;
8
8
  currentVariables: Record<string, any>;
9
9
  } & Pick<PlauditWordpressWebpackConfig, 'externals'>;