@plaudit/webpack-extensions 3.11.0-wp.demo → 3.12.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/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.12.0] - 2026-06-23
9
+ ### Added
10
+ - Logic to treat the nice name of a file as the suffix of its handle
11
+
12
+ ### Changed
13
+ - The handle-part-separator for plain entrypoints from `.` to `/`
14
+
8
15
  ## [3.11.0] - 2026-06-22
9
16
  ### Added
10
17
  - Logic to allow our internal PostCSS plugins to be "optional"
@@ -43,15 +43,15 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
43
43
  for (const { src, rest, locations, type, handleName, lazyLoader, ...otherProps } of handles) {
44
44
  const cleanBasename = (0, node_path_1.basename)(src).replace(/_(?:script(?:-\d+)?\.js|style(?:-\d+)?\.css)$|(?<!_(script|style))\.(js|css)$/, "");
45
45
  let finalHandleName;
46
- if (typeof handleName === 'string') {
47
- finalHandleName = (0, shared_1.convertUsageLocationsHandleToEmittableHandle)(handleName, cleanBasename);
46
+ const handleNameMap = usedHandleNames[type];
47
+ const baseFinalHandleName = finalHandleName = `${handlePrefix}/${(0, shared_1.convertUsageLocationsHandleToEmittableHandle)((0, shared_1.kebabCase)(cleanBasename), cleanBasename)}`;
48
+ for (let count = 0; finalHandleName in handleNameMap && handleNameMap[finalHandleName] !== src;) {
49
+ finalHandleName = `${baseFinalHandleName}-${++count}`;
50
+ }
51
+ if (typeof handleName === 'string' || typeof handleName === 'function') {
52
+ finalHandleName = (0, shared_1.convertUsageLocationsHandleToEmittableHandle)(handleName, finalHandleName);
48
53
  }
49
54
  else {
50
- const handleNameMap = usedHandleNames[type];
51
- const baseFinalHandleName = finalHandleName = `${handlePrefix}.${(0, shared_1.convertUsageLocationsHandleToEmittableHandle)((0, shared_1.kebabCase)(cleanBasename), cleanBasename)}`;
52
- for (let count = 0; finalHandleName in handleNameMap && handleNameMap[finalHandleName] !== src;) {
53
- finalHandleName = `${baseFinalHandleName}-${++count}`;
54
- }
55
55
  handleNameMap[finalHandleName] = src;
56
56
  }
57
57
  plainEntrypointsConfig[`${type}Handles`][finalHandleName] = { src, rest, locations, type, lazyLoader, ...otherProps };
@@ -40,13 +40,13 @@ function mapToRealEntrypoints(entrypoint, dir, supportedExtensions, args) {
40
40
  .map(([ep, rawPathQueryParameters]) => {
41
41
  const parsedEntrypoint = (0, node_path_1.parse)(ep);
42
42
  const entrypointField = shared_1.styleExtension.test(ep) ? 'style' : shared_1.scriptWithModuleExtension.test(ep) ? 'viewScriptModule' : 'script';
43
- const { flags: enqueuingFlags, remainder: pathQueryParameters } = (0, path_query_and_related_helpers_1.unpackEnqueuingControlFlagsFromPathQueryParameters)(rawPathQueryParameters, ep, 'path query parameters');
43
+ const { flags: enqueuingFlags, remainder: pathQueryParameters, handle } = (0, path_query_and_related_helpers_1.unpackEnqueuingControlFlagsFromPathQueryParameters)(rawPathQueryParameters, ep, 'path query parameters');
44
44
  const fakeEntrypointInfo = {
45
45
  blockJsonOrigin: args.entrypointJsonOrigin,
46
46
  entrypointField,
47
47
  originalValue: ep,
48
48
  entrypointName: parsedEntrypoint.name,
49
- handle: (0, shared_1.convertUsageLocationsHandleToEmittableHandle)(dest.locations.handle, parsedEntrypoint.name),
49
+ handle: (0, shared_1.convertUsageLocationsHandleToEmittableHandle)(handle ?? dest.locations.handle, parsedEntrypoint.name),
50
50
  handleGroup: (0, shared_1.getHandleGroup)(entrypointField),
51
51
  dest,
52
52
  absoluteSrc: ep,
@@ -228,6 +228,15 @@ function resolveEntryFromDirectory(commonConfig, srcRoot, dest) {
228
228
  a[entry.entrypointName] = (a[entry.entrypointName] !== undefined);
229
229
  return a;
230
230
  }, {});
231
+ const getDefaultHandle = (presentEntrypoint) => {
232
+ const baseSuffix = `_${(0, shared_1.isStyleField)(presentEntrypoint.entrypointField) ? "style" : "script"}`;
233
+ let count = 0, suffix = baseSuffix, deduplicatedEntrypointName;
234
+ while (((deduplicatedEntrypointName = (presentEntrypoint.entrypointName + suffix)) in allocatedDestinations)
235
+ && allocatedDestinations[deduplicatedEntrypointName] !== presentEntrypoint.originalValue) {
236
+ suffix = baseSuffix + "_" + (++count);
237
+ }
238
+ return { count, suffix, deduplicatedEntrypointName };
239
+ };
231
240
  const handlePrefix = blockJson['name']?.toString() ?? `__UNKNOWN_PREFIX__/${dirent.name}`;
232
241
  const allocatedDestinations = {};
233
242
  const resolvedBlockEntrypoints = presentEntrypoints
@@ -236,11 +245,17 @@ function resolveEntryFromDirectory(commonConfig, srcRoot, dest) {
236
245
  const overallSourceRelativeName = (0, node_path_1.relative)(overallSource, (0, node_path_1.normalize)((0, node_path_1.join)(blockJsonOrigin, (0, node_path_1.relative)(overallSource, presentEntrypoint.extensionlessExpectedSrc))));
237
246
  const handleSuffix = (0, shared_1.convertUsageLocationsHandleToEmittableHandle)(dest.locations.handle, overallSourceRelativeName);
238
247
  const handleGroup = (0, shared_1.getHandleGroup)(presentEntrypoint.entrypointField);
239
- if (presentEntrypoint.handle) {
240
- (seenExplicitHandles[handleGroup][presentEntrypoint.handle] ??= []).push(overallSource);
248
+ const explicitlySetHandle = typeof presentEntrypoint.handle === 'string'
249
+ ? presentEntrypoint.handle
250
+ : presentEntrypoint.handle?.(getDefaultHandle(presentEntrypoint).deduplicatedEntrypointName);
251
+ if (explicitlySetHandle) {
252
+ if (explicitlySetHandle.length < 5) {
253
+ throw (0, shared_1.newWebpackErrorForFile)(`The handle was invalid. Received: ${explicitlySetHandle}. Expected: a string that is at least 5 characters long`, overallSourceRelativeName);
254
+ }
255
+ (seenExplicitHandles[handleGroup][explicitlySetHandle] ??= []).push(overallSource);
241
256
  }
242
257
  if (!entrypointNamesWithEffectiveDuplicates[presentEntrypoint.entrypointName]) {
243
- return { blockJsonOrigin, ...presentEntrypoint, handle: presentEntrypoint.handle ?? `${handlePrefix}/${handleSuffix}`, dest, handleGroup };
258
+ return { blockJsonOrigin, ...presentEntrypoint, handle: explicitlySetHandle ?? `${handlePrefix}/${handleSuffix}`, dest, handleGroup };
244
259
  }
245
260
  const baseSuffix = `_${(0, shared_1.isStyleField)(presentEntrypoint.entrypointField) ? "style" : "script"}`;
246
261
  let count = 0, suffix = baseSuffix, deduplicatedEntrypointName;
@@ -255,7 +270,7 @@ function resolveEntryFromDirectory(commonConfig, srcRoot, dest) {
255
270
  ...presentEntrypoint,
256
271
  entrypointName: deduplicatedEntrypointName,
257
272
  extensionlessExpectedSrc: deduplicatedExtensionlessExpectedSrc,
258
- handle: presentEntrypoint.handle ?? `${handlePrefix}/${count ? handleSuffix + "_" + count : handleSuffix}`, handleGroup,
273
+ handle: explicitlySetHandle ?? `${handlePrefix}/${count ? handleSuffix + "_" + count : handleSuffix}`, handleGroup,
259
274
  dest
260
275
  };
261
276
  });
@@ -1,10 +1,10 @@
1
- import { RealUsageLocations } from "../shared";
1
+ import { RealUsageLocations, UsageLocations } from "../shared";
2
2
  import { NormalizedEnqueuingControlFlags } from "./path-query-and-related-helpers";
3
3
  export type ParsedLocationEncodingFilename = {
4
4
  type: 'script' | 'style' | 'script-module';
5
5
  locations: RealUsageLocations & {
6
6
  register?: boolean | number;
7
- };
7
+ } & Pick<UsageLocations, 'handle'>;
8
8
  flags: NormalizedEnqueuingControlFlags;
9
9
  niceName?: string;
10
10
  };
@@ -78,6 +78,12 @@ function parseLocationEncodingFilename(filename) {
78
78
  if (Object.values(locations).length === 0) {
79
79
  return undefined;
80
80
  }
81
+ if (niceName !== undefined) {
82
+ locations.handle = generatedHandle => {
83
+ const lastSlash = generatedHandle.lastIndexOf('/');
84
+ return (lastSlash > 0 ? generatedHandle.substring(0, lastSlash) : generatedHandle) + "/" + niceName;
85
+ };
86
+ }
81
87
  return { type, locations, flags, niceName };
82
88
  }
83
89
  function parseLocationEncodingFilenameForBlock(filename, errorBuilder = shared_1.newWebpackErrorForFile) {
@@ -1,5 +1,5 @@
1
1
  import type { Compilation } from "webpack";
2
- import { type InlinedAsset, type PathQueryParameters, type ScriptArgsObject } from "../shared";
2
+ import { type InlinedAsset, type PathQueryParameters, type ScriptArgsObject, type UsageLocations } from "../shared";
3
3
  export declare function getAssetFileContents(compilation: Compilation, name: string): string;
4
4
  export declare function unpackPotentiallyPrefixedFilePath(filePath: string): [string, PathQueryParameters | undefined];
5
5
  /**
@@ -39,7 +39,7 @@ export type NormalizedEnqueuingControlFlags = {
39
39
  export declare function mergeTwoEnqueuingControlFlagSets(file: string, ...argsBlocks: (NormalizedEnqueuingControlFlags | undefined)[]): NormalizedEnqueuingControlFlags | undefined;
40
40
  export declare function unpackEnqueuingControlFlagsFromPathQueryParameters(pathQueryParameters: PathQueryParameters | undefined, file: string, sourceType: 'registerScriptArgs' | 'path query parameters'): {
41
41
  flags?: NormalizedEnqueuingControlFlags;
42
- handle?: string;
42
+ handle?: UsageLocations['handle'];
43
43
  remainder?: PathQueryParameters;
44
44
  };
45
45
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "3.11.0-wp.demo",
3
+ "version": "3.12.0",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "files": [
6
6
  "/dist",
@@ -43,9 +43,12 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@plaudit/php-writer": "^1.5.2",
46
+ "@plaudit/postcss-color-function": "^5.1.0",
47
+ "@plaudit/postcss-strip-units": "^3.0.0",
48
+ "@plaudit/postcss-variables": "^2.0.1",
46
49
  "@wordpress/dependency-extraction-webpack-plugin": "^6.48.1",
47
50
  "@wordpress/scripts": "^32.4.1",
48
- "autoprefixer": "^10.5.0",
51
+ "autoprefixer": "^10.5.1",
49
52
  "browser-sync": "^3.0.4",
50
53
  "copy-webpack-plugin": "10.2.4",
51
54
  "css-minimizer-webpack-plugin": "^8.0.0",