@plaudit/webpack-extensions 2.79.0 → 2.80.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/build/plugins/AdditionalDependencyInjectorPlugin.d.ts +1 -1
- package/build/plugins/dependency-extraction-webpack-plugin-config-builder.d.ts +1 -1
- package/build/plugins/dependency-extraction-webpack-plugin-config-builder.js +18 -27
- package/build/shared.d.ts +2 -1
- package/build/wordpress-scripts-wrapper.js +2 -4
- package/package.json +2 -2
|
@@ -6,7 +6,7 @@ export declare class AdditionalDependencyInjectorPlugin extends AbstractBiPhasic
|
|
|
6
6
|
private readonly processingModules;
|
|
7
7
|
private readonly addExternalizedDep;
|
|
8
8
|
private readonly referencePlugin;
|
|
9
|
-
constructor(config: VerifiedPlauditWordpressWebpackConfig, processingModules: boolean, addExternalizedDep: (dep: string) => void, referencePlugin: AbstractBiPhasicGroupAndEntryPlugin<any>);
|
|
9
|
+
constructor(config: VerifiedPlauditWordpressWebpackConfig, processingModules: boolean | undefined, addExternalizedDep: (dep: string) => void, referencePlugin: AbstractBiPhasicGroupAndEntryPlugin<any>);
|
|
10
10
|
protected attachStandardPhase(compilation: Compilation): void;
|
|
11
11
|
protected attachUniquePhase(): void;
|
|
12
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import DependencyExtractionWebpackPlugin from "@wordpress/dependency-extraction-webpack-plugin";
|
|
2
|
-
import
|
|
2
|
+
import { Externals } from "../shared";
|
|
3
3
|
import type { Configuration } from "webpack";
|
|
4
4
|
export declare function makeDependencyExtractionPlugin(externals: Externals | undefined, assumeGlobalizedPlauditLibraries: boolean, wantsGroupedDepData: boolean, externalizing: Required<Configuration>['output']['library']): {
|
|
5
5
|
instance: DependencyExtractionWebpackPlugin;
|
|
@@ -89,38 +89,29 @@ function firstLayersEqual(first, second) {
|
|
|
89
89
|
return true;
|
|
90
90
|
}
|
|
91
91
|
const PLAUDIT_NAMESPACE = '@plaudit/';
|
|
92
|
-
const EXTERNALIZABLE_PLAUDIT_LIBRARIES =
|
|
92
|
+
const EXTERNALIZABLE_PLAUDIT_LIBRARIES = {
|
|
93
|
+
...Object.fromEntries(['@plaudit/frontend-apis', '@plaudit/library-extensions', '@plaudit/block-supports', '@plaudit/gutenberg-api-extensions']
|
|
94
|
+
.map(req => {
|
|
95
|
+
return [req, {
|
|
96
|
+
import: ['plaudit', camelCaseDash(req.substring(PLAUDIT_NAMESPACE.length))],
|
|
97
|
+
handle: `plaudit-${req.substring(PLAUDIT_NAMESPACE.length)}`
|
|
98
|
+
}];
|
|
99
|
+
})),
|
|
100
|
+
"@plaudit/wp-consent-api": { handle: "wp-consent-api", import: ['plaudit'] },
|
|
101
|
+
"@plaudit/analytics-integrations-api": { handle: "plaudit/analytics-integrations/api", import: ['plaudit', 'analyticsIntegrations', 'api'] },
|
|
102
|
+
"google.maps": { handle: "plaudit-base/google-maps-api", import: ['google', 'maps'] }
|
|
103
|
+
};
|
|
93
104
|
function plauditRequestToExternal(ext) {
|
|
94
105
|
return function (request) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
else if (request.startsWith('@plaudit/gutenberg-api-extensions')) {
|
|
99
|
-
return handleExternalizingEqualsPossibleExternal({ import: ['plaudit', 'gutenbergApiExtensions'], handle: "" }, ext)?.import;
|
|
100
|
-
}
|
|
101
|
-
else if (request.startsWith('@plaudit/wp-consent-api')) {
|
|
102
|
-
return handleExternalizingEqualsPossibleExternal({ import: ['plaudit'], handle: "" }, ext)?.import;
|
|
103
|
-
}
|
|
104
|
-
else if (request.startsWith('@plaudit/analytics-integrations-api')) {
|
|
105
|
-
return handleExternalizingEqualsPossibleExternal({ import: ['plaudit', 'analyticsIntegrations', 'api'], handle: "" }, ext)?.import;
|
|
106
|
-
}
|
|
107
|
-
return undefined;
|
|
106
|
+
const req = EXTERNALIZABLE_PLAUDIT_LIBRARIES[normalizeRequest(request)];
|
|
107
|
+
return req ? handleExternalizingEqualsPossibleExternal(req, ext)?.import : undefined;
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
110
|
function plauditRequestToHandle(request) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return 'plaudit-gutenberg-api-extensions';
|
|
116
|
-
}
|
|
117
|
-
else if (request.startsWith('@plaudit/wp-consent-api')) {
|
|
118
|
-
return 'wp-consent-api';
|
|
119
|
-
}
|
|
120
|
-
else if (request.startsWith('@plaudit/analytics-integrations-api')) {
|
|
121
|
-
return 'plaudit/analytics-integrations/api';
|
|
122
|
-
}
|
|
123
|
-
return undefined;
|
|
111
|
+
return EXTERNALIZABLE_PLAUDIT_LIBRARIES[normalizeRequest(request)]?.handle;
|
|
112
|
+
}
|
|
113
|
+
function normalizeRequest(request) {
|
|
114
|
+
return request.startsWith("@plaudit/gutenberg-api-extensions/") ? "@plaudit/gutenberg-api-extensions" : request;
|
|
124
115
|
}
|
|
125
116
|
function curryRequestHandlers(primary, secondary) {
|
|
126
117
|
return (...args) => primary(...args) ?? secondary(...args);
|
package/build/shared.d.ts
CHANGED
|
@@ -63,10 +63,11 @@ export declare const enum SourceType {
|
|
|
63
63
|
plain = "plain"
|
|
64
64
|
}
|
|
65
65
|
export declare function determineCurrentSourceType(dest: string | AdvancedOutputConfig, srcIsDirectory: boolean): SourceType;
|
|
66
|
-
export type
|
|
66
|
+
export type ObjectIndividualExternalDepConfig = {
|
|
67
67
|
import?: string | [string, ...string[]];
|
|
68
68
|
handle: string;
|
|
69
69
|
};
|
|
70
|
+
export type IndividualExternalDepConfig = string | ObjectIndividualExternalDepConfig;
|
|
70
71
|
export type Externals = {
|
|
71
72
|
[dep: string]: IndividualExternalDepConfig;
|
|
72
73
|
};
|
|
@@ -368,8 +368,6 @@ function handleDisablingTSCheckerIfNecessary(srcRoot, scriptExtension, plugins)
|
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
370
|
function buildCommonPluginConfig(webpackConfig, config, bundleAnalyzer, assumeGlobalizedPlauditLibraries, externalize) {
|
|
371
|
-
const { externals } = config;
|
|
372
|
-
const processingModules = webpackConfig.output?.module ?? false;
|
|
373
371
|
const plugins = webpackConfig.plugins?.filter(v => !!v)
|
|
374
372
|
.filter(plugin => plugin.constructor.name !== 'RtlCssPlugin')
|
|
375
373
|
.filter(plugin => plugin.constructor.name !== 'CopyPlugin' && plugin.constructor.name !== 'CleanWebpackPlugin')
|
|
@@ -410,13 +408,13 @@ function buildCommonPluginConfig(webpackConfig, config, bundleAnalyzer, assumeGl
|
|
|
410
408
|
console.error("Once those commands have finished, re-run whichever command had this error. If it still doesn't work, report the issue immediately.");
|
|
411
409
|
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");
|
|
412
410
|
}
|
|
413
|
-
const builtDependencyExtractionWebpackPlugin = (0, dependency_extraction_webpack_plugin_config_builder_1.makeDependencyExtractionPlugin)(externals, assumeGlobalizedPlauditLibraries, true, externalize);
|
|
411
|
+
const builtDependencyExtractionWebpackPlugin = (0, dependency_extraction_webpack_plugin_config_builder_1.makeDependencyExtractionPlugin)(config.externals, assumeGlobalizedPlauditLibraries, true, externalize);
|
|
414
412
|
plugins[dependencyExtractionPluginIndex] = builtDependencyExtractionWebpackPlugin.instance;
|
|
415
413
|
plugins.push(new BrowserSyncPlugin_1.BrowserSyncPlugin());
|
|
416
414
|
return {
|
|
417
415
|
plugins, removeEmptyScriptsPlugin,
|
|
418
416
|
makeAdditionalDependencyInjectorPlugin(referencePlugin) {
|
|
419
|
-
return new AdditionalDependencyInjectorPlugin_1.AdditionalDependencyInjectorPlugin(config,
|
|
417
|
+
return new AdditionalDependencyInjectorPlugin_1.AdditionalDependencyInjectorPlugin(config, webpackConfig.output?.module, builtDependencyExtractionWebpackPlugin.addExternalizedDep, referencePlugin);
|
|
420
418
|
}
|
|
421
419
|
};
|
|
422
420
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plaudit/webpack-extensions",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.80.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"files": [
|
|
6
6
|
"/build"
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"postcss-reporter": "^7.1.0",
|
|
62
62
|
"postcss-simple-vars": "^7.0.1",
|
|
63
63
|
"postcss-url": "^10.1.3",
|
|
64
|
-
"webpack": "^5.104.
|
|
64
|
+
"webpack": "^5.104.1",
|
|
65
65
|
"webpack-remove-empty-scripts": "^1.1.1",
|
|
66
66
|
"xml-formatter": "^3.6.7"
|
|
67
67
|
},
|