@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
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Compilation } from "webpack";
|
|
2
|
-
import { AbstractBiPhasicGroupAndEntryPlugin, EntryProvider } from "./AbstractBiPhasicGroupAndEntryPlugin";
|
|
3
|
-
import type { ParsedAssetJsonProvider } from "../shared";
|
|
4
|
-
export declare class EnhancedDynamicEntryPlugin extends AbstractBiPhasicGroupAndEntryPlugin {
|
|
5
|
-
constructor(context: string, entry: EntryProvider);
|
|
6
|
-
protected attachUniquePhase(): void;
|
|
7
|
-
protected processAssets(compilation: Compilation, parsedAssetJsonProvider: ParsedAssetJsonProvider): void;
|
|
8
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EnhancedDynamicEntryPlugin = void 0;
|
|
4
|
-
const AbstractBiPhasicGroupAndEntryPlugin_1 = require("./AbstractBiPhasicGroupAndEntryPlugin");
|
|
5
|
-
class EnhancedDynamicEntryPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.AbstractBiPhasicGroupAndEntryPlugin {
|
|
6
|
-
constructor(context, entry) {
|
|
7
|
-
super(`enhanced-dynamic-entries`, [], context, entry);
|
|
8
|
-
}
|
|
9
|
-
attachUniquePhase() { }
|
|
10
|
-
processAssets(compilation, parsedAssetJsonProvider) {
|
|
11
|
-
this.extractRelevantAssetData(compilation, parsedAssetJsonProvider);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.EnhancedDynamicEntryPlugin = EnhancedDynamicEntryPlugin;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { AbstractBiPhasicGroupAndEntryPlugin, EntryProvider } from "./AbstractBiPhasicGroupAndEntryPlugin";
|
|
2
|
-
import { MinimumViableMetadata, ParsedAssetJsonProvider, VerifiedAdvancedOutputConfig, VerifiedPlauditWordpressWebpackConfig } from "../shared";
|
|
3
|
-
import { Compilation, type Compiler } from "webpack";
|
|
4
|
-
export type ExtensionConfigFileGeneratorMetadata = MinimumViableMetadata & {
|
|
5
|
-
extensionId: string;
|
|
6
|
-
};
|
|
7
|
-
export declare class ExtensionsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAndEntryPlugin<ExtensionConfigFileGeneratorMetadata> {
|
|
8
|
-
private readonly config;
|
|
9
|
-
private readonly extensionsSrcPath;
|
|
10
|
-
private readonly dest;
|
|
11
|
-
private static readonly semaphore;
|
|
12
|
-
private setupFiles;
|
|
13
|
-
constructor(config: VerifiedPlauditWordpressWebpackConfig, extensionsSrcPath: string, dest: VerifiedAdvancedOutputConfig, context: string, entry: EntryProvider<ExtensionConfigFileGeneratorMetadata>);
|
|
14
|
-
get extensionsDestPath(): string;
|
|
15
|
-
apply(compiler: Compiler): void;
|
|
16
|
-
private walkSubtreeForMetaInfo;
|
|
17
|
-
private generateVersionThreeConfigFile;
|
|
18
|
-
protected attachUniquePhase(compilation: Compilation): void;
|
|
19
|
-
protected processAssets(compilation: Compilation, parsedAssetJsonProvider: ParsedAssetJsonProvider): void;
|
|
20
|
-
}
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExtensionsConfigFileGeneratorPlugin = void 0;
|
|
4
|
-
const promises_1 = require("node:fs/promises");
|
|
5
|
-
const node_path_1 = require("node:path");
|
|
6
|
-
const php_writer_1 = require("@plaudit/php-writer");
|
|
7
|
-
const expressions_1 = require("@plaudit/php-writer/expressions");
|
|
8
|
-
const AbstractBiPhasicGroupAndEntryPlugin_1 = require("./AbstractBiPhasicGroupAndEntryPlugin");
|
|
9
|
-
const UnifiedLoaderGenerator_1 = require("./UnifiedLoaderGenerator");
|
|
10
|
-
const shared_1 = require("../shared");
|
|
11
|
-
const pseudo_semaphore_1 = require("../utils/pseudo-semaphore");
|
|
12
|
-
const webpack_1 = require("webpack");
|
|
13
|
-
class ExtensionsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.AbstractBiPhasicGroupAndEntryPlugin {
|
|
14
|
-
config;
|
|
15
|
-
extensionsSrcPath;
|
|
16
|
-
dest;
|
|
17
|
-
static semaphore = new pseudo_semaphore_1.PseudoSemaphore("Extensions");
|
|
18
|
-
setupFiles = [];
|
|
19
|
-
constructor(config, extensionsSrcPath, dest, context, entry) {
|
|
20
|
-
super(`extensions-v2-${dest.destination}`, [ExtensionsConfigFileGeneratorPlugin.semaphore, UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore], context, entry);
|
|
21
|
-
this.config = config;
|
|
22
|
-
this.extensionsSrcPath = extensionsSrcPath;
|
|
23
|
-
this.dest = dest;
|
|
24
|
-
}
|
|
25
|
-
get extensionsDestPath() {
|
|
26
|
-
let extensionsDestPath = this.dest.destination.endsWith("/") ? this.dest.destination : this.dest.destination + "/";
|
|
27
|
-
return !extensionsDestPath.startsWith("/") ? "/" + extensionsDestPath : extensionsDestPath;
|
|
28
|
-
}
|
|
29
|
-
apply(compiler) {
|
|
30
|
-
super.apply(compiler);
|
|
31
|
-
compiler.hooks.make.tapPromise(this.constructor.name, async (compilation) => {
|
|
32
|
-
if (!compilation.contextDependencies.has(this.extensionsSrcPath)) {
|
|
33
|
-
compilation.contextDependencies.add(this.extensionsSrcPath);
|
|
34
|
-
}
|
|
35
|
-
const emissionPromises = [];
|
|
36
|
-
for await (const { name: setupFilePath } of await (0, promises_1.opendir)(this.extensionsSrcPath, { encoding: 'utf-8' })) {
|
|
37
|
-
if (setupFilePath.endsWith("-setup.php")) {
|
|
38
|
-
const setupFileSourcePath = (0, node_path_1.join)(this.extensionsSrcPath, setupFilePath);
|
|
39
|
-
compilation.fileDependencies.add(setupFileSourcePath);
|
|
40
|
-
emissionPromises.push((0, promises_1.readFile)(setupFileSourcePath).then(contents => {
|
|
41
|
-
compilation.emitAsset((0, node_path_1.join)(this.dest.destination, setupFilePath), new webpack_1.sources.RawSource(contents), { size: Buffer.byteLength(contents) });
|
|
42
|
-
const blockSlug = /^(.+?)-setup.php$/i.exec(setupFilePath)?.[1];
|
|
43
|
-
return [blockSlug, setupFilePath];
|
|
44
|
-
}));
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
await this.walkSubtreeForMetaInfo(compilation, this.extensionsSrcPath, this.dest, [], emissionPromises);
|
|
48
|
-
this.setupFiles = (await Promise.all(emissionPromises))
|
|
49
|
-
.filter((item) => item[0] !== undefined).sort((a, b) => a[0].localeCompare(b[0]));
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
async walkSubtreeForMetaInfo(compilation, srcRoot, dest, parents, emissionPromises) {
|
|
53
|
-
if (!compilation.contextDependencies.has(srcRoot)) {
|
|
54
|
-
compilation.contextDependencies.add(srcRoot);
|
|
55
|
-
}
|
|
56
|
-
for await (const dirent of await (0, promises_1.opendir)(srcRoot)) {
|
|
57
|
-
if ((0, shared_1.shouldBeSkipped)(dirent.name)) {
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
if (dirent.isFile()) {
|
|
61
|
-
if (dirent.name === "setup.php") {
|
|
62
|
-
const setupFilePath = (0, node_path_1.join)(...parents, dirent.name);
|
|
63
|
-
const setupFileSourcePath = (0, node_path_1.join)(this.extensionsSrcPath, setupFilePath);
|
|
64
|
-
compilation.fileDependencies.add(setupFileSourcePath);
|
|
65
|
-
emissionPromises.push((0, promises_1.readFile)(setupFileSourcePath).then(contents => {
|
|
66
|
-
compilation.emitAsset((0, node_path_1.join)(this.dest.destination, setupFilePath), new webpack_1.sources.RawSource(contents), { size: Buffer.byteLength(contents) });
|
|
67
|
-
return [parents.join("-") /* blockSlug */, setupFilePath];
|
|
68
|
-
}));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
else if (dirent.isDirectory()) {
|
|
72
|
-
await this.walkSubtreeForMetaInfo(compilation, (0, node_path_1.join)(srcRoot, dirent.name), dest, [...parents, dirent.name], emissionPromises);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
generateVersionThreeConfigFile(compilation, relevantAssetData, setupFilePaths) {
|
|
77
|
-
const handlePrefix = `${this.config.targetHandlePrefix}_block-extensions`;
|
|
78
|
-
const regex = /^(.+?)-((?:editor-|view-|)(?:style|script|script-module))$/i;
|
|
79
|
-
const blockExtensionsConfig = {
|
|
80
|
-
metadata: { version: this.config.extensionsVersion }, scriptHandles: {}, scriptModuleHandles: {}, styleHandles: {}, blocks: {}, setupFiles: {}
|
|
81
|
-
};
|
|
82
|
-
const normalizedAssetData = Object.entries(relevantAssetData)
|
|
83
|
-
.map(entry => {
|
|
84
|
-
const assetPath = this.dest.destination && entry[0].startsWith(this.dest.destination + "/")
|
|
85
|
-
? entry[0].substring(this.dest.destination.length + 1) : entry[0];
|
|
86
|
-
return [assetPath, entry[1]];
|
|
87
|
-
});
|
|
88
|
-
for (const [assetPath, assetData] of normalizedAssetData) {
|
|
89
|
-
const match = regex.exec(assetData.extensionId);
|
|
90
|
-
if (!match) {
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
const blockSlug = match[1], assetType = match[2];
|
|
94
|
-
if (blockSlug && assetType) {
|
|
95
|
-
const key = assetType.replace(/-[sm]/gi, chars => chars.substring(1).toUpperCase());
|
|
96
|
-
//TODO: Handle deduplicating handles in the same way that PlainEntrypointsStyleBlockJSONPlugin does
|
|
97
|
-
const handle = `${handlePrefix}_${blockSlug}-${assetType}`;
|
|
98
|
-
const isCss = (0, shared_1.isStyleField)(assetType);
|
|
99
|
-
const handleGroup = isCss ? 'styleHandles'
|
|
100
|
-
: ((0, shared_1.isScriptModuleField)(assetType) ? 'scriptModuleHandles' : 'scriptHandles');
|
|
101
|
-
const { dependencies, module_dependencies } = assetData;
|
|
102
|
-
blockExtensionsConfig[handleGroup][handle] = {
|
|
103
|
-
src: isCss ? assetPath.replace(/\.js$/, ".css") : assetPath,
|
|
104
|
-
rest: isCss || key.startsWith("editor")
|
|
105
|
-
? (module_dependencies?.length ? [dependencies, assetData.version, { in_footer: true, module_dependencies }] : [dependencies, assetData.version])
|
|
106
|
-
: [dependencies, assetData.version, module_dependencies?.length ? { strategy: 'defer', module_dependencies } : { strategy: 'defer' }]
|
|
107
|
-
};
|
|
108
|
-
(blockExtensionsConfig.blocks[blockSlug] ?? (blockExtensionsConfig.blocks[blockSlug] = {}))[key] = handle;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
for (const [blockSlug, asset] of setupFilePaths) {
|
|
112
|
-
blockExtensionsConfig.setupFiles[blockSlug] = asset;
|
|
113
|
-
}
|
|
114
|
-
blockExtensionsConfig.scriptHandles = Object.fromEntries(Object.entries(blockExtensionsConfig.scriptHandles)
|
|
115
|
-
.toSorted(([a], [b]) => a.localeCompare(b)));
|
|
116
|
-
blockExtensionsConfig.scriptModuleHandles = Object.fromEntries(Object.entries(blockExtensionsConfig.scriptModuleHandles)
|
|
117
|
-
.toSorted(([a], [b]) => a.localeCompare(b)));
|
|
118
|
-
blockExtensionsConfig.styleHandles = Object.fromEntries(Object.entries(blockExtensionsConfig.styleHandles)
|
|
119
|
-
.toSorted(([a], [b]) => a.localeCompare(b)));
|
|
120
|
-
blockExtensionsConfig.setupFiles = Object.fromEntries(Object.entries(blockExtensionsConfig.setupFiles)
|
|
121
|
-
.toSorted(([a], [b]) => a.localeCompare(b)));
|
|
122
|
-
blockExtensionsConfig.blocks = Object.fromEntries(Object.entries(blockExtensionsConfig.blocks)
|
|
123
|
-
.map(block => {
|
|
124
|
-
return [block[0], Object.fromEntries(Object.entries(block[1]).toSorted(([a], [b]) => a.localeCompare(b)))];
|
|
125
|
-
})
|
|
126
|
-
.toSorted(([a], [b]) => a.localeCompare(b)));
|
|
127
|
-
(0, shared_1.emitPHPWriterAsAsset)(new php_writer_1.PHPWriter()
|
|
128
|
-
.call("Plaudit\\Common\\Lib\\GutenbergUtils::loadExtensionsV3", [new expressions_1.EnclosedLiteral((0, shared_1.makeEmittableConfigPHP)(blockExtensionsConfig, false)), expressions_1.Op.concat(expressions_1.Constants.__DIR__, '/'),
|
|
129
|
-
expressions_1.Expr.call("plaudit_webpack_extensions__resolve_base_uri", [expressions_1.Constants.__DIR__])]), compilation, (0, node_path_1.join)(this.dest.destination, "extensions-loader.php"));
|
|
130
|
-
}
|
|
131
|
-
attachUniquePhase(compilation) {
|
|
132
|
-
compilation.hooks.processAssets.tapPromise({ name: this.constructor.name, stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_REPORT }, async () => {
|
|
133
|
-
const plugins = Object.values((await ExtensionsConfigFileGeneratorPlugin.semaphore.wait())
|
|
134
|
-
.reduce((acc, cur) => {
|
|
135
|
-
const accValue = acc[cur.plugin.group];
|
|
136
|
-
if (accValue === undefined) {
|
|
137
|
-
acc[cur.plugin.group] = { ...cur, setupFiles: cur.setupFiles?.length ? [...cur.setupFiles] : [] };
|
|
138
|
-
return acc;
|
|
139
|
-
}
|
|
140
|
-
if (cur.relevantAssetData) {
|
|
141
|
-
accValue.relevantAssetData = { ...accValue.relevantAssetData, ...cur.relevantAssetData };
|
|
142
|
-
}
|
|
143
|
-
if (cur.setupFiles?.length) {
|
|
144
|
-
accValue.setupFiles.push(...cur.setupFiles);
|
|
145
|
-
}
|
|
146
|
-
return acc;
|
|
147
|
-
}, {}))
|
|
148
|
-
.sort((a, b) => a.plugin.group.localeCompare(b.plugin.group));
|
|
149
|
-
for (const { plugin, relevantAssetData, setupFiles } of plugins) {
|
|
150
|
-
plugin.generateVersionThreeConfigFile(compilation, relevantAssetData, setupFiles);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
processAssets(compilation, parsedAssetJsonProvider) {
|
|
155
|
-
const relevantAssetData = Object.fromEntries(this.getRelevantEntrypoints(compilation)
|
|
156
|
-
.map(({ entrypoint, metadata, srcPath }) => {
|
|
157
|
-
const providedData = parsedAssetJsonProvider(entrypoint, metadata);
|
|
158
|
-
if (providedData === undefined) {
|
|
159
|
-
compilation.errors.push((0, shared_1.newWebpackErrorForFile)(`assets.json did not contain information for ${srcPath}`, srcPath));
|
|
160
|
-
return undefined;
|
|
161
|
-
}
|
|
162
|
-
return [providedData.assetName, { ...providedData.assetData, extensionId: metadata.extensionId }];
|
|
163
|
-
})
|
|
164
|
-
.filter(item => item !== undefined));
|
|
165
|
-
const staticallyLoadedEntrypoints = Object.keys(relevantAssetData);
|
|
166
|
-
const generateLoader = (writer) => {
|
|
167
|
-
writer.require(this.extensionsDestPath + "extensions-loader.php", { dirRelative: true, once: true });
|
|
168
|
-
};
|
|
169
|
-
let action;
|
|
170
|
-
const lazyLoader = this.dest.lazyLoader;
|
|
171
|
-
if (lazyLoader) {
|
|
172
|
-
try {
|
|
173
|
-
action = writer => writer.function(new expressions_1.NamespacedReference(this.config.targetNamespace, lazyLoader, 'function'), [], generateLoader, { returnType: 'void' });
|
|
174
|
-
}
|
|
175
|
-
catch (e) {
|
|
176
|
-
compilation.errors.push((0, shared_1.newWebpackErrorForFile)(["An error occurred while emitting a function for lazily loading extensions", { cause: e }], this.extensionsSrcPath));
|
|
177
|
-
this.rejectSemaphores();
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
action = writer => writer.withScope(generateLoader);
|
|
183
|
-
}
|
|
184
|
-
const myCacheData = { plugin: this, setupFiles: this.setupFiles, relevantAssetData };
|
|
185
|
-
ExtensionsConfigFileGeneratorPlugin.semaphore.resolve(this.id, myCacheData);
|
|
186
|
-
UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.resolve(this.id, this.setupFiles.length > 0 || staticallyLoadedEntrypoints.length > 0
|
|
187
|
-
? { group: this.group, requiresBaseURI: true, action, staticallyLoadedEntrypoints }
|
|
188
|
-
: undefined);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
exports.ExtensionsConfigFileGeneratorPlugin = ExtensionsConfigFileGeneratorPlugin;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AbstractBiPhasicGroupAndEntryPlugin, EntryProvider } from "./AbstractBiPhasicGroupAndEntryPlugin";
|
|
2
|
-
import type { ParsedAssetJsonProvider } from "../shared";
|
|
3
|
-
import { Compilation } from "webpack";
|
|
4
|
-
export declare class ExtensionsConfigFileGeneratorPluginV1 extends AbstractBiPhasicGroupAndEntryPlugin {
|
|
5
|
-
private readonly extensionsDest;
|
|
6
|
-
constructor(extensionsDest: string, context: string, entry: EntryProvider);
|
|
7
|
-
protected attachUniquePhase(): void;
|
|
8
|
-
protected processAssets(compilation: Compilation, parsedAssetJsonProvider: ParsedAssetJsonProvider): void;
|
|
9
|
-
}
|
|
@@ -1,45 +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.ExtensionsConfigFileGeneratorPluginV1 = void 0;
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
-
const php_writer_1 = require("@plaudit/php-writer");
|
|
9
|
-
const expressions_1 = require("@plaudit/php-writer/expressions");
|
|
10
|
-
const AbstractBiPhasicGroupAndEntryPlugin_1 = require("./AbstractBiPhasicGroupAndEntryPlugin");
|
|
11
|
-
const UnifiedLoaderGenerator_1 = require("./UnifiedLoaderGenerator");
|
|
12
|
-
const webpack_1 = require("webpack");
|
|
13
|
-
class ExtensionsConfigFileGeneratorPluginV1 extends AbstractBiPhasicGroupAndEntryPlugin_1.AbstractBiPhasicGroupAndEntryPlugin {
|
|
14
|
-
extensionsDest;
|
|
15
|
-
constructor(extensionsDest, context, entry) {
|
|
16
|
-
super(`extensions-v1-${extensionsDest}`, [UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore], context, entry);
|
|
17
|
-
this.extensionsDest = extensionsDest;
|
|
18
|
-
}
|
|
19
|
-
attachUniquePhase() { }
|
|
20
|
-
processAssets(compilation, parsedAssetJsonProvider) {
|
|
21
|
-
const regex = /^(.+?)-((?<prefix>editor-|view-|)(?<type>style|script|script-module))\.(?<extension>css|m?js)$/i;
|
|
22
|
-
const mapping = {};
|
|
23
|
-
const prefix = this.extensionsDest + node_path_1.default.sep;
|
|
24
|
-
for (let fileWithAssetData of Object.keys(this.extractRelevantAssetData(compilation, parsedAssetJsonProvider))) {
|
|
25
|
-
let match;
|
|
26
|
-
if (fileWithAssetData.startsWith(prefix)) {
|
|
27
|
-
fileWithAssetData = fileWithAssetData.substring(prefix.length);
|
|
28
|
-
}
|
|
29
|
-
if ((match = regex.exec(fileWithAssetData)) && match[1] && match[2]) {
|
|
30
|
-
if (match.groups?.['type'] === 'style' && match.groups['extension'] !== 'css') {
|
|
31
|
-
fileWithAssetData = fileWithAssetData.replace(/\.m?js$/i, ".css");
|
|
32
|
-
}
|
|
33
|
-
const resourceInfo = (mapping[match[1]] ?? (mapping[match[1]] = [{}]))[0];
|
|
34
|
-
const key = match[2].replace(/-[sm]/gi, chars => chars.substring(1).toUpperCase());
|
|
35
|
-
(resourceInfo[key] ?? (resourceInfo[key] = [])).push([`plaudit_block-extension_${match[1]}-${match[2]}`, fileWithAssetData]);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
compilation.emitAsset(node_path_1.default.join(this.extensionsDest, "mapping.config"), new webpack_1.sources.RawSource((0, php_writer_1.phpSerialize)(mapping)));
|
|
39
|
-
UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.resolve(this.id, { group: `extensions-config-v1-${this.extensionsDest}`, requiresBaseURI: false, action: file => {
|
|
40
|
-
file
|
|
41
|
-
.call("Plaudit\\Common\\Lib\\GutenbergUtils::installExtensionsSupport", [expressions_1.Op.concat(expressions_1.Constants.__DIR__, this.extensionsDest)]);
|
|
42
|
-
} });
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.ExtensionsConfigFileGeneratorPluginV1 = ExtensionsConfigFileGeneratorPluginV1;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MiniCSSExtractPluginErrorCleaner = void 0;
|
|
4
|
-
class MiniCSSExtractPluginErrorCleaner {
|
|
5
|
-
apply(compiler) {
|
|
6
|
-
compiler.hooks.done.tap("CleanupMiniCssExtractPlugin", stats => {
|
|
7
|
-
if (stats.hasErrors()) {
|
|
8
|
-
if (!stats.compilation.errors.every(error => error.message.includes("mini-css-extract-plugin")) && stats.compilation.errors.length % 2 === 0) {
|
|
9
|
-
stats.compilation.errors = stats.compilation.errors.filter(error => !error.message.includes("mini-css-extract-plugin"));
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.MiniCSSExtractPluginErrorCleaner = MiniCSSExtractPluginErrorCleaner;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { AbstractBiPhasicGroupPlugin } from "./AbstractBiPhasicGroupPlugin";
|
|
2
|
-
import { Compilation } from "webpack";
|
|
3
|
-
export declare class MixableBiPhasicGroupAndEntryPlugin extends AbstractBiPhasicGroupPlugin {
|
|
4
|
-
protected attachStandardPhase(compilation: Compilation): void;
|
|
5
|
-
protected attachUniquePhase(compilation: Compilation): void;
|
|
6
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MixableBiPhasicGroupAndEntryPlugin = void 0;
|
|
4
|
-
const AbstractBiPhasicGroupPlugin_1 = require("./AbstractBiPhasicGroupPlugin");
|
|
5
|
-
class MixableBiPhasicGroupAndEntryPlugin extends AbstractBiPhasicGroupPlugin_1.AbstractBiPhasicGroupPlugin {
|
|
6
|
-
attachStandardPhase(compilation) {
|
|
7
|
-
throw new Error("This must be implemented");
|
|
8
|
-
}
|
|
9
|
-
attachUniquePhase(compilation) {
|
|
10
|
-
throw new Error("This must be implemented");
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.MixableBiPhasicGroupAndEntryPlugin = MixableBiPhasicGroupAndEntryPlugin;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { AbstractBiPhasicGroupPlugin } from "./AbstractBiPhasicGroupPlugin";
|
|
2
|
-
import { Compilation } from "webpack";
|
|
3
|
-
export declare class MixableBiPhasicGroupPlugin extends AbstractBiPhasicGroupPlugin {
|
|
4
|
-
protected attachStandardPhase(compilation: Compilation): void;
|
|
5
|
-
protected attachUniquePhase(compilation: Compilation): void;
|
|
6
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MixableBiPhasicGroupPlugin = void 0;
|
|
4
|
-
const AbstractBiPhasicGroupPlugin_1 = require("./AbstractBiPhasicGroupPlugin");
|
|
5
|
-
class MixableBiPhasicGroupPlugin extends AbstractBiPhasicGroupPlugin_1.AbstractBiPhasicGroupPlugin {
|
|
6
|
-
attachStandardPhase(compilation) {
|
|
7
|
-
throw new Error("This must be implemented");
|
|
8
|
-
}
|
|
9
|
-
attachUniquePhase(compilation) {
|
|
10
|
-
throw new Error("This must be implemented");
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.MixableBiPhasicGroupPlugin = MixableBiPhasicGroupPlugin;
|
|
@@ -1,30 +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.PackageConfigSanityChecker = void 0;
|
|
7
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
class PackageConfigSanityChecker {
|
|
10
|
-
apply(compiler) {
|
|
11
|
-
compiler.hooks.thisCompilation.tap(this.constructor.name, compilation => {
|
|
12
|
-
const configs = [["postcss.config.js", true], ["babel-transform.js", false],
|
|
13
|
-
...["babel.config", ".babelrc"].flatMap(prefix => [`${prefix}.json`, `${prefix}.js`]).map((filename) => [filename, false])];
|
|
14
|
-
for (const [filename, blockable] of configs) {
|
|
15
|
-
const invalidFilePath = node_path_1.default.join(process.cwd(), filename);
|
|
16
|
-
if (node_fs_1.default.existsSync(invalidFilePath)) {
|
|
17
|
-
if (blockable) {
|
|
18
|
-
compilation.warnings.push(new Error(`The current project has a ${filename} file in its theme directory.`
|
|
19
|
-
+ ` It will be ignored, but SHOULD be deleted before continuing.\nTo fix it, run: rm ${invalidFilePath}`));
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
compilation.errors.push(new Error(`The current project has a ${filename} file in its theme directory.`
|
|
23
|
-
+ ` It WILL cause issues and MUST be deleted before continuing.\nTo fix it, run: rm ${invalidFilePath}`));
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.PackageConfigSanityChecker = PackageConfigSanityChecker;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { BlockEntrypointInfo, ParsedAssetJsonProvider, VerifiedAdvancedOutputConfig, VerifiedPlauditWordpressWebpackConfig } from "../shared";
|
|
2
|
-
import { AbstractBiPhasicGroupAndEntryPlugin, EntryProvider } from "./AbstractBiPhasicGroupAndEntryPlugin";
|
|
3
|
-
import { Compilation } from "webpack";
|
|
4
|
-
export declare class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAndEntryPlugin<BlockEntrypointInfo> {
|
|
5
|
-
private readonly config;
|
|
6
|
-
private readonly buildRoot;
|
|
7
|
-
private readonly outputDir;
|
|
8
|
-
private readonly dest;
|
|
9
|
-
private readonly useUnifiedLoader;
|
|
10
|
-
private static readonly semaphore;
|
|
11
|
-
constructor(config: VerifiedPlauditWordpressWebpackConfig, buildRoot: string, outputDir: string, dest: VerifiedAdvancedOutputConfig, useUnifiedLoader: boolean, context: string, entry: EntryProvider<BlockEntrypointInfo>);
|
|
12
|
-
private generatePlainEntrypointsLoader;
|
|
13
|
-
private static writeHandleItem;
|
|
14
|
-
private static collatePotentiallyMergeableAssets;
|
|
15
|
-
private static addHandlesToHandleLists;
|
|
16
|
-
private static appendEnqueuingHandleLists;
|
|
17
|
-
private static separateHandleListByPriority;
|
|
18
|
-
/**
|
|
19
|
-
* This is used to allow scripts and styles to be grouped based on hook_name for the admin handle
|
|
20
|
-
* @param handleItems
|
|
21
|
-
* @private
|
|
22
|
-
*/
|
|
23
|
-
private static separateHandleListByHookName;
|
|
24
|
-
protected attachUniquePhase(compilation: Compilation): void;
|
|
25
|
-
protected processAssets(compilation: Compilation, parsedAssetJsonProvider: ParsedAssetJsonProvider): void;
|
|
26
|
-
}
|