@plaudit/webpack-extensions 2.46.0 → 2.47.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/README.md +1 -7
- package/build/wordpress-scripts-wrapper/dependency-extraction-webpack-plugin-config-builder.d.ts +2 -1
- package/build/wordpress-scripts-wrapper/dependency-extraction-webpack-plugin-config-builder.js +64 -15
- package/build/wordpress-scripts-wrapper.d.ts +1 -1
- package/build/wordpress-scripts-wrapper.js +2 -2
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -2,12 +2,6 @@
|
|
|
2
2
|
To test locally, either set up yarn to pull from this folder or (ideally) build and copy the resulting built files into another project for testing purposes.
|
|
3
3
|
|
|
4
4
|
# To Deploy
|
|
5
|
-
If you haven't
|
|
6
5
|
```
|
|
7
|
-
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
To deploy
|
|
11
|
-
```
|
|
12
|
-
./publish.sh y
|
|
6
|
+
publish-pnpm-package
|
|
13
7
|
```
|
package/build/wordpress-scripts-wrapper/dependency-extraction-webpack-plugin-config-builder.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import DependencyExtractionWebpackPlugin from "@wordpress/dependency-extraction-webpack-plugin";
|
|
2
|
+
import type { Configuration } from "webpack";
|
|
2
3
|
export type IndividualExternalDepConfig = string | {
|
|
3
4
|
import?: string | [string, ...string[]];
|
|
4
5
|
handle: string;
|
|
@@ -6,7 +7,7 @@ export type IndividualExternalDepConfig = string | {
|
|
|
6
7
|
export type Externals = {
|
|
7
8
|
[dep: string]: IndividualExternalDepConfig;
|
|
8
9
|
};
|
|
9
|
-
export declare function makeDependencyExtractionPlugin(externals: Externals | undefined, assumeGlobalizedPlauditLibraries: boolean, wantsGroupedDepData: boolean): {
|
|
10
|
+
export declare function makeDependencyExtractionPlugin(externals: Externals | undefined, assumeGlobalizedPlauditLibraries: boolean, wantsGroupedDepData: boolean, externalizing: Required<Configuration>['output']['library']): {
|
|
10
11
|
instance: DependencyExtractionWebpackPlugin;
|
|
11
12
|
addExternalizedDep: (dep: string) => void;
|
|
12
13
|
};
|
package/build/wordpress-scripts-wrapper/dependency-extraction-webpack-plugin-config-builder.js
CHANGED
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.makeDependencyExtractionPlugin = makeDependencyExtractionPlugin;
|
|
7
7
|
const dependency_extraction_webpack_plugin_1 = __importDefault(require("@wordpress/dependency-extraction-webpack-plugin"));
|
|
8
|
-
function makeDependencyExtractionPlugin(externals, assumeGlobalizedPlauditLibraries, wantsGroupedDepData) {
|
|
9
|
-
const baseProps = makeDependencyExtractionPluginProps(externals, assumeGlobalizedPlauditLibraries);
|
|
8
|
+
function makeDependencyExtractionPlugin(externals, assumeGlobalizedPlauditLibraries, wantsGroupedDepData, externalizing) {
|
|
9
|
+
const baseProps = makeDependencyExtractionPluginProps(externals, assumeGlobalizedPlauditLibraries, externalizing);
|
|
10
10
|
const instance = new dependency_extraction_webpack_plugin_1.default(wantsGroupedDepData ? { ...baseProps, outputFormat: "json", combineAssets: true } : baseProps);
|
|
11
11
|
return {
|
|
12
12
|
instance,
|
|
@@ -15,11 +15,11 @@ function makeDependencyExtractionPlugin(externals, assumeGlobalizedPlauditLibrar
|
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
function makeDependencyExtractionPluginProps(externals, assumeGlobalizedPlauditLibraries) {
|
|
18
|
+
function makeDependencyExtractionPluginProps(externals, assumeGlobalizedPlauditLibraries, externalizing) {
|
|
19
19
|
if (!externals) {
|
|
20
20
|
if (assumeGlobalizedPlauditLibraries) {
|
|
21
21
|
return {
|
|
22
|
-
requestToExternal: plauditRequestToExternal,
|
|
22
|
+
requestToExternal: plauditRequestToExternal(externalizing),
|
|
23
23
|
requestToHandle: plauditRequestToHandle
|
|
24
24
|
};
|
|
25
25
|
}
|
|
@@ -38,11 +38,11 @@ function makeDependencyExtractionPluginProps(externals, assumeGlobalizedPlauditL
|
|
|
38
38
|
}
|
|
39
39
|
const resolvePossibleExternal = (request) => {
|
|
40
40
|
if (request in exactExternals) {
|
|
41
|
-
return exactExternals[request];
|
|
41
|
+
return handleExternalizingEqualsPossibleExternal(exactExternals[request], externalizing);
|
|
42
42
|
}
|
|
43
43
|
for (const [key, value] of suffixExternals) {
|
|
44
44
|
if (request.endsWith(key)) {
|
|
45
|
-
return value;
|
|
45
|
+
return handleExternalizingEqualsPossibleExternal(value, externalizing);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
return undefined;
|
|
@@ -66,7 +66,7 @@ function makeDependencyExtractionPluginProps(externals, assumeGlobalizedPlauditL
|
|
|
66
66
|
};
|
|
67
67
|
if (assumeGlobalizedPlauditLibraries) {
|
|
68
68
|
return {
|
|
69
|
-
requestToExternal: curryRequestHandlers(baselineRequestToExternal, plauditRequestToExternal),
|
|
69
|
+
requestToExternal: curryRequestHandlers(baselineRequestToExternal, plauditRequestToExternal(externalizing)),
|
|
70
70
|
requestToHandle: curryRequestHandlers(baselineRequestToHandle, plauditRequestToHandle),
|
|
71
71
|
};
|
|
72
72
|
}
|
|
@@ -77,16 +77,29 @@ function makeDependencyExtractionPluginProps(externals, assumeGlobalizedPlauditL
|
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (EXTERNALIZABLE_PLAUDIT_LIBRARIES.includes(request)) {
|
|
84
|
-
return ['plaudit', camelCaseDash(request.substring(PLAUDIT_NAMESPACE.length))];
|
|
80
|
+
function firstLayersEqual(first, second) {
|
|
81
|
+
if (first.length !== second.length) {
|
|
82
|
+
return false;
|
|
85
83
|
}
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
for (let i = 0; i < first.length; i++) {
|
|
85
|
+
if (first[i] !== second[i]) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
88
|
}
|
|
89
|
-
return
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
const PLAUDIT_NAMESPACE = '@plaudit/';
|
|
92
|
+
const EXTERNALIZABLE_PLAUDIT_LIBRARIES = ['@plaudit/frontend-apis', '@plaudit/library-extensions'];
|
|
93
|
+
function plauditRequestToExternal(ext) {
|
|
94
|
+
return function (request) {
|
|
95
|
+
if (EXTERNALIZABLE_PLAUDIT_LIBRARIES.includes(request)) {
|
|
96
|
+
return handleExternalizingEqualsPossibleExternal({ import: ['plaudit', camelCaseDash(request.substring(PLAUDIT_NAMESPACE.length))], handle: "" }, ext)?.import;
|
|
97
|
+
}
|
|
98
|
+
else if (request.startsWith('@plaudit/gutenberg-api-extensions')) {
|
|
99
|
+
return handleExternalizingEqualsPossibleExternal({ import: ['plaudit', 'gutenbergApiExtensions'], handle: "" }, ext)?.import;
|
|
100
|
+
}
|
|
101
|
+
return undefined;
|
|
102
|
+
};
|
|
90
103
|
}
|
|
91
104
|
function plauditRequestToHandle(request) {
|
|
92
105
|
if (EXTERNALIZABLE_PLAUDIT_LIBRARIES.includes(request)) {
|
|
@@ -106,3 +119,39 @@ function curryRequestHandlers(primary, secondary) {
|
|
|
106
119
|
function camelCaseDash(string) {
|
|
107
120
|
return string.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
108
121
|
}
|
|
122
|
+
function handleExternalizingEqualsPossibleExternal(possibleExternal, ext) {
|
|
123
|
+
if (!ext || !possibleExternal) {
|
|
124
|
+
return possibleExternal;
|
|
125
|
+
}
|
|
126
|
+
const possibleImport = typeof possibleExternal === 'string' ? possibleExternal : possibleExternal['import'];
|
|
127
|
+
if (!possibleImport) {
|
|
128
|
+
return possibleExternal;
|
|
129
|
+
}
|
|
130
|
+
if (typeof ext === 'string') {
|
|
131
|
+
if (typeof possibleImport === 'string') {
|
|
132
|
+
return ext !== possibleImport ? possibleExternal : undefined;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
return possibleImport.length !== 1 || ext !== possibleImport[0] ? possibleExternal : undefined;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else if (Array.isArray(ext)) {
|
|
139
|
+
if (typeof possibleImport === 'string') {
|
|
140
|
+
return ext.length !== 1 || ext[0] !== possibleImport ? possibleExternal : undefined;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
return !firstLayersEqual(ext, possibleImport) ? possibleExternal : undefined;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
else if ('name' in ext) {
|
|
147
|
+
return handleExternalizingEqualsPossibleExternal(possibleExternal, ext.name);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
for (const key of ['amd', 'commonjs', 'root']) {
|
|
151
|
+
if (key in ext && handleExternalizingEqualsPossibleExternal(possibleExternal, ext[key])) {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return possibleExternal;
|
|
157
|
+
}
|
|
@@ -7,7 +7,7 @@ interface AdvancedOutputConfig {
|
|
|
7
7
|
additionalDependencies?: string[];
|
|
8
8
|
directoryLayout?: 'blocks' | 'extensions' | 'plain';
|
|
9
9
|
assumeGlobalizedPlauditLibraries?: boolean;
|
|
10
|
-
externalize?:
|
|
10
|
+
externalize?: Required<Configuration>['output']['library'];
|
|
11
11
|
}
|
|
12
12
|
type PlauditWordpressWebpackConfig = {
|
|
13
13
|
standaloneBlocks?: boolean;
|
|
@@ -339,8 +339,8 @@ function processIndividualWebpackConfig(config, webpackConfig, sources) {
|
|
|
339
339
|
console.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 file");
|
|
340
340
|
}
|
|
341
341
|
else {
|
|
342
|
-
const localAssumeGlobalizedPlauditLibraries = typeof dest !== 'string' ? dest.assumeGlobalizedPlauditLibraries : undefined;
|
|
343
|
-
const builtDependencyExtractionWebpackPlugin = (0, dependency_extraction_webpack_plugin_config_builder_1.makeDependencyExtractionPlugin)(externals, localAssumeGlobalizedPlauditLibraries
|
|
342
|
+
const localAssumeGlobalizedPlauditLibraries = (typeof dest !== 'string' ? dest.assumeGlobalizedPlauditLibraries : undefined) ?? assumeGlobalizedPlauditLibraries;
|
|
343
|
+
const builtDependencyExtractionWebpackPlugin = (0, dependency_extraction_webpack_plugin_config_builder_1.makeDependencyExtractionPlugin)(externals, localAssumeGlobalizedPlauditLibraries, combineAssetMetadata && !processingModules && forBlocksDirectory, typeof dest !== 'string' ? dest.externalize : undefined);
|
|
344
344
|
plugins[pluginIndex] = builtDependencyExtractionWebpackPlugin.instance;
|
|
345
345
|
plugins.push(new AdditionalDependencyInjectorPlugin_1.default(typeof dest !== 'string' && dest.additionalDependencies ? dest.additionalDependencies : [], processingModules, builtDependencyExtractionWebpackPlugin.addExternalizedDep));
|
|
346
346
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plaudit/webpack-extensions",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.47.0",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"files": [
|
|
6
6
|
"/build"
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@plaudit/gutenberg-api-extensions": "^2.
|
|
19
|
+
"@plaudit/gutenberg-api-extensions": "^2.68.1",
|
|
20
20
|
"@types/browser-sync-webpack-plugin": "^2.2.5",
|
|
21
|
-
"@types/node": "^22.15.
|
|
21
|
+
"@types/node": "^22.15.18",
|
|
22
22
|
"@types/postcss-functions": "^4.0.4",
|
|
23
23
|
"@types/tapable": "^2.2.7",
|
|
24
24
|
"@types/webpack": "^5.28.5",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"@plaudit/postcss-silent-extend": "^3.0.0",
|
|
35
35
|
"@plaudit/postcss-strip-units": "^3.0.0",
|
|
36
36
|
"@plaudit/postcss-variables": "^1.1.0",
|
|
37
|
-
"@wordpress/dependency-extraction-webpack-plugin": "^6.
|
|
38
|
-
"@wordpress/scripts": "^30.
|
|
37
|
+
"@wordpress/dependency-extraction-webpack-plugin": "^6.23.0",
|
|
38
|
+
"@wordpress/scripts": "^30.16.0",
|
|
39
39
|
"autoprefixer": "^10.4.21",
|
|
40
40
|
"browser-sync": "^3.0.4",
|
|
41
41
|
"clean-webpack-plugin": "^4.0.0",
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
"postcss-url": "^10.1.3",
|
|
63
63
|
"react": "^18.3.1",
|
|
64
64
|
"react-dom": "^18.3.1",
|
|
65
|
-
"webpack": "^5.99.
|
|
65
|
+
"webpack": "^5.99.8",
|
|
66
66
|
"webpack-remove-empty-scripts": "^1.0.4",
|
|
67
|
-
"xml-formatter": "^3.6.
|
|
67
|
+
"xml-formatter": "^3.6.6"
|
|
68
68
|
},
|
|
69
69
|
"engines": {
|
|
70
70
|
"node": ">=20"
|