@plaudit/webpack-extensions 3.21.2 → 4.0.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 +13 -1
- package/USER-GUIDE.md +2 -1
- package/dist/api/asset-information-emission.d.ts +74 -0
- package/dist/api/asset-information-emission.d.ts.map +1 -0
- package/dist/api/asset-information-emission.js +398 -0
- package/dist/api/asset-information-emission.js.map +1 -0
- package/dist/api/configuration.d.ts +102 -0
- package/dist/api/configuration.d.ts.map +1 -0
- package/dist/api/configuration.js +83 -0
- package/dist/api/configuration.js.map +1 -0
- package/dist/api/coordinatable-emitter.d.ts +27 -0
- package/dist/api/coordinatable-emitter.d.ts.map +1 -0
- package/dist/api/coordinatable-emitter.js +20 -0
- package/dist/api/coordinatable-emitter.js.map +1 -0
- package/dist/api/entries/dependencies.d.ts +69 -0
- package/dist/api/entries/dependencies.d.ts.map +1 -0
- package/dist/api/entries/dependencies.js +61 -0
- package/dist/api/entries/dependencies.js.map +1 -0
- package/dist/api/entries/flag-logic.d.ts +37 -0
- package/dist/api/entries/flag-logic.d.ts.map +1 -0
- package/dist/api/entries/flag-logic.js +110 -0
- package/dist/api/entries/flag-logic.js.map +1 -0
- package/dist/api/entries/identifiers.d.ts +84 -0
- package/dist/api/entries/identifiers.d.ts.map +1 -0
- package/dist/api/entries/identifiers.js +590 -0
- package/dist/api/entries/identifiers.js.map +1 -0
- package/dist/api/entries/index.d.ts +6 -0
- package/dist/api/entries/index.d.ts.map +1 -0
- package/dist/{plugins → api/entries}/index.js +6 -8
- package/dist/api/entries/index.js.map +1 -0
- package/dist/api/entries/locations.d.ts +135 -0
- package/dist/api/entries/locations.d.ts.map +1 -0
- package/dist/api/entries/locations.js +174 -0
- package/dist/api/entries/locations.js.map +1 -0
- package/dist/api/entries/manager.d.ts +12 -0
- package/dist/api/entries/manager.d.ts.map +1 -0
- package/dist/api/entries/manager.js +35 -0
- package/dist/api/entries/manager.js.map +1 -0
- package/dist/api/handle-derivation.d.ts +32 -0
- package/dist/api/handle-derivation.d.ts.map +1 -0
- package/dist/api/handle-derivation.js +77 -0
- package/dist/api/handle-derivation.js.map +1 -0
- package/dist/api/index.d.ts +7 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +23 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/shared-types.d.ts +86 -0
- package/dist/api/shared-types.d.ts.map +1 -0
- package/dist/api/shared-types.js +3 -0
- package/dist/api/shared-types.js.map +1 -0
- package/dist/internal-utils/auto-registering-plugins-loader.d.ts +3 -0
- package/dist/internal-utils/auto-registering-plugins-loader.d.ts.map +1 -0
- package/dist/internal-utils/auto-registering-plugins-loader.js +42 -0
- package/dist/internal-utils/auto-registering-plugins-loader.js.map +1 -0
- package/dist/internal-utils/common-config-helpers.d.ts +14 -0
- package/dist/internal-utils/common-config-helpers.d.ts.map +1 -0
- package/dist/internal-utils/common-config-helpers.js +140 -0
- package/dist/internal-utils/common-config-helpers.js.map +1 -0
- package/dist/internal-utils/entrypoint-resolution-logic.d.ts +14 -0
- package/dist/internal-utils/entrypoint-resolution-logic.d.ts.map +1 -0
- package/dist/internal-utils/entrypoint-resolution-logic.js +223 -0
- package/dist/internal-utils/entrypoint-resolution-logic.js.map +1 -0
- package/dist/internal-utils/internal-pseudo-plugin.d.ts +6 -0
- package/dist/internal-utils/internal-pseudo-plugin.d.ts.map +1 -0
- package/dist/internal-utils/internal-pseudo-plugin.js +46 -0
- package/dist/internal-utils/internal-pseudo-plugin.js.map +1 -0
- package/dist/mocks/blocks.d.ts +32 -0
- package/dist/mocks/blocks.d.ts.map +1 -0
- package/dist/mocks/blocks.js +3 -0
- package/dist/mocks/blocks.js.map +1 -0
- package/dist/mocks/index.d.ts +2 -0
- package/dist/mocks/index.d.ts.map +1 -0
- package/dist/mocks/index.js +18 -0
- package/dist/mocks/index.js.map +1 -0
- package/dist/plugins/AdditionalDependencyInjectorPlugin.d.ts +4 -10
- package/dist/plugins/AdditionalDependencyInjectorPlugin.d.ts.map +1 -0
- package/dist/plugins/AdditionalDependencyInjectorPlugin.js +48 -47
- package/dist/plugins/AdditionalDependencyInjectorPlugin.js.map +1 -0
- package/dist/plugins/MiniCSSExtractPluginErrorCleaner.d.ts +1 -0
- package/dist/plugins/MiniCSSExtractPluginErrorCleaner.d.ts.map +1 -0
- package/dist/plugins/MiniCSSExtractPluginErrorCleaner.js +1 -0
- package/dist/plugins/MiniCSSExtractPluginErrorCleaner.js.map +1 -0
- package/dist/plugins/PackageConfigSanityChecker.d.ts +1 -0
- package/dist/plugins/PackageConfigSanityChecker.d.ts.map +1 -0
- package/dist/plugins/PackageConfigSanityChecker.js +1 -0
- package/dist/plugins/PackageConfigSanityChecker.js.map +1 -0
- package/dist/plugins/RootCoordinatorPluginImpl.d.ts +56 -0
- package/dist/plugins/RootCoordinatorPluginImpl.d.ts.map +1 -0
- package/dist/plugins/RootCoordinatorPluginImpl.js +767 -0
- package/dist/plugins/RootCoordinatorPluginImpl.js.map +1 -0
- package/dist/plugins/VariablesJSMonitorPlugin.d.ts +2 -1
- package/dist/plugins/VariablesJSMonitorPlugin.d.ts.map +1 -0
- package/dist/plugins/VariablesJSMonitorPlugin.js +1 -0
- package/dist/plugins/VariablesJSMonitorPlugin.js.map +1 -0
- package/dist/plugins/blocks/BlocksDirectoryLoaderEmitterPlugin.d.ts +25 -0
- package/dist/plugins/blocks/BlocksDirectoryLoaderEmitterPlugin.d.ts.map +1 -0
- package/dist/plugins/blocks/BlocksDirectoryLoaderEmitterPlugin.js +458 -0
- package/dist/plugins/blocks/BlocksDirectoryLoaderEmitterPlugin.js.map +1 -0
- package/dist/plugins/blocks/BlocksDirectoryProcessingPlugin.d.ts +29 -0
- package/dist/plugins/blocks/BlocksDirectoryProcessingPlugin.d.ts.map +1 -0
- package/dist/plugins/blocks/BlocksDirectoryProcessingPlugin.js +290 -0
- package/dist/plugins/blocks/BlocksDirectoryProcessingPlugin.js.map +1 -0
- package/dist/plugins/blocks/register.d.ts +6 -0
- package/dist/plugins/blocks/register.d.ts.map +1 -0
- package/dist/plugins/blocks/register.js +14 -0
- package/dist/plugins/blocks/register.js.map +1 -0
- package/dist/plugins/blocks/registerEmitter.d.ts +4 -0
- package/dist/plugins/blocks/registerEmitter.d.ts.map +1 -0
- package/dist/plugins/blocks/registerEmitter.js +13 -0
- package/dist/plugins/blocks/registerEmitter.js.map +1 -0
- package/dist/plugins/blocks/registerProcessor.d.ts +4 -0
- package/dist/plugins/blocks/registerProcessor.d.ts.map +1 -0
- package/dist/plugins/blocks/registerProcessor.js +46 -0
- package/dist/plugins/blocks/registerProcessor.js.map +1 -0
- package/dist/plugins/dependency-extraction-webpack-plugin-config-builder.d.ts +3 -2
- package/dist/plugins/dependency-extraction-webpack-plugin-config-builder.d.ts.map +1 -0
- package/dist/plugins/dependency-extraction-webpack-plugin-config-builder.js +2 -1
- package/dist/plugins/dependency-extraction-webpack-plugin-config-builder.js.map +1 -0
- package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPlugin.d.ts +14 -0
- package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPlugin.d.ts.map +1 -0
- package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPlugin.js +191 -0
- package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPlugin.js.map +1 -0
- package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPluginV1.d.ts +14 -0
- package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPluginV1.d.ts.map +1 -0
- package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPluginV1.js +102 -0
- package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPluginV1.js.map +1 -0
- package/dist/plugins/extensions/ExtensionsDirectoryProcessingPlugin.d.ts +25 -0
- package/dist/plugins/extensions/ExtensionsDirectoryProcessingPlugin.d.ts.map +1 -0
- package/dist/plugins/extensions/ExtensionsDirectoryProcessingPlugin.js +229 -0
- package/dist/plugins/extensions/ExtensionsDirectoryProcessingPlugin.js.map +1 -0
- package/dist/plugins/extensions/register.d.ts +6 -0
- package/dist/plugins/extensions/register.d.ts.map +1 -0
- package/dist/plugins/extensions/register.js +14 -0
- package/dist/plugins/extensions/register.js.map +1 -0
- package/dist/plugins/extensions/registerEmitter.d.ts +4 -0
- package/dist/plugins/extensions/registerEmitter.d.ts.map +1 -0
- package/dist/plugins/extensions/registerEmitter.js +18 -0
- package/dist/plugins/extensions/registerEmitter.js.map +1 -0
- package/dist/plugins/extensions/registerProcessor.d.ts +4 -0
- package/dist/plugins/extensions/registerProcessor.d.ts.map +1 -0
- package/dist/plugins/extensions/registerProcessor.js +42 -0
- package/dist/plugins/extensions/registerProcessor.js.map +1 -0
- package/dist/plugins/plain/PlainEntrypointProcessingPlugin.d.ts +18 -0
- package/dist/plugins/plain/PlainEntrypointProcessingPlugin.d.ts.map +1 -0
- package/dist/plugins/plain/PlainEntrypointProcessingPlugin.js +203 -0
- package/dist/plugins/plain/PlainEntrypointProcessingPlugin.js.map +1 -0
- package/dist/plugins/plain/PlainEntrypointsConfigEmitterPlugin.d.ts +13 -0
- package/dist/plugins/plain/PlainEntrypointsConfigEmitterPlugin.d.ts.map +1 -0
- package/dist/plugins/plain/PlainEntrypointsConfigEmitterPlugin.js +51 -0
- package/dist/plugins/plain/PlainEntrypointsConfigEmitterPlugin.js.map +1 -0
- package/dist/plugins/plain/register.d.ts +6 -0
- package/dist/plugins/plain/register.d.ts.map +1 -0
- package/dist/plugins/plain/register.js +14 -0
- package/dist/plugins/plain/register.js.map +1 -0
- package/dist/plugins/plain/registerEmitter.d.ts +4 -0
- package/dist/plugins/plain/registerEmitter.d.ts.map +1 -0
- package/dist/plugins/plain/registerEmitter.js +21 -0
- package/dist/plugins/plain/registerEmitter.js.map +1 -0
- package/dist/plugins/plain/registerProcessor.d.ts +4 -0
- package/dist/plugins/plain/registerProcessor.d.ts.map +1 -0
- package/dist/plugins/plain/registerProcessor.js +34 -0
- package/dist/plugins/plain/registerProcessor.js.map +1 -0
- package/dist/plugins/register.d.ts +3 -0
- package/dist/plugins/register.d.ts.map +1 -0
- package/dist/plugins/register.js +17 -0
- package/dist/plugins/register.js.map +1 -0
- package/dist/plugins/special-assets/SpecialAssetsCollectorPlugin.d.ts +20 -0
- package/dist/plugins/special-assets/SpecialAssetsCollectorPlugin.d.ts.map +1 -0
- package/dist/plugins/special-assets/SpecialAssetsCollectorPlugin.js +56 -0
- package/dist/plugins/special-assets/SpecialAssetsCollectorPlugin.js.map +1 -0
- package/dist/plugins/special-assets/SpecialAssetsLoaderEmitterPlugin.d.ts +13 -0
- package/dist/plugins/special-assets/SpecialAssetsLoaderEmitterPlugin.d.ts.map +1 -0
- package/dist/plugins/special-assets/SpecialAssetsLoaderEmitterPlugin.js +105 -0
- package/dist/plugins/special-assets/SpecialAssetsLoaderEmitterPlugin.js.map +1 -0
- package/dist/plugins/special-assets/register.d.ts +6 -0
- package/dist/plugins/special-assets/register.d.ts.map +1 -0
- package/dist/plugins/special-assets/register.js +14 -0
- package/dist/plugins/special-assets/register.js.map +1 -0
- package/dist/plugins/special-assets/registerEmitter.d.ts +4 -0
- package/dist/plugins/special-assets/registerEmitter.d.ts.map +1 -0
- package/dist/plugins/special-assets/registerEmitter.js +15 -0
- package/dist/plugins/special-assets/registerEmitter.js.map +1 -0
- package/dist/plugins/special-assets/registerProcessor.d.ts +4 -0
- package/dist/plugins/special-assets/registerProcessor.d.ts.map +1 -0
- package/dist/plugins/special-assets/registerProcessor.js +15 -0
- package/dist/plugins/special-assets/registerProcessor.js.map +1 -0
- package/dist/plugins/unified-loader/UnifiedLoaderGenerator.d.ts +22 -0
- package/dist/plugins/unified-loader/UnifiedLoaderGenerator.d.ts.map +1 -0
- package/dist/plugins/unified-loader/UnifiedLoaderGenerator.js +95 -0
- package/dist/plugins/unified-loader/UnifiedLoaderGenerator.js.map +1 -0
- package/dist/plugins/wpml-config/WPMLConfigBuilder.d.ts +24 -0
- package/dist/plugins/wpml-config/WPMLConfigBuilder.d.ts.map +1 -0
- package/dist/plugins/{WPMLConfigBuilder.js → wpml-config/WPMLConfigBuilder.js} +123 -53
- package/dist/plugins/wpml-config/WPMLConfigBuilder.js.map +1 -0
- package/dist/plugins/wpml-config/register.d.ts +6 -0
- package/dist/plugins/wpml-config/register.d.ts.map +1 -0
- package/dist/plugins/wpml-config/register.js +25 -0
- package/dist/plugins/wpml-config/register.js.map +1 -0
- package/dist/shared.d.ts +10 -283
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +32 -405
- package/dist/shared.js.map +1 -0
- package/dist/utils/error-helpers.d.ts +7 -0
- package/dist/utils/error-helpers.d.ts.map +1 -0
- package/dist/utils/error-helpers.js +73 -0
- package/dist/utils/error-helpers.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +22 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/misc.d.ts +4 -0
- package/dist/utils/misc.d.ts.map +1 -0
- package/dist/utils/misc.js +18 -0
- package/dist/utils/misc.js.map +1 -0
- package/dist/utils/path-helpers.d.ts +16 -0
- package/dist/utils/path-helpers.d.ts.map +1 -0
- package/dist/utils/path-helpers.js +115 -0
- package/dist/utils/path-helpers.js.map +1 -0
- package/dist/utils/pseudo-semaphore.d.ts +1 -0
- package/dist/utils/pseudo-semaphore.d.ts.map +1 -0
- package/dist/utils/pseudo-semaphore.js +3 -5
- package/dist/utils/pseudo-semaphore.js.map +1 -0
- package/dist/utils/type-helpers.d.ts +27 -0
- package/dist/utils/type-helpers.d.ts.map +1 -0
- package/dist/utils/type-helpers.js +33 -0
- package/dist/utils/type-helpers.js.map +1 -0
- package/dist/utils/writer-utils.d.ts +8 -0
- package/dist/utils/writer-utils.d.ts.map +1 -0
- package/dist/utils/writer-utils.js +35 -0
- package/dist/utils/writer-utils.js.map +1 -0
- package/dist/wordpress-ports/dependency-extraction-webpack-plugin/index.d.ts +2 -1
- package/dist/wordpress-ports/dependency-extraction-webpack-plugin/index.d.ts.map +1 -0
- package/dist/wordpress-ports/dependency-extraction-webpack-plugin/index.js +5 -7
- package/dist/wordpress-ports/dependency-extraction-webpack-plugin/index.js.map +1 -0
- package/dist/wordpress-ports/dependency-extraction-webpack-plugin/util.d.ts +1 -0
- package/dist/wordpress-ports/dependency-extraction-webpack-plugin/util.d.ts.map +1 -0
- package/dist/wordpress-ports/dependency-extraction-webpack-plugin/util.js +1 -0
- package/dist/wordpress-ports/dependency-extraction-webpack-plugin/util.js.map +1 -0
- package/dist/wordpress-scripts-wrapper.d.ts +3 -2
- package/dist/wordpress-scripts-wrapper.d.ts.map +1 -0
- package/dist/wordpress-scripts-wrapper.js +137 -391
- package/dist/wordpress-scripts-wrapper.js.map +1 -0
- package/package.json +28 -50
- package/dist/plugins/AbstractBiPhasicGroupAndEntryPlugin.d.ts +0 -25
- package/dist/plugins/AbstractBiPhasicGroupAndEntryPlugin.js +0 -86
- package/dist/plugins/AbstractBiPhasicGroupPlugin.d.ts +0 -31
- package/dist/plugins/AbstractBiPhasicGroupPlugin.js +0 -91
- package/dist/plugins/EnhancedBlockJSONPlugin.d.ts +0 -47
- package/dist/plugins/EnhancedBlockJSONPlugin.js +0 -657
- package/dist/plugins/EnhancedDynamicEntryPlugin.d.ts +0 -8
- package/dist/plugins/EnhancedDynamicEntryPlugin.js +0 -14
- package/dist/plugins/ExtensionsConfigFileGeneratorPlugin.d.ts +0 -20
- package/dist/plugins/ExtensionsConfigFileGeneratorPlugin.js +0 -191
- package/dist/plugins/ExtensionsConfigFileGeneratorPluginV1.d.ts +0 -9
- package/dist/plugins/ExtensionsConfigFileGeneratorPluginV1.js +0 -45
- package/dist/plugins/MixableBiPhasicGroupAndEntryPlugin.d.ts +0 -6
- package/dist/plugins/MixableBiPhasicGroupAndEntryPlugin.js +0 -13
- package/dist/plugins/MixableBiPhasicGroupPlugin.d.ts +0 -6
- package/dist/plugins/MixableBiPhasicGroupPlugin.js +0 -13
- package/dist/plugins/PlainEntrypointsConfigFileGeneratorPlugin.d.ts +0 -26
- package/dist/plugins/PlainEntrypointsConfigFileGeneratorPlugin.js +0 -392
- package/dist/plugins/SpecialAssetHandlingPlugin.d.ts +0 -12
- package/dist/plugins/SpecialAssetHandlingPlugin.js +0 -134
- package/dist/plugins/UnifiedLoaderGenerator.d.ts +0 -21
- package/dist/plugins/UnifiedLoaderGenerator.js +0 -144
- package/dist/plugins/WPMLConfigBuilder.d.ts +0 -17
- package/dist/plugins/index.d.ts +0 -8
- package/dist/plugins/static-configs.d.ts +0 -3
- package/dist/plugins/static-configs.js +0 -44
- package/dist/utils/common-config-helpers.d.ts +0 -28
- package/dist/utils/common-config-helpers.js +0 -489
- package/dist/utils/css-writer.d.ts +0 -4
- package/dist/utils/css-writer.js +0 -46
- package/dist/utils/entrypoint-resolution-logic.d.ts +0 -13
- package/dist/utils/entrypoint-resolution-logic.js +0 -82
- package/dist/utils/location-encoding-filename-parser.d.ts +0 -30
- package/dist/utils/location-encoding-filename-parser.js +0 -120
- package/dist/utils/path-query-and-related-helpers.d.ts +0 -64
- package/dist/utils/path-query-and-related-helpers.js +0 -269
|
@@ -3,38 +3,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
const node_fs_1 = require("node:fs");
|
|
6
|
-
const promises_1 = require("node:fs/promises");
|
|
7
6
|
const node_path_1 = require("node:path");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
7
|
+
const copy_webpack_plugin_1 = __importDefault(require("copy-webpack-plugin"));
|
|
8
|
+
const fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
|
|
9
|
+
const webpack_remove_empty_scripts_1 = __importDefault(require("webpack-remove-empty-scripts"));
|
|
10
|
+
const api_1 = require("./api");
|
|
11
|
+
const auto_registering_plugins_loader_1 = require("./internal-utils/auto-registering-plugins-loader");
|
|
12
|
+
const common_config_helpers_1 = require("./internal-utils/common-config-helpers");
|
|
13
|
+
const entrypoint_resolution_logic_1 = require("./internal-utils/entrypoint-resolution-logic");
|
|
14
|
+
const internal_pseudo_plugin_1 = __importDefault(require("./internal-utils/internal-pseudo-plugin"));
|
|
12
15
|
const AdditionalDependencyInjectorPlugin_1 = require("./plugins/AdditionalDependencyInjectorPlugin");
|
|
13
16
|
const dependency_extraction_webpack_plugin_config_builder_1 = require("./plugins/dependency-extraction-webpack-plugin-config-builder");
|
|
14
|
-
const EnhancedDynamicEntryPlugin_1 = require("./plugins/EnhancedDynamicEntryPlugin");
|
|
15
|
-
const ExtensionsConfigFileGeneratorPlugin_1 = require("./plugins/ExtensionsConfigFileGeneratorPlugin");
|
|
16
|
-
const ExtensionsConfigFileGeneratorPluginV1_1 = require("./plugins/ExtensionsConfigFileGeneratorPluginV1");
|
|
17
17
|
const MiniCSSExtractPluginErrorCleaner_1 = require("./plugins/MiniCSSExtractPluginErrorCleaner");
|
|
18
18
|
const PackageConfigSanityChecker_1 = require("./plugins/PackageConfigSanityChecker");
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const SpecialAssetHandlingPlugin_1 = require("./plugins/SpecialAssetHandlingPlugin");
|
|
19
|
+
const RootCoordinatorPluginImpl_1 = require("./plugins/RootCoordinatorPluginImpl");
|
|
20
|
+
const register_1 = require("./plugins/register");
|
|
22
21
|
const VariablesJSMonitorPlugin_1 = require("./plugins/VariablesJSMonitorPlugin");
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const UnifiedLoaderGenerator_1 = require("./plugins/UnifiedLoaderGenerator");
|
|
26
|
-
const copy_webpack_plugin_1 = __importDefault(require("copy-webpack-plugin"));
|
|
27
|
-
const fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
|
|
28
|
-
const webpack_remove_empty_scripts_1 = __importDefault(require("webpack-remove-empty-scripts"));
|
|
29
|
-
const location_encoding_filename_parser_1 = require("./utils/location-encoding-filename-parser");
|
|
22
|
+
const shared_1 = require("./shared");
|
|
23
|
+
const utils_1 = require("./utils");
|
|
30
24
|
function testForDuplicatedEntryPaths(sources) {
|
|
31
|
-
const seenPaths = (0,
|
|
25
|
+
const seenPaths = (0, utils_1.groupEntrypointsByAssetName)(Array.isArray(sources)
|
|
32
26
|
? sources.map(s => typeof s === 'string' ? s : s[1].destination)
|
|
33
27
|
: Object.values(sources).map(bn => typeof bn === 'string' ? bn : bn.destination), bn => bn);
|
|
34
|
-
let projectPrefix
|
|
28
|
+
let projectPrefix;
|
|
35
29
|
let duplicatedPaths = "";
|
|
36
|
-
for (const sameNamePaths of
|
|
37
|
-
if (sameNamePaths
|
|
30
|
+
for (const sameNamePaths of Object.values(seenPaths)) {
|
|
31
|
+
if ((0, utils_1.arrayHasAtLeastLength)(sameNamePaths, 2)) {
|
|
38
32
|
if (projectPrefix === undefined) {
|
|
39
33
|
for (let p = process.cwd(); p.length > 1; p = (0, node_path_1.dirname)(p)) {
|
|
40
34
|
if ((0, node_fs_1.existsSync)((0, node_path_1.join)(p, "docker-compose.yml"))) {
|
|
@@ -54,99 +48,15 @@ function testForDuplicatedEntryPaths(sources) {
|
|
|
54
48
|
process.exit(1);
|
|
55
49
|
}
|
|
56
50
|
}
|
|
57
|
-
function replaceDefaultURLProcessing(useWebpackResourceFiltering) {
|
|
58
|
-
return (rules) => {
|
|
59
|
-
const cssLoader = require.resolve('css-loader');
|
|
60
|
-
if (cssLoader) {
|
|
61
|
-
return rules.map(rule => {
|
|
62
|
-
if (rule && typeof rule === 'object' && "use" in rule && Array.isArray(rule.use)) {
|
|
63
|
-
return {
|
|
64
|
-
...rule,
|
|
65
|
-
use: rule.use.map(useElement => {
|
|
66
|
-
if (useElement && typeof useElement === 'object' && useElement.loader === cssLoader && typeof useElement.options === 'object') {
|
|
67
|
-
return {
|
|
68
|
-
...useElement,
|
|
69
|
-
options: {
|
|
70
|
-
...useElement.options,
|
|
71
|
-
url: {
|
|
72
|
-
filter(url) {
|
|
73
|
-
return (useWebpackResourceFiltering || !url.startsWith("/"))
|
|
74
|
-
&& !!url.match(/\.(woff2?|eot|ttf|otf|png|jpe?g|svg|webp|avif|gif|bmp)[^.]*?(\?.*)?/i);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
return useElement;
|
|
81
|
-
})
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
return rule;
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
return rules;
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function injectPostcssConfigOverrides(rules, config, variables, postcssFunctionsConfig) {
|
|
91
|
-
const postcssConfig = (0, static_configs_1.postcssConfigBuilder)(name => variables(name) ?? (name === 'ENV' ? '' : undefined), postcssFunctionsConfig);
|
|
92
|
-
return rules.map(rule => {
|
|
93
|
-
if (rule && typeof rule === 'object') {
|
|
94
|
-
if (Array.isArray(rule.use)) {
|
|
95
|
-
for (const useItem of rule.use) {
|
|
96
|
-
if (useItem && typeof useItem === 'object' && typeof useItem.options === 'object') {
|
|
97
|
-
if (useItem.options["sourceMap"] === false) {
|
|
98
|
-
useItem.options["sourceMap"] = true;
|
|
99
|
-
}
|
|
100
|
-
if (useItem.loader?.includes('postcss-loader')) {
|
|
101
|
-
if (useItem.options["postcssOptions"]) {
|
|
102
|
-
useItem.options["postcssOptions"] = { ...useItem.options["postcssOptions"], ...postcssConfig, sourceMap: true, config: false };
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
useItem.options["postcssOptions"] = { ...postcssConfig, sourceMap: true, config: false };
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (rule.test instanceof RegExp) {
|
|
111
|
-
if (rule.test.test("index.ts") || rule.test.test("index.mts")) { // Then this is the JavaScript and TypeScript rule
|
|
112
|
-
rule.test = /\.m?[jt]sx?$/; // This hacks in support for mjs and mts files
|
|
113
|
-
}
|
|
114
|
-
if (config.onlyRunPostCSSOnPCSS && rule.test.test("test.css") && !rule.test.test("test.pcss")) {
|
|
115
|
-
// We remove PostCSS processing from the .css file handling pipeline
|
|
116
|
-
rule.use = rule.use.filter(useItem => !useItem || typeof useItem !== 'object' || !useItem.loader?.includes('postcss-loader'));
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
if (rule.type === "asset/inline" && rule.test instanceof RegExp && rule.issuer instanceof RegExp && rule.test.test("test.svg") && rule.issuer.test("test.pcss")) {
|
|
121
|
-
const { type: originalType, ...commonRuleParams } = rule;
|
|
122
|
-
return {
|
|
123
|
-
...commonRuleParams,
|
|
124
|
-
oneOf: [
|
|
125
|
-
{ type: originalType, resourceQuery: /string|inline/i },
|
|
126
|
-
{ type: "asset/resource", generator: { filename: "images/[name].[hash:8][ext]" } }
|
|
127
|
-
]
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return rule;
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
function injectSupportForInliningSVGsAsStrings(rules) {
|
|
135
|
-
const svgRLoader = require.resolve('@svgr/webpack');
|
|
136
|
-
return rules.map(rule => {
|
|
137
|
-
if (rule && typeof rule === 'object' && "use" in rule && Array.isArray(rule.use) && (rule.use.includes('@svgr/webpack') || rule.use.includes(svgRLoader))) {
|
|
138
|
-
const { test, issuer, ...reactSpecific } = rule;
|
|
139
|
-
return { test, issuer, oneOf: [
|
|
140
|
-
{ type: 'asset/source', resourceQuery: /string/ }, // *.svg?string
|
|
141
|
-
reactSpecific
|
|
142
|
-
] };
|
|
143
|
-
}
|
|
144
|
-
return rule;
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
51
|
function buildVerifiedConfig(config) {
|
|
52
|
+
const baseDir = process.cwd();
|
|
148
53
|
config = (0, shared_1.applyStandards)(config);
|
|
149
|
-
const { standaloneBlocks = false, stats = 'errors-warnings', variables: rawVariables, verbose = process.argv.includes('--verbose') || process.env['VERBOSE'] === 'true',
|
|
54
|
+
const { standaloneBlocks = false, stats = 'errors-warnings', variables: rawVariables, verbose = process.argv.includes('--verbose') || process.env['VERBOSE'] === 'true', externals, assumeGlobalizedPlauditLibraries = true, useWebpackResourceFiltering = true, plainEntrypointsVersion = 1, srcDir = "", useUnifiedLoader = false, includePostInitFallback = false, omitDistDev = false, onlyRunPostCSSOnPCSS = false, useBlockSupportsAsThemeJsonDefaults = true, pluginConfig = {}, } = config;
|
|
55
|
+
// This is present to handle the postcss config being in the legacy location
|
|
56
|
+
if ('postcss' in config) {
|
|
57
|
+
(0, utils_1.emitWarning)("Found the postcss config object at the root of the config object. Please move it to be a child of pluginConfig");
|
|
58
|
+
pluginConfig['postcss'] = config.postcss;
|
|
59
|
+
}
|
|
150
60
|
let outputDir = config.outputDir ?? "";
|
|
151
61
|
if ((0, shared_1.shouldWriteDistDev)({ outputDir, useUnifiedLoader, omitDistDev })) {
|
|
152
62
|
outputDir += "-dev";
|
|
@@ -159,87 +69,35 @@ function buildVerifiedConfig(config) {
|
|
|
159
69
|
else {
|
|
160
70
|
srcPrefixes = (srcDir && !config.srcPrefixes.includes(trailingSlashedSrcDir) ? [...config.srcPrefixes, trailingSlashedSrcDir] : config.srcPrefixes);
|
|
161
71
|
}
|
|
162
|
-
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
if (!outputDir) {
|
|
171
|
-
throw new Error("Plain Entrypoints V2 and higher require 'outputDir' to be set");
|
|
172
|
-
}
|
|
72
|
+
const targetHandlePrefix = config.targetHandlePrefix ?? config.plainEntrypointsHandlePrefix ?? deriveDefaultHandlePrefixFromComposerJsonOrThemeName(utils_1.kebabCase) ?? "";
|
|
73
|
+
if (!targetHandlePrefix) {
|
|
74
|
+
throw new Error("'targetHandlePrefix' must be set or the webpack.config.js file must have an adjacent composer.json or style.css file");
|
|
75
|
+
}
|
|
76
|
+
if (plainEntrypointsVersion > 1 && !outputDir) {
|
|
77
|
+
throw new Error("Plain Entrypoints V2 and higher require 'outputDir' to be set");
|
|
173
78
|
}
|
|
174
79
|
// Only the lazyLoader emitters read this, so an absence of package metadata is not worth failing a build
|
|
175
80
|
// over: php-writer treats an empty namespace as "emit no namespace", which is what we did before 3.10.0
|
|
176
|
-
const targetNamespace = config.targetNamespace || deriveDefaultHandlePrefixFromComposerJsonOrThemeName(
|
|
177
|
-
|
|
178
|
-
const rawSources = [...staticEntrypoints, ...dynamicEntrypoints];
|
|
179
|
-
let variablesFilePath = undefined;
|
|
81
|
+
const targetNamespace = config.targetNamespace || deriveDefaultHandlePrefixFromComposerJsonOrThemeName(utils_1.camelCaseForPHPLabels, true) || "";
|
|
82
|
+
let variablesFilePath;
|
|
180
83
|
const currentVariables = rawVariables ?? {};
|
|
181
84
|
if (!rawVariables) {
|
|
182
|
-
variablesFilePath = ["variables.js", "src/site/variables.js"].map(p => (0, node_path_1.join)(
|
|
85
|
+
variablesFilePath = ["variables.js", "src/site/variables.js"].map(p => (0, node_path_1.join)(baseDir, p)).filter(p => (0, node_fs_1.existsSync)(p))[0];
|
|
183
86
|
}
|
|
184
87
|
let extensionsVersion = config.extensionsVersion ?? 1;
|
|
185
88
|
if (extensionsVersion === 2) {
|
|
186
89
|
extensionsVersion = 3; // Version 3 is a backwards-compatible upgrade of version 2, so we can automatically upgrade everything
|
|
187
90
|
}
|
|
188
91
|
const cfg = {
|
|
189
|
-
currentVariables,
|
|
92
|
+
currentVariables, standaloneBlocks, stats, variablesFilePath, verbose, externals, assumeGlobalizedPlauditLibraries,
|
|
190
93
|
useWebpackResourceFiltering, outputDir, extensionsVersion, plainEntrypointsVersion, srcDir, srcPrefixes, targetHandlePrefix,
|
|
191
|
-
useUnifiedLoader, includePostInitFallback, omitDistDev, onlyRunPostCSSOnPCSS, targetNamespace, useBlockSupportsAsThemeJsonDefaults
|
|
94
|
+
useUnifiedLoader, includePostInitFallback, omitDistDev, onlyRunPostCSSOnPCSS, targetNamespace, useBlockSupportsAsThemeJsonDefaults,
|
|
95
|
+
pluginConfig
|
|
192
96
|
};
|
|
193
97
|
// Destination -> source map
|
|
194
98
|
const allocatedDestinations = {};
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
// This guards against a crash later on down the line due to trying to run a spread on a boolean
|
|
198
|
-
if (externalize && typeof externalize !== 'string' && typeof externalize !== 'object') {
|
|
199
|
-
throw new TypeError(`externalize must be a string, an array or an object, but "${src}" set externalize to a ${typeof externalize}`);
|
|
200
|
-
}
|
|
201
|
-
const { flags: queryEnqueuingFlags, remainder: pathQueryParameters, handle: pathQueryHandle } = (0, path_query_and_related_helpers_1.unpackEnqueuingControlFlagsFromPathQueryParameters)(rawPathQueryParameters, src, 'path query parameters');
|
|
202
|
-
const enqueuingFlags = (0, path_query_and_related_helpers_1.mergeTwoEnqueuingControlFlagSets)(src, rawEnqueuingFlags, queryEnqueuingFlags);
|
|
203
|
-
const normalizedParts = { additionalDependencies, assumeGlobalizedPlauditLibraries, bundleAnalyzer, directoryLayout, externalize, withLegacyBlocksIn, lazyLoader };
|
|
204
|
-
let locations;
|
|
205
|
-
if (pathQueryHandle === undefined) {
|
|
206
|
-
locations = typeof rawSourceLocations === 'string' || typeof rawSourceLocations === 'function' || (rawSourceLocations !== undefined && 'niceName' in rawSourceLocations)
|
|
207
|
-
? { handle: rawSourceLocations } : rawSourceLocations ?? {};
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
const rawSourceHandle = typeof rawSourceLocations === 'string' || typeof rawSourceLocations === 'function' || (rawSourceLocations !== undefined && 'niceName' in rawSourceLocations)
|
|
211
|
-
? rawSourceLocations : rawSourceLocations?.handle;
|
|
212
|
-
if (rawSourceHandle === undefined) {
|
|
213
|
-
locations = { handle: pathQueryHandle };
|
|
214
|
-
}
|
|
215
|
-
else if (typeof rawSourceHandle === 'string') {
|
|
216
|
-
if (rawSourceHandle !== pathQueryHandle) {
|
|
217
|
-
throw new ReferenceError(`Encountered mismatched handles "${rawSourceHandle}" and "${pathQueryHandle}" when preparing "${src}"`);
|
|
218
|
-
}
|
|
219
|
-
locations = { handle: pathQueryHandle };
|
|
220
|
-
}
|
|
221
|
-
else {
|
|
222
|
-
throw new ReferenceError(`Encountered a function handle and a path query handle when preparing "${src}"`);
|
|
223
|
-
}
|
|
224
|
-
// This is just a means of merging the new handle into the rawSourceLocations config without mutating the base config
|
|
225
|
-
if (rawSourceLocations !== undefined && typeof rawSourceLocations !== 'function' && typeof rawSourceLocations !== 'string') {
|
|
226
|
-
locations = { ...rawSourceLocations, ...locations };
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
if (typeof locations.registerScriptArgs === 'string' && !['lazy', 'eager', 'inline'].includes(locations.registerScriptArgs)) {
|
|
230
|
-
throw new ReferenceError("The only supported string values for registerScriptArgs are 'lazy', 'eager', and 'inline'");
|
|
231
|
-
}
|
|
232
|
-
if (destination !== undefined) {
|
|
233
|
-
const effectiveDestination = toEffectiveWebpackDestination(destination);
|
|
234
|
-
allocatedDestinations[effectiveDestination] = src; // We need to pre-populate the allocatedDestinations map with statically declared destinations
|
|
235
|
-
return [src, { ...normalizedParts, locations, destination, effectiveDestination, staticallyDeclaredDestination: true, pathQueryParameters, enqueuingFlags }];
|
|
236
|
-
}
|
|
237
|
-
else {
|
|
238
|
-
const naiveDestination = deriveNaiveDestinationFromUnverifiedSourceEntry(src, destination, srcPrefixes);
|
|
239
|
-
const effectiveDestination = toEffectiveWebpackDestination(naiveDestination);
|
|
240
|
-
return [src, { ...normalizedParts, locations, destination: naiveDestination, effectiveDestination, staticallyDeclaredDestination: false, pathQueryParameters, enqueuingFlags }];
|
|
241
|
-
}
|
|
242
|
-
});
|
|
99
|
+
const { staticEntrypoints, dynamicEntrypoints } = (0, entrypoint_resolution_logic_1.resolveAllConfigLevelEntrypoints)(cfg, config.src, baseDir, allocatedDestinations, srcPrefixes);
|
|
100
|
+
const partiallyVerifiedSources = [...staticEntrypoints, ...dynamicEntrypoints];
|
|
243
101
|
const dynamicEffectiveDestinationsWithExpectedNaiveDuplicates = partiallyVerifiedSources
|
|
244
102
|
.filter(entry => !entry[1].staticallyDeclaredDestination)
|
|
245
103
|
.map(entry => entry[1].effectiveDestination)
|
|
@@ -252,33 +110,6 @@ function buildVerifiedConfig(config) {
|
|
|
252
110
|
testForDuplicatedEntryPaths(sources);
|
|
253
111
|
return cfg.outputDir ? { cfg, sources } : withDerivedOutputDir(cfg, sources);
|
|
254
112
|
}
|
|
255
|
-
function toEffectiveWebpackDestination(destination) {
|
|
256
|
-
const pathParts = (0, node_path_1.parse)(destination);
|
|
257
|
-
return (0, node_path_1.join)(pathParts.dir, pathParts.name);
|
|
258
|
-
}
|
|
259
|
-
function deriveNaiveDestinationFromUnverifiedSourceEntry(src, destination, srcPrefixes) {
|
|
260
|
-
if (destination !== undefined) {
|
|
261
|
-
return destination;
|
|
262
|
-
}
|
|
263
|
-
const commaIndex = src.indexOf(',');
|
|
264
|
-
const primarySource = stripSrcPrefix(commaIndex > -1 ? src.substring(0, commaIndex).trim() : src, srcPrefixes);
|
|
265
|
-
const scriptParts = shared_1.scriptExtension.exec(primarySource);
|
|
266
|
-
if (scriptParts !== null) {
|
|
267
|
-
return `${scriptParts.groups['filename']}.js`; // filename is always defined here
|
|
268
|
-
}
|
|
269
|
-
const styleParts = shared_1.styleExtension.exec(primarySource);
|
|
270
|
-
if (styleParts !== null) {
|
|
271
|
-
return `${styleParts.groups['filename']}.css`; // filename is always defined here
|
|
272
|
-
}
|
|
273
|
-
return primarySource;
|
|
274
|
-
}
|
|
275
|
-
function stripSrcPrefix(src, srcPrefixes) {
|
|
276
|
-
const prefix = srcPrefixes.find(sp => src.startsWith(sp));
|
|
277
|
-
if (!prefix) {
|
|
278
|
-
return src;
|
|
279
|
-
}
|
|
280
|
-
return src[prefix.length] === '/' ? src.substring(prefix.length + 1) : src.substring(prefix.length);
|
|
281
|
-
}
|
|
282
113
|
function finalizeEntryDestination(entry, dynamicEffectiveDestinationsWithExpectedNaiveDuplicates, allocatedDestinations) {
|
|
283
114
|
if (entry[1].staticallyDeclaredDestination) {
|
|
284
115
|
return entry;
|
|
@@ -330,8 +161,8 @@ function deriveDefaultHandlePrefixFromThemeName(stringTransformer) {
|
|
|
330
161
|
return stringTransformer(themeName);
|
|
331
162
|
}
|
|
332
163
|
function withDerivedOutputDir(cfg, sources) {
|
|
333
|
-
const destinations = sources.map(([_, { destination }]) => destination.split(/[
|
|
334
|
-
if (destinations
|
|
164
|
+
const destinations = sources.map(([_, { destination }]) => destination.split(/[/\\]/g));
|
|
165
|
+
if (!(0, utils_1.arrayHasAtLeastLength)(destinations, 2)) {
|
|
335
166
|
return { cfg, sources };
|
|
336
167
|
}
|
|
337
168
|
const commonParent = destinations[0][0];
|
|
@@ -363,7 +194,7 @@ function handleDisablingTSCheckerIfNecessary(srcRoot, scriptExtension, plugins)
|
|
|
363
194
|
if ((0, node_path_1.extname)(sr).length === 0) {
|
|
364
195
|
include.push(...tsExtensions.map(tsExt => (0, node_path_1.join)(sr, "**", `*.${tsExt}`)));
|
|
365
196
|
}
|
|
366
|
-
else if ((0,
|
|
197
|
+
else if ((0, api_1.scriptOrStyleTest)(sr, scriptExtension) === "script") {
|
|
367
198
|
include.push(sr);
|
|
368
199
|
}
|
|
369
200
|
}
|
|
@@ -415,7 +246,7 @@ function handleDisablingTSCheckerIfNecessary(srcRoot, scriptExtension, plugins)
|
|
|
415
246
|
}
|
|
416
247
|
}));
|
|
417
248
|
}
|
|
418
|
-
function buildCommonPluginConfig(webpackConfig, config, bundleAnalyzer, assumeGlobalizedPlauditLibraries, externalize) {
|
|
249
|
+
function buildCommonPluginConfig(coordinator, webpackConfig, config, bundleAnalyzer, assumeGlobalizedPlauditLibraries, externalize) {
|
|
419
250
|
const plugins = webpackConfig.plugins?.filter(v => !!v)
|
|
420
251
|
.filter(plugin => plugin.constructor.name !== 'RtlCssPlugin')
|
|
421
252
|
.filter(plugin => plugin.constructor.name !== 'CopyPlugin' && plugin.constructor.name !== 'CleanWebpackPlugin')
|
|
@@ -431,19 +262,15 @@ function buildCommonPluginConfig(webpackConfig, config, bundleAnalyzer, assumeGl
|
|
|
431
262
|
return plugin;
|
|
432
263
|
})
|
|
433
264
|
?? [];
|
|
434
|
-
plugins.
|
|
265
|
+
plugins.unshift(new PackageConfigSanityChecker_1.PackageConfigSanityChecker(), coordinator);
|
|
435
266
|
if (bundleAnalyzer) {
|
|
436
|
-
plugins.
|
|
267
|
+
plugins.unshift(new (require("webpack-bundle-analyzer").BundleAnalyzerPlugin)({ analyzerMode: 'static', openAnalyzer: bundleAnalyzer !== 'no-auto-open' }));
|
|
437
268
|
}
|
|
438
|
-
|
|
269
|
+
plugins.push(new webpack_remove_empty_scripts_1.default({
|
|
439
270
|
stage: webpack_remove_empty_scripts_1.default.STAGE_AFTER_PROCESS_PLUGINS,
|
|
440
271
|
extensions: ['css', 'scss', 'sass', 'less', 'styl', 'pcss'],
|
|
441
272
|
ignore: /block\.json/
|
|
442
|
-
});
|
|
443
|
-
plugins.push(removeEmptyScriptsPlugin, new MiniCSSExtractPluginErrorCleaner_1.MiniCSSExtractPluginErrorCleaner());
|
|
444
|
-
if (config.useWebpackResourceFiltering) {
|
|
445
|
-
plugins.push(new SpecialAssetHandlingPlugin_1.SpecialAssetHandlingPlugin(config));
|
|
446
|
-
}
|
|
273
|
+
}), new MiniCSSExtractPluginErrorCleaner_1.MiniCSSExtractPluginErrorCleaner());
|
|
447
274
|
plugins.push(new VariablesJSMonitorPlugin_1.VariablesJSMonitorPlugin(config));
|
|
448
275
|
// We have to use constructor.name here the version desyncs can result in multiple equivalent versions kicking around
|
|
449
276
|
const dependencyExtractionPluginIndex = plugins.findIndex(plugin => plugin.constructor.name === 'DependencyExtractionWebpackPlugin');
|
|
@@ -456,51 +283,30 @@ function buildCommonPluginConfig(webpackConfig, config, bundleAnalyzer, assumeGl
|
|
|
456
283
|
console.error("Once those commands have finished, re-run whichever command had this error. If it still doesn't work, report the issue immediately.");
|
|
457
284
|
throw new Error("Cannot apply externals when they have been disabled via CLI flag. This will greatly increase bundle size and will likely cause the build to fail");
|
|
458
285
|
}
|
|
459
|
-
|
|
460
|
-
plugins[dependencyExtractionPluginIndex] = builtDependencyExtractionWebpackPlugin;
|
|
286
|
+
plugins[dependencyExtractionPluginIndex] = (0, dependency_extraction_webpack_plugin_config_builder_1.makeDependencyExtractionPlugin)(config.externals, assumeGlobalizedPlauditLibraries, externalize);
|
|
461
287
|
try {
|
|
462
288
|
const { PlauditDevPlugin } = require("@plaudit/dev-webpack-plugin");
|
|
463
289
|
plugins.push(new PlauditDevPlugin(config));
|
|
464
290
|
}
|
|
465
291
|
catch { }
|
|
466
292
|
return {
|
|
467
|
-
plugins
|
|
468
|
-
makeAdditionalDependencyInjectorPlugin(referencePlugin) {
|
|
469
|
-
return new AdditionalDependencyInjectorPlugin_1.AdditionalDependencyInjectorPlugin(webpackConfig.output?.module, builtDependencyExtractionWebpackPlugin.addExternalizedDep, referencePlugin);
|
|
470
|
-
}
|
|
293
|
+
plugins
|
|
471
294
|
};
|
|
472
295
|
}
|
|
473
|
-
function commonConfigProcessingPrep(config, webpackConfig) {
|
|
474
|
-
let scriptExtension; // This is only used in non-block contexts. It might not actually be necessary, but it is good to have
|
|
475
|
-
let entrypointFields;
|
|
296
|
+
async function commonConfigProcessingPrep(wrapperManager, config, webpackConfig, hasAnyNonModuleBuilds) {
|
|
476
297
|
const processingModules = webpackConfig.output?.module ?? false;
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
entrypointFields = ["viewScriptModule"];
|
|
480
|
-
}
|
|
481
|
-
else {
|
|
482
|
-
scriptExtension = shared_1.scriptWithoutModuleExtension;
|
|
483
|
-
entrypointFields = ["editorStyle", "viewStyle", "style", "editorScript", "viewScript", "script"];
|
|
484
|
-
}
|
|
298
|
+
const scriptExtension = processingModules ? api_1.scriptWithModuleExtension : api_1.scriptWithoutModuleExtension; // This is only used in non-block contexts. It might not actually be necessary, but it is good to have
|
|
299
|
+
const entrypointFields = (0, api_1.getLoadableEntrypointFields)(processingModules);
|
|
485
300
|
let currentVariables = config.currentVariables;
|
|
486
|
-
const
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
},
|
|
491
|
-
injectSupportForInliningSVGsAsStrings
|
|
492
|
-
].reduce((r, a) => a(r), webpackConfig.module?.rules ?? []);
|
|
493
|
-
fixedRules.push({
|
|
494
|
-
test: /wpml-config\.xml$/i,
|
|
495
|
-
type: 'asset/resource',
|
|
496
|
-
generator: {
|
|
497
|
-
filename: '[name][ext]',
|
|
498
|
-
emit: false
|
|
499
|
-
}
|
|
500
|
-
});
|
|
301
|
+
const getVariableValue = (name) => currentVariables[name];
|
|
302
|
+
const draftRules = utils_1.nonFreezingImmer.createDraft(webpackConfig.module?.rules ?? []);
|
|
303
|
+
await wrapperManager.hooks.webpackConfig.rules.promise(draftRules, { config, hasAnyNonModuleBuilds, webpackConfig, getVariableValue, entrypointFields, scriptExtension });
|
|
304
|
+
const fixedRules = utils_1.nonFreezingImmer.finishDraft(draftRules);
|
|
501
305
|
return {
|
|
502
306
|
entrypointFields, fixedRules, processingModules, scriptExtension,
|
|
503
|
-
updateCurrentVariables: (value) =>
|
|
307
|
+
updateCurrentVariables: (value) => {
|
|
308
|
+
return currentVariables = value;
|
|
309
|
+
}
|
|
504
310
|
};
|
|
505
311
|
}
|
|
506
312
|
function destToKey(dest) {
|
|
@@ -509,10 +315,11 @@ function destToKey(dest) {
|
|
|
509
315
|
: dest.externalize?.toString() ?? "undefined";
|
|
510
316
|
return [dest.assumeGlobalizedPlauditLibraries, dest.bundleAnalyzer, externalize].join("~");
|
|
511
317
|
}
|
|
512
|
-
function processIndividualWebpackConfig(config, webpackConfig, sources, canClean,
|
|
318
|
+
async function processIndividualWebpackConfig(wrapperManager, coordinator, config, webpackConfig, sources, canClean, hasAnyNonModuleBuilds) {
|
|
513
319
|
if (webpackConfig.output?.module) {
|
|
514
320
|
// This ensures that module files are emitted as module files
|
|
515
321
|
webpackConfig = {
|
|
322
|
+
name: "base:modules",
|
|
516
323
|
...webpackConfig,
|
|
517
324
|
output: {
|
|
518
325
|
...webpackConfig.output,
|
|
@@ -521,13 +328,26 @@ function processIndividualWebpackConfig(config, webpackConfig, sources, canClean
|
|
|
521
328
|
}
|
|
522
329
|
};
|
|
523
330
|
}
|
|
524
|
-
|
|
525
|
-
|
|
331
|
+
else if (!webpackConfig.name) {
|
|
332
|
+
webpackConfig = { name: "base:non-modules", ...webpackConfig };
|
|
333
|
+
}
|
|
334
|
+
const commonConfig = await commonConfigProcessingPrep(wrapperManager, config, webpackConfig, hasAnyNonModuleBuilds);
|
|
335
|
+
const { entrypointFields, processingModules, scriptExtension } = commonConfig;
|
|
336
|
+
const legacyBlocksResources = {};
|
|
526
337
|
const allSrcRoots = sources.map(([src, dest]) => {
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
338
|
+
let srcRoots, legacyBlocksAssets;
|
|
339
|
+
if (dest.withLegacyBlocksIn !== false) {
|
|
340
|
+
legacyBlocksAssets = (0, shared_1.resolveLegacyBlockScriptsInFolder)((0, utils_1.joinPossiblyAbsolutePaths)(process.cwd(), config.srcDir, dest.withLegacyBlocksIn));
|
|
341
|
+
srcRoots = [...src.split(','), ...legacyBlocksAssets];
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
legacyBlocksAssets = [];
|
|
345
|
+
srcRoots = src.split(',');
|
|
346
|
+
}
|
|
347
|
+
const srcRoot = srcRoots.length < 2 ? (0, utils_1.joinPossiblyAbsolutePaths)(process.cwd(), src) : srcRoots.map(s => (0, utils_1.joinPossiblyAbsolutePaths)(process.cwd(), s));
|
|
348
|
+
for (const legacyBlocksAsset of legacyBlocksAssets) {
|
|
349
|
+
legacyBlocksResources[legacyBlocksAsset] = srcRoot;
|
|
350
|
+
}
|
|
531
351
|
const srcIsDirectory = !Array.isArray(srcRoot) && (0, node_fs_1.lstatSync)(srcRoot, { throwIfNoEntry: false })?.isDirectory();
|
|
532
352
|
if (srcIsDirectory === undefined) {
|
|
533
353
|
return undefined;
|
|
@@ -539,160 +359,86 @@ function processIndividualWebpackConfig(config, webpackConfig, sources, canClean
|
|
|
539
359
|
const key = destToKey(entry.dest);
|
|
540
360
|
(groupedSrcRoots[key] ?? (groupedSrcRoots[key] = [])).push(entry);
|
|
541
361
|
}
|
|
542
|
-
const batches = Object.values(groupedSrcRoots).filter(
|
|
543
|
-
return batches.map(currentBatch => {
|
|
362
|
+
const batches = Object.values(groupedSrcRoots).filter(utils_1.hasAtLeastOneItem);
|
|
363
|
+
return Promise.all(batches.map(async (currentBatch) => {
|
|
544
364
|
const { bundleAnalyzer, assumeGlobalizedPlauditLibraries, externalize } = currentBatch[0].dest;
|
|
545
|
-
const { plugins
|
|
546
|
-
if (!processingModules || !
|
|
365
|
+
const { plugins } = buildCommonPluginConfig(coordinator, webpackConfig, config, bundleAnalyzer, assumeGlobalizedPlauditLibraries, externalize);
|
|
366
|
+
if (!processingModules || !hasAnyNonModuleBuilds) {
|
|
547
367
|
handleDisablingTSCheckerIfNecessary(currentBatch.flatMap(a => a.srcRoots), scriptExtension, plugins);
|
|
548
368
|
}
|
|
549
|
-
const
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
for (const
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
}
|
|
560
|
-
plugin = new EnhancedBlockJSONPlugin_1.EnhancedBlockJSONPlugin(config, dest, removeEmptyScriptsPlugin, contextPath, (0, common_config_helpers_1.resolveEntryFromDirectory)(commonConfig, srcRoot, dest));
|
|
561
|
-
plugins.push(plugin);
|
|
562
|
-
if (!processingModules) {
|
|
563
|
-
plugins.push(new WPMLConfigBuilder_1.WPMLConfigBuilderPlugin(dest.destination, plugin));
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
else if (sourceType === "extensions" /* SourceType.extensions */) {
|
|
567
|
-
if (!srcIsDirectory) {
|
|
568
|
-
continue;
|
|
569
|
-
}
|
|
570
|
-
const entry = async () => {
|
|
571
|
-
const rawEntrypoints = [];
|
|
572
|
-
for await (const dirent of await (0, promises_1.opendir)(srcRoot)) {
|
|
573
|
-
if ((0, shared_1.shouldBeSkipped)(dirent.name)) {
|
|
574
|
-
continue;
|
|
575
|
-
}
|
|
576
|
-
if (dirent.isFile()) {
|
|
577
|
-
if (applicableExtensionTest(dirent.name)) {
|
|
578
|
-
const absoluteSrc = (0, common_config_helpers_1.joinPossiblyAbsolutePaths)(srcRoot, dirent.name);
|
|
579
|
-
const extensionId = (0, node_path_1.parse)(dirent.name).name;
|
|
580
|
-
rawEntrypoints.push([(0, node_path_1.join)(dest.destination, (0, node_path_1.basename)(absoluteSrc, (0, node_path_1.extname)(absoluteSrc))), {
|
|
581
|
-
import: [absoluteSrc],
|
|
582
|
-
plauditMetadata: { dest, absoluteSrc, extensionId }
|
|
583
|
-
}]);
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
else if (dirent.isDirectory()) {
|
|
587
|
-
rawEntrypoints.push(...await walkExtensionsTree((0, node_path_1.join)(srcRoot, dirent.name), dest, applicableExtensionTest, [dirent.name]));
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
return Object.fromEntries(rawEntrypoints);
|
|
591
|
-
};
|
|
592
|
-
plugin = config.extensionsVersion > 1
|
|
593
|
-
? new ExtensionsConfigFileGeneratorPlugin_1.ExtensionsConfigFileGeneratorPlugin(config, srcRoot, dest, contextPath, entry)
|
|
594
|
-
: new ExtensionsConfigFileGeneratorPluginV1_1.ExtensionsConfigFileGeneratorPluginV1(dest.destination, contextPath, entry);
|
|
595
|
-
plugins.push(plugin);
|
|
596
|
-
}
|
|
597
|
-
else if (sourceType === "plain" /* SourceType.plain */) {
|
|
598
|
-
const absoluteSrc = typeof srcRoot === 'string' ? srcRoot : srcRoot[0];
|
|
599
|
-
if (!srcIsDirectory && !applicableExtensionTest(absoluteSrc)) {
|
|
600
|
-
continue;
|
|
601
|
-
}
|
|
602
|
-
const baseDest = stripExtension(dest.destination);
|
|
603
|
-
if (config.plainEntrypointsVersion > 1) {
|
|
604
|
-
const entry = srcIsDirectory // This being true implies that srcRoot is not an array
|
|
605
|
-
? (0, common_config_helpers_1.resolveEntryFromDirectory)(commonConfig, srcRoot, dest)
|
|
606
|
-
: () => ({ [baseDest]: { import: Array.isArray(srcRoot) ? srcRoot : [srcRoot], plauditMetadata: { purpose: "plain-entrypoint", dest, absoluteSrc } } });
|
|
607
|
-
plugin = new PlainEntrypointsConfigFileGeneratorPlugin_1.PlainEntrypointsConfigFileGeneratorPlugin(config, process.cwd(), config.outputDir, dest, config.useUnifiedLoader, contextPath, entry);
|
|
608
|
-
}
|
|
609
|
-
else {
|
|
610
|
-
if (srcIsDirectory) {
|
|
611
|
-
console.error("Using directory mode with legacy plain entrypoint handling is not supported");
|
|
612
|
-
continue;
|
|
613
|
-
}
|
|
614
|
-
plugin = new EnhancedDynamicEntryPlugin_1.EnhancedDynamicEntryPlugin(contextPath, () => ({ [baseDest]: { import: Array.isArray(srcRoot) ? srcRoot : [srcRoot], plauditMetadata: { purpose: "plain-entrypoint", dest, absoluteSrc } } }));
|
|
369
|
+
const batchProcessor = new api_1.IndividualBatchProcessor(plugins, canClean, hasAnyNonModuleBuilds, entrypointFields, scriptExtension);
|
|
370
|
+
const configLevelProps = { config, hasAnyNonModuleBuilds, webpackConfig };
|
|
371
|
+
await wrapperManager.hooks.batch.promise(batchProcessor, configLevelProps);
|
|
372
|
+
await batchProcessor.hooks.beforeBatch.promise();
|
|
373
|
+
for (const item of currentBatch) {
|
|
374
|
+
if (item.dest.sourceType && !wrapperManager.supportedSourceTypes.has(item.dest.sourceType)) {
|
|
375
|
+
let supportedSourceTypes = wrapperManager.supportedSourceTypes.values().map(st => "'" + st + "'").toArray().join(", ");
|
|
376
|
+
if (wrapperManager.supportedSourceTypes.size > 2) {
|
|
377
|
+
const splitIndex = supportedSourceTypes.lastIndexOf("', '") + 2;
|
|
378
|
+
supportedSourceTypes = supportedSourceTypes.substring(0, splitIndex) + " and" + supportedSourceTypes.substring(splitIndex);
|
|
615
379
|
}
|
|
616
|
-
|
|
617
|
-
}
|
|
618
|
-
else {
|
|
619
|
-
console.error("Unrecognized sourceType");
|
|
380
|
+
(0, utils_1.emitError)(`Encountered an unsupported source type: ${item.dest.sourceType}. The supported source types are ${supportedSourceTypes}`);
|
|
620
381
|
continue;
|
|
621
382
|
}
|
|
622
|
-
|
|
623
|
-
const
|
|
624
|
-
if (
|
|
625
|
-
|
|
626
|
-
patterns: [{
|
|
627
|
-
from: config.standaloneBlocks ? '**/*.(php|twig|svg)' : '**/*.(asset\.php|svg)', //TODO: I'm pretty sure that the dots need proper escaping
|
|
628
|
-
to: dest.destination,
|
|
629
|
-
context: srcRoot /* canCopyFiles can only be true if srcRoot is a string, so this is safe */, noErrorOnMissing: true
|
|
630
|
-
}]
|
|
631
|
-
}));
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
plugins.push(new UnifiedLoaderGenerator_1.UnifiedLoaderGenerator(config));
|
|
635
|
-
return (0, common_config_helpers_1.commonMakeWebpackConfig)(config, commonConfig, webpackConfig, externalize, plugins, canClean && batches.length < 2);
|
|
636
|
-
}).filter(cfg => cfg !== undefined);
|
|
637
|
-
}
|
|
638
|
-
async function walkExtensionsTree(srcRoot, dest, applicableExtensionTest, parents) {
|
|
639
|
-
const res = [];
|
|
640
|
-
for await (const dirent of await (0, promises_1.opendir)(srcRoot)) {
|
|
641
|
-
if ((0, shared_1.shouldBeSkipped)(dirent.name)) {
|
|
642
|
-
continue;
|
|
643
|
-
}
|
|
644
|
-
if (dirent.isFile()) {
|
|
645
|
-
if (!applicableExtensionTest(dirent.name)) {
|
|
383
|
+
await batchProcessor.hooks.beforeDestinationHandler.promise(item);
|
|
384
|
+
const destinationHandler = batchProcessor.hooks.destinationHandler.call(item);
|
|
385
|
+
if (destinationHandler === undefined) {
|
|
386
|
+
await batchProcessor.hooks.afterDestinationHandler.promise(item, destinationHandler);
|
|
646
387
|
continue;
|
|
647
388
|
}
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
continue;
|
|
389
|
+
if (Array.isArray(destinationHandler.plugin)) {
|
|
390
|
+
plugins.push(...destinationHandler.plugin);
|
|
651
391
|
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
if (Object.keys(parsedFilename.locations).length === 1) {
|
|
655
|
-
if (parsedFilename.locations.clientView) {
|
|
656
|
-
destFile = `view-${parsedFilename.type}`;
|
|
657
|
-
}
|
|
658
|
-
else if (parsedFilename.locations.clientEditor) {
|
|
659
|
-
destFile = `editor-${parsedFilename.type}`;
|
|
660
|
-
}
|
|
661
|
-
else {
|
|
662
|
-
destFile = (0, node_path_1.basename)(absoluteSrc, (0, node_path_1.extname)(absoluteSrc));
|
|
663
|
-
}
|
|
392
|
+
else if (destinationHandler.plugin !== undefined) {
|
|
393
|
+
plugins.push(destinationHandler.plugin);
|
|
664
394
|
}
|
|
665
|
-
|
|
666
|
-
|
|
395
|
+
plugins.push(...wrapperManager.emitterPlugins
|
|
396
|
+
.flatMap(cb => cb(configLevelProps, item, destinationHandler))
|
|
397
|
+
.filter(p => p !== undefined));
|
|
398
|
+
await batchProcessor.hooks.afterDestinationHandler.promise(item, destinationHandler);
|
|
399
|
+
const { dest, src, srcIsDirectory, srcRoot } = item;
|
|
400
|
+
if (destinationHandler.supportsAssetCopying ?? true) {
|
|
401
|
+
if (srcIsDirectory && src !== dest.destination) {
|
|
402
|
+
plugins.push(new copy_webpack_plugin_1.default({
|
|
403
|
+
patterns: [{
|
|
404
|
+
from: config.standaloneBlocks ? '**/*.(php|twig|svg)' : '**/*.(asset.php|svg)',
|
|
405
|
+
to: dest.destination,
|
|
406
|
+
context: srcRoot /* canCopyFiles can only be true if srcRoot is a string, so this is safe */,
|
|
407
|
+
noErrorOnMissing: true,
|
|
408
|
+
}]
|
|
409
|
+
}));
|
|
410
|
+
}
|
|
667
411
|
}
|
|
668
|
-
const extensionId = parents.join("-") + "-" + destFile;
|
|
669
|
-
res.push([(0, node_path_1.join)(dest.destination, ...parents, destFile), {
|
|
670
|
-
import: [absoluteSrc],
|
|
671
|
-
plauditMetadata: { dest, absoluteSrc, extensionId }
|
|
672
|
-
}]);
|
|
673
|
-
}
|
|
674
|
-
else if (dirent.isDirectory()) {
|
|
675
|
-
res.push(...await walkExtensionsTree((0, node_path_1.join)(srcRoot, dirent.name), dest, applicableExtensionTest, [...parents, dirent.name]));
|
|
676
412
|
}
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
return (0, node_path_1.join)((0, node_path_1.dirname)(filepath), (0, node_path_1.basename)(filepath, (0, node_path_1.extname)(filepath)));
|
|
413
|
+
plugins.push(new AdditionalDependencyInjectorPlugin_1.AdditionalDependencyInjectorPlugin());
|
|
414
|
+
await batchProcessor.hooks.afterBatch.promise(plugins);
|
|
415
|
+
return (0, common_config_helpers_1.commonMakeWebpackConfig)(wrapperManager, config, commonConfig, webpackConfig, externalize, plugins, canClean && batches.length < 2, hasAnyNonModuleBuilds);
|
|
416
|
+
}));
|
|
682
417
|
}
|
|
683
|
-
module.exports =
|
|
418
|
+
module.exports = async (config, webpackConfig = require("@wordpress/scripts/config/webpack.config")) => {
|
|
684
419
|
const { cfg, sources } = buildVerifiedConfig(config);
|
|
685
|
-
|
|
420
|
+
const { coordinator, finalizer } = RootCoordinatorPluginImpl_1.RootCoordinatorPluginImpl.make();
|
|
421
|
+
const wrapperManager = new api_1.WrapperManager(coordinator, cfg);
|
|
422
|
+
await (0, register_1.registerBuiltins)(wrapperManager);
|
|
423
|
+
await (0, auto_registering_plugins_loader_1.registerAutoLoadingPlugins)(wrapperManager);
|
|
424
|
+
if (config.wrapperPlugins) {
|
|
425
|
+
for (const plugin of config.wrapperPlugins) {
|
|
426
|
+
await plugin.register(wrapperManager);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
await internal_pseudo_plugin_1.default.register(wrapperManager);
|
|
430
|
+
if (Array.isArray(webpackConfig) && (0, utils_1.arrayIsLength)(webpackConfig, 1)) {
|
|
686
431
|
webpackConfig = webpackConfig[0];
|
|
687
432
|
}
|
|
688
433
|
if (Array.isArray(webpackConfig)) {
|
|
689
434
|
const hasNonModuleCompiler = webpackConfig.some(cfg => !cfg.output?.module);
|
|
690
|
-
return webpackConfig.toSorted((a, b) => {
|
|
435
|
+
return finalizer((await Promise.all(webpackConfig.toSorted((a, b) => {
|
|
691
436
|
if (a.output?.module) {
|
|
692
437
|
return b.output?.module ? 0 : -1;
|
|
693
438
|
}
|
|
694
439
|
return b.output?.module ? 1 : 0;
|
|
695
|
-
}).
|
|
440
|
+
}).map(wpCfg => processIndividualWebpackConfig(wrapperManager, coordinator, cfg, wpCfg, sources, false, hasNonModuleCompiler)))).flat());
|
|
696
441
|
}
|
|
697
|
-
return processIndividualWebpackConfig(cfg, webpackConfig, sources, true, false);
|
|
442
|
+
return finalizer(await processIndividualWebpackConfig(wrapperManager, coordinator, cfg, webpackConfig, sources, true, false));
|
|
698
443
|
};
|
|
444
|
+
//# sourceMappingURL=wordpress-scripts-wrapper.js.map
|