@plaudit/webpack-extensions 2.82.0 → 2.82.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.
package/build/shared.d.ts
CHANGED
|
@@ -133,7 +133,7 @@ export type MinimumViableMetadata = {
|
|
|
133
133
|
};
|
|
134
134
|
export declare function convertUsageLocationsHandleToEmittableHandle(handle: UsageLocations['handle'], generatedHandle: string): string;
|
|
135
135
|
export declare function makeEmittableConfigPHP(data: any, asFullFile: boolean, parentIndent?: string): string;
|
|
136
|
-
export declare const entrypointFields: readonly ["editorStyle", "viewStyle", "style", "editorScript", "viewScript", "script", "viewScriptModule"
|
|
136
|
+
export declare const entrypointFields: readonly ["editorStyle", "viewStyle", "style", "editorScript", "viewScript", "script", "viewScriptModule"];
|
|
137
137
|
export type EntrypointFields = (typeof entrypointFields[number])[];
|
|
138
138
|
export declare function convertEntrypointFieldForAssetType(entrypointField: EntrypointFields[number], assetType: 'script' | 'style'): EntrypointFields[number];
|
|
139
139
|
export declare function leadingSlashIt(pathOrSomething: string): string;
|
|
@@ -143,7 +143,7 @@ export declare const scriptWithModuleExtension: RegExp;
|
|
|
143
143
|
export declare const styleExtension: RegExp;
|
|
144
144
|
export declare function scriptOrStyleTest(entryPath: string, scriptExtension: RegExp): "style" | "script" | "";
|
|
145
145
|
export declare function isStyleField(field: string): field is 'style' | 'viewStyle' | 'editorStyle';
|
|
146
|
-
export declare function isScriptModuleField(field: string): field is '
|
|
146
|
+
export declare function isScriptModuleField(field: string): field is 'viewScriptModule';
|
|
147
147
|
export declare function getHandleGroup(field: string): 'styleHandles' | 'scriptHandles' | 'scriptModuleHandles';
|
|
148
148
|
export declare function hasAtLeastOneItem<T>(list: T[]): list is [T, ...T[]];
|
|
149
149
|
export type TupleOf<T, N extends number> = N extends N ? number extends N ? T[] : _TupleOf<T, N, []> : never;
|
package/build/shared.js
CHANGED
|
@@ -89,10 +89,10 @@ function makeEmittableConfigPHP(data, asFullFile, parentIndent = "") {
|
|
|
89
89
|
.replaceAll(/'rest' => \[\n\t+(\[(?:'[^']+')?]),\n\t+('[^']+')(?:,\n\t+(\[[^\n]+]))?\n\t+]/gs, (_, deps, hash, args) => `'rest' => [${[deps, hash, args].filter(value => !!value).join(", ")}]`);
|
|
90
90
|
return asFullFile ? `<?php return ${prettyPrintedMetadata};` : prettyPrintedMetadata.trim();
|
|
91
91
|
}
|
|
92
|
-
exports.entrypointFields = ["editorStyle", "viewStyle", "style", "editorScript", "viewScript", "script", "viewScriptModule"
|
|
92
|
+
exports.entrypointFields = ["editorStyle", "viewStyle", "style", "editorScript", "viewScript", "script", "viewScriptModule"];
|
|
93
93
|
function convertEntrypointFieldForAssetType(entrypointField, assetType) {
|
|
94
94
|
// Using these word fragments instead of the full words allows us to avoid having to deal with the capitalization of the first letter
|
|
95
|
-
const searchRep = assetType === 'script' ? ['tyle', 'cript'] : [
|
|
95
|
+
const searchRep = assetType === 'script' ? ['tyle', 'cript'] : [/cript(?:Module)?/, 'tyle'];
|
|
96
96
|
return entrypointField.replace(...searchRep);
|
|
97
97
|
}
|
|
98
98
|
function leadingSlashIt(pathOrSomething) {
|
|
@@ -36,7 +36,7 @@ function mapToRealEntrypoints(entrypoint, dir, supportedExtensions, args) {
|
|
|
36
36
|
.filter(ep => supportedExtensions(ep) && node_fs_1.default.statSync(ep, { throwIfNoEntry: false })?.isFile())
|
|
37
37
|
.map(ep => {
|
|
38
38
|
const parsedEntrypoint = node_path_1.default.parse(ep);
|
|
39
|
-
const entrypointField = shared_1.styleExtension.test(ep) ? 'style' : shared_1.scriptWithModuleExtension.test(ep) ? '
|
|
39
|
+
const entrypointField = shared_1.styleExtension.test(ep) ? 'style' : shared_1.scriptWithModuleExtension.test(ep) ? 'viewScriptModule' : 'script';
|
|
40
40
|
const fakeEntrypointInfo = {
|
|
41
41
|
blockJsonOrigin: args.entrypointJsonOrigin,
|
|
42
42
|
entrypointField,
|
|
@@ -431,7 +431,7 @@ function commonConfigProcessingPrep(config, webpackConfig) {
|
|
|
431
431
|
const processingModules = webpackConfig.output?.module ?? false;
|
|
432
432
|
if (processingModules) {
|
|
433
433
|
scriptExtension = shared_1.scriptWithModuleExtension;
|
|
434
|
-
entrypointFields = ["viewScriptModule"
|
|
434
|
+
entrypointFields = ["viewScriptModule"];
|
|
435
435
|
}
|
|
436
436
|
else {
|
|
437
437
|
scriptExtension = shared_1.scriptWithoutModuleExtension;
|
|
@@ -467,6 +467,17 @@ function destToKey(dest) {
|
|
|
467
467
|
return [dest.assumeGlobalizedPlauditLibraries, dest.bundleAnalyzer, externalize].join("~");
|
|
468
468
|
}
|
|
469
469
|
function processIndividualWebpackConfig(config, webpackConfig, sources, canClean) {
|
|
470
|
+
if (webpackConfig.output?.module) {
|
|
471
|
+
// This ensures that module files are emitted as module files
|
|
472
|
+
webpackConfig = {
|
|
473
|
+
...webpackConfig,
|
|
474
|
+
output: {
|
|
475
|
+
...webpackConfig.output,
|
|
476
|
+
filename: '[name].mjs',
|
|
477
|
+
chunkFilename: '[name].mjs?ver=[chunkhash]',
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
}
|
|
470
481
|
const commonConfig = commonConfigProcessingPrep(config, webpackConfig);
|
|
471
482
|
const { processingModules, scriptExtension } = commonConfig;
|
|
472
483
|
const allSrcRoots = sources.map(([src, dest]) => {
|
|
@@ -573,7 +584,7 @@ function stripExtension(filepath) {
|
|
|
573
584
|
}
|
|
574
585
|
module.exports = function (config, webpackConfig = require("@wordpress/scripts/config/webpack.config")) {
|
|
575
586
|
const { cfg, sources } = buildVerifiedConfig(config);
|
|
576
|
-
if (Array.isArray(webpackConfig) && (0, shared_1.
|
|
587
|
+
if (Array.isArray(webpackConfig) && (0, shared_1.arrayIsLength)(webpackConfig, 1)) {
|
|
577
588
|
webpackConfig = webpackConfig[0];
|
|
578
589
|
}
|
|
579
590
|
if (Array.isArray(webpackConfig)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plaudit/webpack-extensions",
|
|
3
|
-
"version": "2.82.
|
|
3
|
+
"version": "2.82.2",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"files": [
|
|
6
6
|
"/build"
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@plaudit/gutenberg-api-extensions": "^2.
|
|
23
|
+
"@plaudit/gutenberg-api-extensions": "^2.83.0",
|
|
24
24
|
"@types/browser-sync-webpack-plugin": "^2.2.5",
|
|
25
25
|
"@types/node": "^25.0.3",
|
|
26
26
|
"@types/postcss-functions": "^4.0.4",
|