@plaudit/webpack-extensions 2.62.3 → 2.63.1
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/plugins/AbstractMultiPhaseLibraryAndEntryPlugin.d.ts +19 -0
- package/build/plugins/AbstractMultiPhaseLibraryAndEntryPlugin.js +62 -0
- package/build/plugins/AbstractMultiPhaseLibraryPlugin.d.ts +0 -6
- package/build/plugins/AbstractMultiPhaseLibraryPlugin.js +0 -68
- package/build/plugins/ExtensionsConfigFileGeneratorPlugin.d.ts +6 -5
- package/build/plugins/ExtensionsConfigFileGeneratorPlugin.js +53 -41
- package/build/plugins/PlainEntrypointsConfigFileGeneratorPlugin.d.ts +4 -4
- package/build/plugins/PlainEntrypointsConfigFileGeneratorPlugin.js +9 -14
- package/build/plugins/PlainEntrypointsStyleBlockJSONPlugin.d.ts +4 -3
- package/build/plugins/PlainEntrypointsStyleBlockJSONPlugin.js +21 -30
- package/build/plugins/SpecialAssetHandlingPlugin.d.ts +1 -1
- package/build/plugins/SpecialAssetHandlingPlugin.js +1 -1
- package/build/shared.d.ts +9 -6
- package/build/shared.js +11 -5
- package/build/utils/common-config-helpers.d.ts +12 -4
- package/build/utils/common-config-helpers.js +39 -26
- package/build/utils/php-writer.d.ts +38 -9
- package/build/utils/php-writer.js +69 -25
- package/build/wordpress-scripts-wrapper.js +41 -23
- package/package.json +3 -3
|
@@ -211,15 +211,17 @@ function buildVerifiedConfig(config) {
|
|
|
211
211
|
const allocatedDestinations = {};
|
|
212
212
|
const partiallyVerifiedSources = rawSources.map(rawSource => {
|
|
213
213
|
const destination = rawSource[1].destination;
|
|
214
|
+
const locations = typeof rawSource[1].locations === 'string' || typeof rawSource[1].locations === 'function'
|
|
215
|
+
? { handle: rawSource[1].locations } : rawSource[1].locations ?? {};
|
|
214
216
|
if (destination !== undefined) {
|
|
215
217
|
const effectiveDestination = toEffectiveWebpackDestination(destination);
|
|
216
218
|
allocatedDestinations[effectiveDestination] = rawSource[0]; // We need to pre-populate the allocatedDestinations map with statically-declared destinations
|
|
217
|
-
return [rawSource[0], { ...rawSource[1], destination, effectiveDestination, staticallyDeclaredDestination: true }];
|
|
219
|
+
return [rawSource[0], { ...rawSource[1], locations, destination, effectiveDestination, staticallyDeclaredDestination: true }];
|
|
218
220
|
}
|
|
219
221
|
else {
|
|
220
222
|
const naiveDestination = deriveNaiveDestinationFromUnverifiedSourceEntry(rawSource, srcPrefixes);
|
|
221
223
|
const effectiveDestination = toEffectiveWebpackDestination(naiveDestination);
|
|
222
|
-
return [rawSource[0], { ...rawSource[1], destination: naiveDestination, effectiveDestination, staticallyDeclaredDestination: false }];
|
|
224
|
+
return [rawSource[0], { ...rawSource[1], locations, destination: naiveDestination, effectiveDestination, staticallyDeclaredDestination: false }];
|
|
223
225
|
}
|
|
224
226
|
});
|
|
225
227
|
const dynamicEffectiveDestinationsWithExpectedNaiveDuplicates = partiallyVerifiedSources
|
|
@@ -482,31 +484,47 @@ function processIndividualWebpackConfig(config, webpackConfig, sources) {
|
|
|
482
484
|
}
|
|
483
485
|
function makeBlocksWebpackConfig(config, commonConfig, webpackConfig, dest, src, srcRoot, plugins) {
|
|
484
486
|
const { processingModules } = commonConfig;
|
|
485
|
-
const blockJSONManagingPlugin = new PlainEntrypointsStyleBlockJSONPlugin_1.PlainEntrypointsStyleBlockJSONPlugin(config, dest.destination, plugins.find(p => p instanceof webpack_remove_empty_scripts_1.default));
|
|
487
|
+
const blockJSONManagingPlugin = new PlainEntrypointsStyleBlockJSONPlugin_1.PlainEntrypointsStyleBlockJSONPlugin(config, dest.destination, plugins.find(p => p instanceof webpack_remove_empty_scripts_1.default), webpackConfig.context ?? process.cwd(), (0, common_config_helpers_1.resolveEntryFromDirectory)(commonConfig, srcRoot, dest));
|
|
486
488
|
plugins.push(blockJSONManagingPlugin);
|
|
487
489
|
if (config.processTranslationConfigs && !processingModules) {
|
|
488
490
|
plugins.push(new WPMLConfigBuilder_1.WPMLConfigBuilderPlugin(dest.destination));
|
|
489
491
|
}
|
|
490
|
-
return (0, common_config_helpers_1.commonMakeWebpackConfig)(config, commonConfig, webpackConfig, true, dest, src, srcRoot,
|
|
492
|
+
return (0, common_config_helpers_1.commonMakeWebpackConfig)(config, commonConfig, webpackConfig, true, dest, src, srcRoot, {}, plugins);
|
|
491
493
|
}
|
|
492
494
|
function makeExtensionsWebpackConfig(config, commonConfig, webpackConfig, dest, src, srcRoot, plugins) {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
const file = (0, common_config_helpers_1.joinPossiblyAbsolutePaths)(srcRoot, dirent.name);
|
|
503
|
-
rawEntrypoints.push([node_path_1.default.join(dest.destination, node_path_1.default.basename(file, node_path_1.default.extname(file))), { import: file, library: { type: plugin.libraryType } }]);
|
|
495
|
+
if (config.extensionsVersion > 1) {
|
|
496
|
+
const entry = async () => {
|
|
497
|
+
const rawEntrypoints = [];
|
|
498
|
+
for await (const dirent of await promises_1.default.opendir(srcRoot)) {
|
|
499
|
+
if (dirent.isFile() && !dirent.name.startsWith("~")) {
|
|
500
|
+
if (commonConfig.scriptExtension.test(dirent.name) || shared_1.styleExtension.test(dirent.name)) {
|
|
501
|
+
const file = (0, common_config_helpers_1.joinPossiblyAbsolutePaths)(srcRoot, dirent.name);
|
|
502
|
+
rawEntrypoints.push([node_path_1.default.join(dest.destination, node_path_1.default.basename(file, node_path_1.default.extname(file))), { import: [file], plauditMetadata: "entrypoint-v2" }]);
|
|
503
|
+
}
|
|
504
504
|
}
|
|
505
505
|
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
506
|
+
return Object.fromEntries(rawEntrypoints);
|
|
507
|
+
};
|
|
508
|
+
plugins.push(new ExtensionsConfigFileGeneratorPlugin_1.ExtensionsConfigFileGeneratorPlugin(config, srcRoot, dest, webpackConfig.context ?? process.cwd(), entry));
|
|
509
|
+
return (0, common_config_helpers_1.commonMakeWebpackConfig)(config, commonConfig, webpackConfig, true, dest, src, srcRoot, {}, plugins);
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
const plugin = new ExtensionsConfigFileGeneratorPluginV1_1.ExtensionsConfigFileGeneratorPluginV1(dest.destination);
|
|
513
|
+
plugins.push(plugin);
|
|
514
|
+
const entry = async () => {
|
|
515
|
+
const rawEntrypoints = [];
|
|
516
|
+
for await (const dirent of await promises_1.default.opendir(srcRoot)) {
|
|
517
|
+
if (dirent.isFile() && !dirent.name.startsWith("~")) {
|
|
518
|
+
if (commonConfig.scriptExtension.test(dirent.name) || shared_1.styleExtension.test(dirent.name)) {
|
|
519
|
+
const file = (0, common_config_helpers_1.joinPossiblyAbsolutePaths)(srcRoot, dirent.name);
|
|
520
|
+
rawEntrypoints.push([node_path_1.default.join(dest.destination, node_path_1.default.basename(file, node_path_1.default.extname(file))), file]);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
return Object.fromEntries(rawEntrypoints);
|
|
525
|
+
};
|
|
526
|
+
return (0, common_config_helpers_1.commonMakeWebpackConfig)(config, commonConfig, webpackConfig, true, dest, src, srcRoot, entry, plugins);
|
|
527
|
+
}
|
|
510
528
|
}
|
|
511
529
|
function makePlainV1WebpackConfig(config, commonConfig, webpackConfig, dest, src, srcRoot, plugins, srcIsDirectory) {
|
|
512
530
|
const baseDest = stripExtension(dest.destination);
|
|
@@ -516,13 +534,13 @@ function makePlainV1WebpackConfig(config, commonConfig, webpackConfig, dest, src
|
|
|
516
534
|
return (0, common_config_helpers_1.commonMakeWebpackConfig)(config, commonConfig, webpackConfig, srcIsDirectory, dest, src, srcRoot, entry, plugins);
|
|
517
535
|
}
|
|
518
536
|
function makePlainV2WebpackConfig(config, commonConfig, webpackConfig, dest, src, srcRoot, plugins, srcIsDirectory) {
|
|
519
|
-
const locations = typeof dest.locations === 'string' ? { handle: dest.locations } : dest.locations ?? {};
|
|
520
|
-
plugins.push(new PlainEntrypointsConfigFileGeneratorPlugin_1.PlainEntrypointsConfigFileGeneratorPlugin(process.cwd(), config.outputDir, locations, config.plainEntrypointsHandlePrefix, config.useUnifiedLoader));
|
|
521
537
|
const baseDest = stripExtension(dest.destination);
|
|
522
538
|
const entry = srcIsDirectory // This being true implies that srcRoot is not an array
|
|
523
539
|
? (0, common_config_helpers_1.resolveEntryFromDirectory)(commonConfig, srcRoot, dest)
|
|
524
|
-
: () => ({ [baseDest]: srcRoot });
|
|
525
|
-
|
|
540
|
+
: () => ({ [baseDest]: { import: Array.isArray(srcRoot) ? srcRoot : [srcRoot], plauditMetadata: "plain-entrypoint" } });
|
|
541
|
+
const requester = new PlainEntrypointsConfigFileGeneratorPlugin_1.PlainEntrypointsConfigFileGeneratorPlugin(process.cwd(), config.outputDir, dest.locations, config.plainEntrypointsHandlePrefix, config.useUnifiedLoader, webpackConfig.context ?? process.cwd(), entry);
|
|
542
|
+
plugins.push(requester);
|
|
543
|
+
return (0, common_config_helpers_1.commonMakeWebpackConfig)(config, commonConfig, webpackConfig, srcIsDirectory, dest, src, srcRoot, {}, plugins);
|
|
526
544
|
}
|
|
527
545
|
function stripExtension(filepath) {
|
|
528
546
|
return node_path_1.default.join(node_path_1.default.dirname(filepath), node_path_1.default.basename(filepath, node_path_1.default.extname(filepath)));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plaudit/webpack-extensions",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.63.1",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"files": [
|
|
6
6
|
"/build"
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"@plaudit/postcss-silent-extend": "^3.0.0",
|
|
36
36
|
"@plaudit/postcss-strip-units": "^3.0.0",
|
|
37
37
|
"@plaudit/postcss-variables": "^1.1.0",
|
|
38
|
-
"@wordpress/dependency-extraction-webpack-plugin": "^6.
|
|
39
|
-
"@wordpress/scripts": "^30.
|
|
38
|
+
"@wordpress/dependency-extraction-webpack-plugin": "^6.30.0",
|
|
39
|
+
"@wordpress/scripts": "^30.23.0",
|
|
40
40
|
"autoprefixer": "^10.4.21",
|
|
41
41
|
"browser-sync": "^3.0.4",
|
|
42
42
|
"clean-webpack-plugin": "^4.0.0",
|