@plaudit/webpack-extensions 3.21.2 → 4.0.0-rc.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/CHANGELOG.md +9 -1
- package/USER-GUIDE.md +2 -1
- package/package.json +27 -49
- 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/AdditionalDependencyInjectorPlugin.d.ts +0 -11
- package/dist/plugins/AdditionalDependencyInjectorPlugin.js +0 -58
- 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/MiniCSSExtractPluginErrorCleaner.d.ts +0 -4
- package/dist/plugins/MiniCSSExtractPluginErrorCleaner.js +0 -15
- 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/PackageConfigSanityChecker.d.ts +0 -4
- package/dist/plugins/PackageConfigSanityChecker.js +0 -30
- 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/VariablesJSMonitorPlugin.d.ts +0 -7
- package/dist/plugins/VariablesJSMonitorPlugin.js +0 -20
- package/dist/plugins/WPMLConfigBuilder.d.ts +0 -17
- package/dist/plugins/WPMLConfigBuilder.js +0 -472
- package/dist/plugins/dependency-extraction-webpack-plugin-config-builder.d.ts +0 -4
- package/dist/plugins/dependency-extraction-webpack-plugin-config-builder.js +0 -147
- package/dist/plugins/index.d.ts +0 -8
- package/dist/plugins/index.js +0 -24
- package/dist/plugins/static-configs.d.ts +0 -3
- package/dist/plugins/static-configs.js +0 -44
- package/dist/shared.d.ts +0 -311
- package/dist/shared.js +0 -536
- 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
- package/dist/utils/pseudo-semaphore.d.ts +0 -14
- package/dist/utils/pseudo-semaphore.js +0 -79
- package/dist/wordpress-ports/dependency-extraction-webpack-plugin/index.d.ts +0 -72
- package/dist/wordpress-ports/dependency-extraction-webpack-plugin/index.js +0 -518
- package/dist/wordpress-ports/dependency-extraction-webpack-plugin/util.d.ts +0 -56
- package/dist/wordpress-ports/dependency-extraction-webpack-plugin/util.js +0 -155
- package/dist/wordpress-scripts-wrapper.d.ts +0 -4
- package/dist/wordpress-scripts-wrapper.js +0 -698
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [4.0.0-rc.1] - 2026-10-15
|
|
9
|
+
### Changed
|
|
10
|
+
- Refactored this into a modular system
|
|
11
|
+
- Updated the
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
- Mountains of bugs
|
|
15
|
+
|
|
8
16
|
## [3.21.2] - 2026-10-15
|
|
9
17
|
### Fixed
|
|
10
18
|
- A desync with the dependencies in `@plaudit/gutenberg-api-extensions`
|
|
@@ -803,7 +811,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
803
811
|
|
|
804
812
|
## [2.61.2] - 2025-08-28
|
|
805
813
|
### Removed
|
|
806
|
-
- An unnecessary `accountForAlreadyDoing` flag from the code generated by `
|
|
814
|
+
- An unnecessary `accountForAlreadyDoing` flag from the code generated by `SpecialAssetsCollectorPlugin`
|
|
807
815
|
|
|
808
816
|
## [2.61.1] - 2025-08-28
|
|
809
817
|
### Fixed
|
package/USER-GUIDE.md
CHANGED
|
@@ -411,8 +411,9 @@ This section covers the shared options for entrypoints. See the [Entrypoint Type
|
|
|
411
411
|
- These are URL-style queries added to the end of entrypoint *source* paths and are used to set entrypoint-specific properties in Plain and Block contexts.
|
|
412
412
|
- If you find yourself using these, consider switching to [Location-Encoding Filenames](#location-encoding-filenames)
|
|
413
413
|
- At present, this is only being used to configure inlining, but expansion to other systems is being considered
|
|
414
|
-
- The available options are: `strategy`, `inline`, `in_footer`, `fetchpriority`, `position`, and `handle`
|
|
414
|
+
- The available options are: `strategy`, `inline`, `in_footer`, `preload`, `fetchpriority`, `crossorigin`, `position`, and `handle`
|
|
415
415
|
- Handle is only available on blocks – declare the handle using the [Locations object](#the-locations-object)
|
|
416
|
+
- `fetchpriority` and `crossorigin` will not have any effect unless `preload` is also set
|
|
416
417
|
|
|
417
418
|
### Boolean-form
|
|
418
419
|
- This is only available if `outputDir` has been set
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plaudit/webpack-extensions",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-rc.1",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,43 +9,40 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"/dist",
|
|
11
11
|
"README.md",
|
|
12
|
-
"LICENSE.md",
|
|
13
12
|
"CHANGELOG.md",
|
|
14
13
|
"USER-GUIDE.md"
|
|
15
14
|
],
|
|
16
15
|
"exports": {
|
|
17
|
-
"./
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"./
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
"dist/shared.d.ts"
|
|
33
|
-
]
|
|
16
|
+
"./api": {
|
|
17
|
+
"types": "./dist/api/index.d.ts",
|
|
18
|
+
"default": "./dist/api/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./wordpress-scripts-wrapper": {
|
|
21
|
+
"types": "./dist/wordpress-scripts-wrapper.d.ts",
|
|
22
|
+
"default": "./dist/wordpress-scripts-wrapper.js"
|
|
23
|
+
},
|
|
24
|
+
"./mocks": {
|
|
25
|
+
"types": "./dist/mocks/index.d.ts",
|
|
26
|
+
"default": "./dist/mocks/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./utils": {
|
|
29
|
+
"types": "./dist/utils/index.d.ts",
|
|
30
|
+
"default": "./dist/utils/index.js"
|
|
34
31
|
}
|
|
35
32
|
},
|
|
36
33
|
"devDependencies": {
|
|
37
34
|
"@plaudit/dev-webpack-plugin": "^1.5.0",
|
|
38
35
|
"@plaudit/gutenberg-api-extensions": "^2.101.1",
|
|
36
|
+
"@plaudit/library-extensions": "^1.1.1",
|
|
39
37
|
"@types/jsdom": "^30.0.0",
|
|
40
38
|
"@types/node": "^26.6.5",
|
|
41
|
-
"@types/
|
|
42
|
-
"@types/postcss-import": "^14.0.3",
|
|
43
|
-
"@types/tapable": "^2.3.0",
|
|
44
|
-
"@types/webpack-sources": "^3.2.3",
|
|
39
|
+
"@types/picomatch": "^4.0.3",
|
|
45
40
|
"@wordpress/dependency-extraction-webpack-plugin": "^6.57.0",
|
|
46
41
|
"atob": "^2.1.2",
|
|
47
|
-
"
|
|
42
|
+
"immer": "^11.1.21",
|
|
48
43
|
"jest": "^30.5.2",
|
|
44
|
+
"jest-environment-node": "^30.5.2",
|
|
45
|
+
"js-yaml": "^5.4.3",
|
|
49
46
|
"lodash": "^4.18.1",
|
|
50
47
|
"mini-css-extract-plugin": "^2.10.2",
|
|
51
48
|
"mkdirp": "^3.0.1",
|
|
@@ -57,33 +54,19 @@
|
|
|
57
54
|
},
|
|
58
55
|
"dependencies": {
|
|
59
56
|
"@plaudit/php-writer": "^1.11.0",
|
|
60
|
-
"@plaudit/postcss-color-function": "^5.1.0",
|
|
61
|
-
"@plaudit/postcss-strip-units": "^3.0.0",
|
|
62
|
-
"@plaudit/postcss-variables": "^2.0.1",
|
|
63
57
|
"@wordpress/scripts": "^36.1.0",
|
|
64
|
-
"
|
|
65
|
-
"copy-webpack-plugin": "10.2.4",
|
|
66
|
-
"css-minimizer-webpack-plugin": "^8.0.0",
|
|
67
|
-
"cssnano": "^7.1.9",
|
|
58
|
+
"copy-webpack-plugin": "^14.0.0",
|
|
68
59
|
"fork-ts-checker-webpack-plugin": "^9.1.0",
|
|
69
60
|
"jsdom": "^30.1.2",
|
|
70
61
|
"json2php": "0.0.12",
|
|
71
|
-
"
|
|
72
|
-
"postcss-calc": "^10.1.1",
|
|
73
|
-
"postcss-functions": "^4.0.2",
|
|
74
|
-
"postcss-import": "^16.2.0",
|
|
75
|
-
"postcss-loader": "^8.2.1",
|
|
76
|
-
"postcss-mixins": "^12.1.2",
|
|
77
|
-
"postcss-nested": "^7.0.2",
|
|
78
|
-
"postcss-property-lookup": "^3.0.0",
|
|
79
|
-
"postcss-reporter": "^7.1.0",
|
|
80
|
-
"postcss-url": "^10.1.4",
|
|
62
|
+
"tapable": "^2.3.3",
|
|
81
63
|
"webpack": "^5.111.1",
|
|
82
64
|
"webpack-remove-empty-scripts": "^1.1.1",
|
|
83
65
|
"xml-formatter": "^3.7.0"
|
|
84
66
|
},
|
|
85
67
|
"peerDependencies": {
|
|
86
|
-
"@plaudit/dev-webpack-plugin": "^1.3.1"
|
|
68
|
+
"@plaudit/dev-webpack-plugin": "^1.3.1",
|
|
69
|
+
"immer": ">=9"
|
|
87
70
|
},
|
|
88
71
|
"peerDependenciesMeta": {
|
|
89
72
|
"@plaudit/dev-webpack-plugin": {
|
|
@@ -91,7 +74,7 @@
|
|
|
91
74
|
}
|
|
92
75
|
},
|
|
93
76
|
"engines": {
|
|
94
|
-
"node": ">=
|
|
77
|
+
"node": ">=24"
|
|
95
78
|
},
|
|
96
79
|
"scripts": {
|
|
97
80
|
"build": "tsc",
|
|
@@ -99,11 +82,6 @@
|
|
|
99
82
|
"build:clean": "pnpm run clean && pnpm run build",
|
|
100
83
|
"build:sync-wp-bundled-packages": "node tools/bundled-packages-sync.mts",
|
|
101
84
|
"watch": "tsc -w",
|
|
102
|
-
"
|
|
103
|
-
"test:no-build": "rm -rf tests/.tmp/coverage/jest && NODE_V8_COVERAGE=tests/.tmp/coverage/jest jest",
|
|
104
|
-
"test:update": "pnpm run build && rm -rf tests/.tmp/coverage/jest && NODE_V8_COVERAGE=tests/.tmp/coverage/jest jest -u",
|
|
105
|
-
"test:paths": "pnpm run build && jest \"tests/integration-[0-9]+x/paths\"",
|
|
106
|
-
"test:gaps": "node tests/tools/coverage-gaps.js",
|
|
107
|
-
"update": "pnpm add --config '@plaudit/pnpm-plugin-plaudit-config@*' && pnpm up"
|
|
85
|
+
"deps:conflicts": "node ../../tools/dependency-conflicts.mts"
|
|
108
86
|
}
|
|
109
87
|
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { MinimumViableMetadata, ParsedAssetJsonProvider, ParsedAssetsJson } from "../shared";
|
|
2
|
-
import type { ExtensibleEntryObject } from "../utils/common-config-helpers";
|
|
3
|
-
import { PseudoSemaphore } from "../utils/pseudo-semaphore";
|
|
4
|
-
import { AbstractBiPhasicGroupPlugin } from "./AbstractBiPhasicGroupPlugin";
|
|
5
|
-
import { type Compilation, type Compiler, type Entrypoint } from "webpack";
|
|
6
|
-
export type EntryProvider<M extends MinimumViableMetadata = MinimumViableMetadata> = () => ExtensibleEntryObject<M> | Promise<ExtensibleEntryObject<M>>;
|
|
7
|
-
export declare abstract class AbstractBiPhasicGroupAndEntryPlugin<M extends MinimumViableMetadata = MinimumViableMetadata> extends AbstractBiPhasicGroupPlugin {
|
|
8
|
-
private readonly context;
|
|
9
|
-
private readonly entry;
|
|
10
|
-
private static readonly configuredCompilations;
|
|
11
|
-
private readonly entryMetadataRecord;
|
|
12
|
-
constructor(group: string, semaphores: PseudoSemaphore<any>[], context: string, entry: EntryProvider<M>);
|
|
13
|
-
apply(compiler: Compiler): void;
|
|
14
|
-
protected attachStandardPhase(compilation: Compilation): void;
|
|
15
|
-
/**
|
|
16
|
-
* NOTE: This function returns an ITERATOR. Call .toArray() on it if you need to use the result multiple times
|
|
17
|
-
*/
|
|
18
|
-
getRelevantEntrypoints(compilation: Compilation): IteratorObject<{
|
|
19
|
-
entrypoint: Entrypoint;
|
|
20
|
-
srcPath: string;
|
|
21
|
-
metadata: M;
|
|
22
|
-
}, undefined, unknown>;
|
|
23
|
-
protected abstract processAssets(compilation: Compilation, parsedAssetJsonProvider: ParsedAssetJsonProvider): Promise<void> | void;
|
|
24
|
-
protected extractRelevantAssetData(compilation: Compilation, parsedAssetJsonProvider: ParsedAssetJsonProvider): ParsedAssetsJson;
|
|
25
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AbstractBiPhasicGroupAndEntryPlugin = void 0;
|
|
4
|
-
const shared_1 = require("../shared");
|
|
5
|
-
const AbstractBiPhasicGroupPlugin_1 = require("./AbstractBiPhasicGroupPlugin");
|
|
6
|
-
const webpack_1 = require("webpack");
|
|
7
|
-
class AbstractBiPhasicGroupAndEntryPlugin extends AbstractBiPhasicGroupPlugin_1.AbstractBiPhasicGroupPlugin {
|
|
8
|
-
context;
|
|
9
|
-
entry;
|
|
10
|
-
static configuredCompilations = new WeakSet();
|
|
11
|
-
entryMetadataRecord = {};
|
|
12
|
-
constructor(group, semaphores, context, entry) {
|
|
13
|
-
super(group, semaphores);
|
|
14
|
-
this.context = context;
|
|
15
|
-
this.entry = entry;
|
|
16
|
-
}
|
|
17
|
-
apply(compiler) {
|
|
18
|
-
super.apply(compiler);
|
|
19
|
-
compiler.hooks.compilation.tap(this.constructor.name, (compilation, { normalModuleFactory }) => {
|
|
20
|
-
if (!AbstractBiPhasicGroupAndEntryPlugin.configuredCompilations.has(compilation)) {
|
|
21
|
-
AbstractBiPhasicGroupAndEntryPlugin.configuredCompilations.add(compilation);
|
|
22
|
-
const dummyEntry = webpack_1.EntryPlugin.createDependency("", "");
|
|
23
|
-
compilation.dependencyFactories.set(dummyEntry.constructor, normalModuleFactory);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
compiler.hooks.make.tapPromise(this.constructor.name, async (compilation) => {
|
|
27
|
-
const entry = await this.entry();
|
|
28
|
-
const promises = [];
|
|
29
|
-
for (const [name, { plauditMetadata, ...desc }] of Object.entries(entry)) {
|
|
30
|
-
const options = webpack_1.EntryOptionPlugin.entryDescriptionToOptions(compiler, name, desc);
|
|
31
|
-
this.entryMetadataRecord[name] = plauditMetadata;
|
|
32
|
-
for (const entry of desc.import) {
|
|
33
|
-
promises.push(new Promise((resolve, reject) => {
|
|
34
|
-
compilation.addEntry(this.context, webpack_1.EntryPlugin.createDependency(entry, options), options, err => {
|
|
35
|
-
if (err) {
|
|
36
|
-
return reject(err);
|
|
37
|
-
}
|
|
38
|
-
resolve();
|
|
39
|
-
});
|
|
40
|
-
}));
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
await Promise.all(promises);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
attachStandardPhase(compilation) {
|
|
47
|
-
this.tapWithParsedAssetsJson(compilation, async (parsedAssetsJson) => {
|
|
48
|
-
await this.processAssets(compilation, parsedAssetsJson);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* NOTE: This function returns an ITERATOR. Call .toArray() on it if you need to use the result multiple times
|
|
53
|
-
*/
|
|
54
|
-
getRelevantEntrypoints(compilation) {
|
|
55
|
-
return compilation.entrypoints.values()
|
|
56
|
-
.map(entrypoint => {
|
|
57
|
-
const name = entrypoint.name;
|
|
58
|
-
if (!name) {
|
|
59
|
-
return undefined;
|
|
60
|
-
}
|
|
61
|
-
const metadata = this.entryMetadataRecord[name];
|
|
62
|
-
if (metadata === undefined) {
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
|
-
const srcPath = entrypoint.origins[0]?.request;
|
|
66
|
-
if (!srcPath) {
|
|
67
|
-
return undefined;
|
|
68
|
-
}
|
|
69
|
-
return { entrypoint, srcPath, metadata };
|
|
70
|
-
})
|
|
71
|
-
.filter(item => item !== undefined);
|
|
72
|
-
}
|
|
73
|
-
extractRelevantAssetData(compilation, parsedAssetJsonProvider) {
|
|
74
|
-
const relevantAssetData = {};
|
|
75
|
-
for (const { entrypoint, srcPath, metadata } of this.getRelevantEntrypoints(compilation)) {
|
|
76
|
-
const providedData = parsedAssetJsonProvider(entrypoint, metadata);
|
|
77
|
-
if (providedData === undefined) {
|
|
78
|
-
compilation.errors.push((0, shared_1.newWebpackErrorForFile)(`assets.json did not contain information for ${srcPath}`, srcPath));
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
relevantAssetData[providedData.assetName] = providedData.assetData;
|
|
82
|
-
}
|
|
83
|
-
return relevantAssetData;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
exports.AbstractBiPhasicGroupAndEntryPlugin = AbstractBiPhasicGroupAndEntryPlugin;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Compilation, Compiler, type WebpackPluginInstance } from "webpack";
|
|
2
|
-
import { PseudoSemaphore } from "../utils/pseudo-semaphore";
|
|
3
|
-
import { type ParsedAssetJsonProvider } from "../shared";
|
|
4
|
-
type TapWithAssetsJsonOptions = {
|
|
5
|
-
name?: string;
|
|
6
|
-
stage?: (typeof Compilation.PROCESS_ASSETS_STAGE_REPORT) | (typeof Compilation.PROCESS_ASSETS_STAGE_ANALYSE);
|
|
7
|
-
additionalAssets?: any;
|
|
8
|
-
};
|
|
9
|
-
type TapWithAssetsJsonFn = Parameters<Compilation['hooks']['processAssets']['tapPromise']>[1];
|
|
10
|
-
type TapWithParsedAssetsJsonFn = (parsedAssetJsonProvider: ParsedAssetJsonProvider, assets: Parameters<TapWithAssetsJsonFn>[0]) => Promise<void> | void;
|
|
11
|
-
export declare abstract class AbstractBiPhasicGroupPlugin implements WebpackPluginInstance {
|
|
12
|
-
readonly group: string;
|
|
13
|
-
private readonly semaphores;
|
|
14
|
-
protected static readonly uniquePhaseAttached: {
|
|
15
|
-
[key in string]: any;
|
|
16
|
-
};
|
|
17
|
-
protected readonly id: string;
|
|
18
|
-
constructor(group: string, semaphores: PseudoSemaphore<any>[]);
|
|
19
|
-
apply(compiler: Compiler): void;
|
|
20
|
-
protected resetSemaphores(): void;
|
|
21
|
-
protected rejectSemaphores(): void;
|
|
22
|
-
protected abstract attachStandardPhase(compilation: Compilation): void;
|
|
23
|
-
protected abstract attachUniquePhase(compilation: Compilation): void;
|
|
24
|
-
protected tapRequiringAssetsJson(compilation: Compilation, fnOrOptions: TapWithAssetsJsonFn): void;
|
|
25
|
-
protected tapRequiringAssetsJson(compilation: Compilation, fnOrOptions: TapWithAssetsJsonOptions, fnIfOptions: TapWithAssetsJsonFn): void;
|
|
26
|
-
protected tapWithParsedAssetsJson(compilation: Compilation, fnOrOptions: TapWithParsedAssetsJsonFn): void;
|
|
27
|
-
protected tapWithParsedAssetsJson(compilation: Compilation, fnOrOptions: TapWithAssetsJsonOptions, fnIfOptions: TapWithParsedAssetsJsonFn): void;
|
|
28
|
-
private sharedTapLogicForAssetsJsonHelpers;
|
|
29
|
-
private extractTapAndFunction;
|
|
30
|
-
}
|
|
31
|
-
export {};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AbstractBiPhasicGroupPlugin = void 0;
|
|
4
|
-
const webpack_1 = require("webpack");
|
|
5
|
-
const shared_1 = require("../shared");
|
|
6
|
-
class AbstractBiPhasicGroupPlugin {
|
|
7
|
-
group;
|
|
8
|
-
semaphores;
|
|
9
|
-
static uniquePhaseAttached = {};
|
|
10
|
-
id;
|
|
11
|
-
constructor(group, semaphores) {
|
|
12
|
-
this.group = group;
|
|
13
|
-
this.semaphores = semaphores;
|
|
14
|
-
this.id = Math.random().toString();
|
|
15
|
-
}
|
|
16
|
-
apply(compiler) {
|
|
17
|
-
webpack_1.library.EnableLibraryPlugin.setEnabled(compiler, this.group);
|
|
18
|
-
for (const semaphore of this.semaphores) {
|
|
19
|
-
semaphore.register(this.id);
|
|
20
|
-
}
|
|
21
|
-
compiler.hooks.compilation.tap(this.constructor.name, compilation => {
|
|
22
|
-
AbstractBiPhasicGroupPlugin.uniquePhaseAttached[this.group] = false;
|
|
23
|
-
this.resetSemaphores();
|
|
24
|
-
compilation.hooks.beforeChunkIds.tap(this.constructor.name, () => {
|
|
25
|
-
if (!AbstractBiPhasicGroupPlugin.uniquePhaseAttached[this.group]) {
|
|
26
|
-
AbstractBiPhasicGroupPlugin.uniquePhaseAttached[this.group] = this;
|
|
27
|
-
this.attachUniquePhase(compilation);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
this.attachStandardPhase(compilation);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
resetSemaphores() {
|
|
34
|
-
for (const semaphore of this.semaphores) {
|
|
35
|
-
semaphore.reset(this.id);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
rejectSemaphores() {
|
|
39
|
-
for (const semaphore of this.semaphores) {
|
|
40
|
-
semaphore.reject(this.id);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
tapRequiringAssetsJson(compilation, fnOrOptions, fnIfOptions) {
|
|
44
|
-
this.sharedTapLogicForAssetsJsonHelpers(compilation, this.extractTapAndFunction(fnOrOptions, fnIfOptions));
|
|
45
|
-
}
|
|
46
|
-
tapWithParsedAssetsJson(compilation, fnOrOptions, fnIfOptions) {
|
|
47
|
-
const { tap, earlyStage, fn } = this.extractTapAndFunction(fnOrOptions, fnIfOptions);
|
|
48
|
-
this.sharedTapLogicForAssetsJsonHelpers(compilation, { tap, earlyStage, fn: async (assets) => {
|
|
49
|
-
try {
|
|
50
|
-
await fn((entrypoint, dest) => (0, shared_1.getParsedAssetsJsonDataForEntrypoint)(compilation, entrypoint, dest), assets);
|
|
51
|
-
}
|
|
52
|
-
catch (e) {
|
|
53
|
-
console.error(e);
|
|
54
|
-
this.rejectSemaphores();
|
|
55
|
-
if (e instanceof Error) {
|
|
56
|
-
compilation.errors.push(e);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
throw e;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
} });
|
|
63
|
-
}
|
|
64
|
-
sharedTapLogicForAssetsJsonHelpers(compilation, { tap, earlyStage, fn }) {
|
|
65
|
-
compilation.hooks.processAssets.tapPromise({ ...tap, additionalAssets: true }, async (assets, ...args) => {
|
|
66
|
-
if (!earlyStage || "assets.json" in assets) {
|
|
67
|
-
await fn(assets, ...args);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
extractTapAndFunction(fnOrOptions, fnIfOptions) {
|
|
72
|
-
let tap = { name: this.constructor.name, stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_ANALYSE };
|
|
73
|
-
let fn;
|
|
74
|
-
if (typeof fnOrOptions === 'function') {
|
|
75
|
-
fn = fnOrOptions;
|
|
76
|
-
}
|
|
77
|
-
else if (!fnIfOptions) {
|
|
78
|
-
throw new Error("Somehow reached an impossible state. Make sure that you're using TypeScript.");
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
tap = { ...tap, ...fnOrOptions };
|
|
82
|
-
fn = fnIfOptions;
|
|
83
|
-
}
|
|
84
|
-
const earlyStage = tap.stage === webpack_1.Compilation.PROCESS_ASSETS_STAGE_ANALYSE;
|
|
85
|
-
if (earlyStage && tap.additionalAssets === undefined) {
|
|
86
|
-
tap.additionalAssets = true;
|
|
87
|
-
}
|
|
88
|
-
return { tap, earlyStage, fn };
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
exports.AbstractBiPhasicGroupPlugin = AbstractBiPhasicGroupPlugin;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { AbstractBiPhasicGroupPlugin } from "./AbstractBiPhasicGroupPlugin";
|
|
2
|
-
import type { AbstractBiPhasicGroupAndEntryPlugin } from "./AbstractBiPhasicGroupAndEntryPlugin";
|
|
3
|
-
import { Compilation } from "webpack";
|
|
4
|
-
export declare class AdditionalDependencyInjectorPlugin extends AbstractBiPhasicGroupPlugin {
|
|
5
|
-
private readonly processingModules;
|
|
6
|
-
private readonly addExternalizedDep;
|
|
7
|
-
private readonly referencePlugin;
|
|
8
|
-
constructor(processingModules: boolean | undefined, addExternalizedDep: (dep: string) => void, referencePlugin: AbstractBiPhasicGroupAndEntryPlugin<any>);
|
|
9
|
-
protected attachStandardPhase(compilation: Compilation): void;
|
|
10
|
-
protected attachUniquePhase(): void;
|
|
11
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.AdditionalDependencyInjectorPlugin = void 0;
|
|
7
|
-
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
8
|
-
const AbstractBiPhasicGroupPlugin_1 = require("./AbstractBiPhasicGroupPlugin");
|
|
9
|
-
const shared_1 = require("../shared");
|
|
10
|
-
const webpack_1 = require("webpack");
|
|
11
|
-
class AdditionalDependencyInjectorPlugin extends AbstractBiPhasicGroupPlugin_1.AbstractBiPhasicGroupPlugin {
|
|
12
|
-
processingModules;
|
|
13
|
-
addExternalizedDep;
|
|
14
|
-
referencePlugin;
|
|
15
|
-
constructor(processingModules, addExternalizedDep, referencePlugin) {
|
|
16
|
-
super("additional-dependency-injector-plugin", []);
|
|
17
|
-
this.processingModules = processingModules;
|
|
18
|
-
this.addExternalizedDep = addExternalizedDep;
|
|
19
|
-
this.referencePlugin = referencePlugin;
|
|
20
|
-
}
|
|
21
|
-
attachStandardPhase(compilation) {
|
|
22
|
-
const usableEntrypointTest = this.processingModules ? shared_1.scriptWithModuleExtension : shared_1.scriptWithoutModuleExtension;
|
|
23
|
-
compilation.hooks.processAssets.tapPromise({
|
|
24
|
-
name: `${this.constructor.name}_ProcessAssets_AddFakeModules`,
|
|
25
|
-
stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
|
|
26
|
-
}, async () => {
|
|
27
|
-
await Promise.all(this.referencePlugin.getRelevantEntrypoints(compilation)
|
|
28
|
-
.filter(re => usableEntrypointTest.test(re.srcPath))
|
|
29
|
-
.map(async ({ entrypoint, metadata, srcPath }) => {
|
|
30
|
-
const additionalDependencies = [...metadata.dest.additionalDependencies];
|
|
31
|
-
const firstLine = (await promises_1.default.readFile(srcPath, 'utf-8')).trim().split(/\r?\n/)[0];
|
|
32
|
-
if (firstLine?.startsWith("//ADDITIONAL_DEPENDENCIES:")) {
|
|
33
|
-
additionalDependencies.push(...firstLine.substring(26).trim().split(',').map(dep => dep.trim()));
|
|
34
|
-
}
|
|
35
|
-
const chunk = entrypoint.getEntrypointChunk();
|
|
36
|
-
for (const additionalDep of additionalDependencies) {
|
|
37
|
-
this.addExternalizedDep(additionalDep);
|
|
38
|
-
compilation.chunkGraph.connectChunkAndModule(chunk, new webpack_1.ExternalModule("__REMOVE_ME__", "var", additionalDep));
|
|
39
|
-
}
|
|
40
|
-
}));
|
|
41
|
-
});
|
|
42
|
-
compilation.hooks.processAssets.tap({
|
|
43
|
-
name: `${this.constructor.name}_ProcessAssets_RemoveFakeModules`,
|
|
44
|
-
stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_REPORT
|
|
45
|
-
}, () => {
|
|
46
|
-
for (const { entrypoint } of this.referencePlugin.getRelevantEntrypoints(compilation)) {
|
|
47
|
-
const entrypointChunk = entrypoint.getEntrypointChunk();
|
|
48
|
-
for (const module of compilation.chunkGraph.getChunkModules(entrypointChunk)) {
|
|
49
|
-
if (module instanceof webpack_1.ExternalModule && module.request === '__REMOVE_ME__') {
|
|
50
|
-
compilation.chunkGraph.disconnectChunkAndModule(entrypointChunk, module);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
attachUniquePhase() { }
|
|
57
|
-
}
|
|
58
|
-
exports.AdditionalDependencyInjectorPlugin = AdditionalDependencyInjectorPlugin;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Compilation } from "webpack";
|
|
2
|
-
import type WebpackRemoveEmptyScriptsPlugin from "webpack-remove-empty-scripts";
|
|
3
|
-
import { AbstractBiPhasicGroupAndEntryPlugin, EntryProvider } from "./AbstractBiPhasicGroupAndEntryPlugin";
|
|
4
|
-
import { AssetMetaSegment, BlockEntrypointInfo, FileSegmentBlockEntrypointInfo, ParsedAssetJsonProvider, ParsedAssetsJson, ScriptArgsObject, VerifiedAdvancedOutputConfig, VerifiedPlauditWordpressWebpackConfig } from "../shared";
|
|
5
|
-
type WorkableBlockEntrypointInfo = Omit<FileSegmentBlockEntrypointInfo, 'originalValue' | 'pathQueryParameters'> & Partial<Pick<FileSegmentBlockEntrypointInfo, 'originalValue'>> & {
|
|
6
|
-
outputPath: string;
|
|
7
|
-
assetData: ParsedAssetsJson[string];
|
|
8
|
-
hash: string;
|
|
9
|
-
scriptArgsObject: ScriptArgsObject | undefined;
|
|
10
|
-
} & (AssetMetaSegment | {
|
|
11
|
-
inlinedAsset?: undefined;
|
|
12
|
-
assetContents?: string;
|
|
13
|
-
});
|
|
14
|
-
type CollatedWorkableBlockInfo = Record<string, {
|
|
15
|
-
sourcePath?: string;
|
|
16
|
-
workableBlockEntrypointsInfo: WorkableBlockEntrypointInfo[];
|
|
17
|
-
blockJsonText?: string;
|
|
18
|
-
}>;
|
|
19
|
-
export declare class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin<BlockEntrypointInfo> {
|
|
20
|
-
private readonly config;
|
|
21
|
-
private readonly dest;
|
|
22
|
-
private readonly webpackRemoveEmptyScriptsPlugin;
|
|
23
|
-
private static readonly semaphore;
|
|
24
|
-
constructor(config: VerifiedPlauditWordpressWebpackConfig, dest: VerifiedAdvancedOutputConfig, webpackRemoveEmptyScriptsPlugin: WebpackRemoveEmptyScriptsPlugin, context: string, entry: EntryProvider<BlockEntrypointInfo>);
|
|
25
|
-
protected processAssets(compilation: Compilation, parsedAssetJsonProvider: ParsedAssetJsonProvider): Promise<void>;
|
|
26
|
-
private emitBlockLoaderFile;
|
|
27
|
-
private static readonly THEME_JSON_FLAG_PROPS;
|
|
28
|
-
private static pickOutFlagPropsFromBlockSupports;
|
|
29
|
-
private callRegisterFunction;
|
|
30
|
-
private transformBlocks;
|
|
31
|
-
private static extractAssetSource;
|
|
32
|
-
private static convertToScriptHandles;
|
|
33
|
-
private static doFileOrHandleReplacements;
|
|
34
|
-
private stripOffBlocksDestPrefix;
|
|
35
|
-
private static hashThingForAsset;
|
|
36
|
-
private static stripFilePrefix;
|
|
37
|
-
static findCommonAncestor(...paths: string[]): string[];
|
|
38
|
-
static findRelativeRouteBetween(path1: string, path2: string): string;
|
|
39
|
-
private static remapReferencedPHPFilesOnKey;
|
|
40
|
-
private static normalizeRenderTemplate;
|
|
41
|
-
private static readonly knownExperimentalProperties;
|
|
42
|
-
private static handleExperimentalBlockSupportsFlags;
|
|
43
|
-
protected attachUniquePhase(compilation: Compilation): void;
|
|
44
|
-
protected attachStandardPhase(compilation: Compilation): void;
|
|
45
|
-
protected deduplicateEntrypointHandles(workableBlockInfo: CollatedWorkableBlockInfo): CollatedWorkableBlockInfo;
|
|
46
|
-
}
|
|
47
|
-
export {};
|