@plaudit/webpack-extensions 2.68.0 → 2.69.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/AbstractBiPhasicGroupAndEntryPlugin.d.ts +2 -2
- package/build/plugins/AbstractBiPhasicGroupPlugin.d.ts +2 -3
- package/build/plugins/AbstractBiPhasicGroupPlugin.js +1 -1
- package/build/plugins/AdditionalDependencyInjectorPlugin.d.ts +1 -1
- package/build/plugins/EnhancedDynamicEntryPlugin.d.ts +1 -1
- package/build/plugins/ExtensionsConfigFileGeneratorPlugin.d.ts +1 -2
- package/build/plugins/ExtensionsConfigFileGeneratorPlugin.js +1 -1
- package/build/plugins/ExtensionsConfigFileGeneratorPluginV1.d.ts +1 -2
- package/build/plugins/PlainEntrypointsConfigFileGeneratorPlugin.d.ts +1 -2
- package/build/plugins/PlainEntrypointsConfigFileGeneratorPlugin.js +5 -14
- package/build/plugins/PlainEntrypointsStyleBlockJSONPlugin.d.ts +1 -2
- package/build/plugins/SpecialAssetHandlingPlugin.d.ts +1 -1
- package/build/plugins/UnifiedLoaderGenerator.d.ts +1 -1
- package/build/plugins/VariablesJSMonitorPlugin.d.ts +1 -1
- package/build/shared.d.ts +48 -5
- package/build/shared.js +14 -2
- package/build/utils/common-config-helpers.d.ts +1 -5
- package/build/wordpress-scripts-wrapper.js +15 -11
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ParsedAssetsJson, VerifiedAdvancedOutputConfig } from "../shared";
|
|
2
|
-
import type { ExtensibleEntryObject
|
|
1
|
+
import { ParsedAssetsJson, VerifiedAdvancedOutputConfig, VerifiedPlauditWordpressWebpackConfig } from "../shared";
|
|
2
|
+
import type { ExtensibleEntryObject } from "../utils/common-config-helpers";
|
|
3
3
|
import { PseudoSemaphore } from "../utils/pseduo-semaphore";
|
|
4
4
|
import { AbstractBiPhasicGroupPlugin } from "./AbstractBiPhasicGroupPlugin";
|
|
5
5
|
import { Compilation, Compiler, Entrypoint } from "webpack";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Compilation, Compiler, type WebpackPluginInstance } from "webpack";
|
|
2
1
|
import { PseudoSemaphore } from "../utils/pseduo-semaphore";
|
|
3
|
-
import type
|
|
4
|
-
import {
|
|
2
|
+
import { type ParsedAssetsJson, type VerifiedPlauditWordpressWebpackConfig } from "../shared";
|
|
3
|
+
import { Compilation, Compiler, type WebpackPluginInstance } from "webpack";
|
|
5
4
|
type TapWithAssetsJsonOptions = {
|
|
6
5
|
name?: string;
|
|
7
6
|
stage?: (typeof Compilation.PROCESS_ASSETS_STAGE_REPORT) | (typeof Compilation.PROCESS_ASSETS_STAGE_ANALYSE);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AbstractBiPhasicGroupPlugin = void 0;
|
|
4
|
-
const webpack_1 = require("webpack");
|
|
5
4
|
const shared_1 = require("../shared");
|
|
5
|
+
const webpack_1 = require("webpack");
|
|
6
6
|
class AbstractBiPhasicGroupPlugin {
|
|
7
7
|
config;
|
|
8
8
|
group;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractBiPhasicGroupPlugin } from "./AbstractBiPhasicGroupPlugin";
|
|
2
2
|
import type { AbstractBiPhasicGroupAndEntryPlugin } from "./AbstractBiPhasicGroupAndEntryPlugin";
|
|
3
|
-
import { VerifiedPlauditWordpressWebpackConfig } from "../
|
|
3
|
+
import { VerifiedPlauditWordpressWebpackConfig } from "../shared";
|
|
4
4
|
import { Compilation } from "webpack";
|
|
5
5
|
export declare class AdditionalDependencyInjectorPlugin extends AbstractBiPhasicGroupPlugin {
|
|
6
6
|
private readonly processingModules;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractBiPhasicGroupAndEntryPlugin, EntryProvider } from "./AbstractBiPhasicGroupAndEntryPlugin";
|
|
2
|
-
import type { VerifiedPlauditWordpressWebpackConfig } from "../
|
|
2
|
+
import type { VerifiedPlauditWordpressWebpackConfig } from "../shared";
|
|
3
3
|
export declare class EnhancedDynamicEntryPlugin extends AbstractBiPhasicGroupAndEntryPlugin {
|
|
4
4
|
constructor(config: VerifiedPlauditWordpressWebpackConfig, context: string, entry: EntryProvider);
|
|
5
5
|
protected attachUniquePhase(): void;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AbstractBiPhasicGroupAndEntryPlugin, EntryProvider } from "./AbstractBiPhasicGroupAndEntryPlugin";
|
|
2
|
-
import { ParsedAssetsJson, VerifiedAdvancedOutputConfig } from "../shared";
|
|
3
|
-
import type { VerifiedPlauditWordpressWebpackConfig } from "../utils/common-config-helpers";
|
|
2
|
+
import { ParsedAssetsJson, VerifiedAdvancedOutputConfig, VerifiedPlauditWordpressWebpackConfig } from "../shared";
|
|
4
3
|
import { Compilation, type Compiler } from "webpack";
|
|
5
4
|
export declare class ExtensionsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAndEntryPlugin {
|
|
6
5
|
private readonly extensionsSrcPath;
|
|
@@ -49,7 +49,7 @@ class ExtensionsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAndEntryP
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
generateVersionThreeConfigFile(compilation, relevantAssetData, setupFilePaths) {
|
|
52
|
-
const handlePrefix = `${this.config.
|
|
52
|
+
const handlePrefix = `${this.config.targetHandlePrefix}_block-extensions`;
|
|
53
53
|
const regex = /^(.+?)-((?:editor-|view-|)(?:style|script|script-module))\.(?:css|m?js)$/i;
|
|
54
54
|
const blockExtensionsConfig = {
|
|
55
55
|
metadata: { version: this.config.extensionsVersion }, scriptHandles: {}, scriptModuleHandles: {}, styleHandles: {}, blocks: {}, setupFiles: {}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AbstractBiPhasicGroupAndEntryPlugin, EntryProvider } from "./AbstractBiPhasicGroupAndEntryPlugin";
|
|
2
|
-
import type { ParsedAssetsJson } from "../shared";
|
|
3
|
-
import type { VerifiedPlauditWordpressWebpackConfig } from "../utils/common-config-helpers";
|
|
2
|
+
import type { ParsedAssetsJson, VerifiedPlauditWordpressWebpackConfig } from "../shared";
|
|
4
3
|
import { Compilation } from "webpack";
|
|
5
4
|
export declare class ExtensionsConfigFileGeneratorPluginV1 extends AbstractBiPhasicGroupAndEntryPlugin {
|
|
6
5
|
private readonly extensionsDest;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { ParsedAssetsJson, BlockEntrypointInfo, UsageLocations } from "../shared";
|
|
2
|
-
import type { VerifiedPlauditWordpressWebpackConfig } from "../utils/common-config-helpers";
|
|
1
|
+
import { ParsedAssetsJson, BlockEntrypointInfo, UsageLocations, VerifiedPlauditWordpressWebpackConfig } from "../shared";
|
|
3
2
|
import { AbstractBiPhasicGroupAndEntryPlugin, EntryProvider } from "./AbstractBiPhasicGroupAndEntryPlugin";
|
|
4
3
|
import { Compilation } from "webpack";
|
|
5
4
|
export declare class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAndEntryPlugin<BlockEntrypointInfo> {
|
|
@@ -28,13 +28,7 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
|
|
|
28
28
|
const emitDir = node_path_1.default.join(this.buildRoot, this.outputDir);
|
|
29
29
|
const handleLists = {
|
|
30
30
|
register: [],
|
|
31
|
-
|
|
32
|
-
clientEditor: [],
|
|
33
|
-
blockAssets: [],
|
|
34
|
-
admin: [],
|
|
35
|
-
login: [],
|
|
36
|
-
customizer: [],
|
|
37
|
-
analytics: []
|
|
31
|
+
...Object.fromEntries((0, shared_1.constantKeys)(shared_1.standardLocationNamesMeta).map(sln => [sln, []]))
|
|
38
32
|
};
|
|
39
33
|
const allNamedHandles = assets
|
|
40
34
|
.flatMap(({ handles }) => handles)
|
|
@@ -91,7 +85,7 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
|
|
|
91
85
|
for (const { handle, type, data } of prioritizedHandleList) {
|
|
92
86
|
writer.call(`wp_register_${type}`, [handle, php_writer_1.Op.concat(baseUriVar, node_path_1.default.relative(emitDir, data.src)), ...data.rest]);
|
|
93
87
|
}
|
|
94
|
-
}, { priority, accountForAlreadyDoing:
|
|
88
|
+
}, { priority, accountForAlreadyDoing: this.config.plainEntrypointsSettings.includePostInitFallback });
|
|
95
89
|
}
|
|
96
90
|
const sortedEditorStyleHandles = sortedStyleHandles
|
|
97
91
|
.filter(([_, { locations: { clientEditor }, type }]) => type === 'style' && (clientEditor || typeof clientEditor === 'number'))
|
|
@@ -113,7 +107,7 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
|
|
|
113
107
|
if (data.locations.register !== false) {
|
|
114
108
|
handleLists.register.push({ handle, type, data, priority: typeof data.locations.register === 'number' ? data.locations.register : 10 });
|
|
115
109
|
}
|
|
116
|
-
for (const location of shared_1.
|
|
110
|
+
for (const location of (0, shared_1.constantKeys)(shared_1.standardLocationNamesMeta)) {
|
|
117
111
|
if (location === 'clientEditor' && type === 'style') {
|
|
118
112
|
// We don't include editor styles in the handle list because editor styles are enqueued via a completely separate mechanism at runtime and, therefore,
|
|
119
113
|
// cannot be handled by the same code as every other enqueueable item
|
|
@@ -129,10 +123,7 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
|
|
|
129
123
|
}
|
|
130
124
|
}
|
|
131
125
|
static appendEnqueuingHandleLists(writer, handleLists) {
|
|
132
|
-
const enqueuingHandleActions = [
|
|
133
|
-
["wp_enqueue_scripts", handleLists.clientView], ["enqueue_block_editor_assets", handleLists.clientEditor], ["enqueue_block_assets", handleLists.blockAssets], ["admin_enqueue_scripts", handleLists.admin],
|
|
134
|
-
["login_enqueue_scripts", handleLists.login], ["customize_controls_enqueue_scripts", handleLists.customizer], ["plaudit_enqueue_analytics", handleLists.analytics]
|
|
135
|
-
];
|
|
126
|
+
const enqueuingHandleActions = (0, shared_1.constantEntries)(shared_1.standardLocationNamesMeta).map(([sln, { action }]) => [action, handleLists[sln]]);
|
|
136
127
|
for (const [action, handleList] of enqueuingHandleActions) {
|
|
137
128
|
if (handleList.length > 0) {
|
|
138
129
|
for (const [priority, prioritizedHandleList] of PlainEntrypointsConfigFileGeneratorPlugin.separateHandleListByPriority(handleList)) {
|
|
@@ -197,7 +188,7 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
|
|
|
197
188
|
handleName: useHandleName ? this.usageLocations.handle : undefined,
|
|
198
189
|
});
|
|
199
190
|
}
|
|
200
|
-
myAssetHandles.push({ handles, handlePrefix: this.config.
|
|
191
|
+
myAssetHandles.push({ handles, handlePrefix: this.config.targetHandlePrefix });
|
|
201
192
|
}
|
|
202
193
|
PlainEntrypointsConfigFileGeneratorPlugin.semaphore.resolve(this.id, myAssetHandles);
|
|
203
194
|
UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.resolve(this.id, myAssetHandles.length
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AbstractBiPhasicGroupAndEntryPlugin, EntryProvider } from "./AbstractBiPhasicGroupAndEntryPlugin";
|
|
2
|
-
import { ParsedAssetsJson, BlockEntrypointInfo, FileSegmentBlockEntrypointInfo } from "../shared";
|
|
3
|
-
import type { VerifiedPlauditWordpressWebpackConfig } from "../utils/common-config-helpers";
|
|
2
|
+
import { ParsedAssetsJson, BlockEntrypointInfo, FileSegmentBlockEntrypointInfo, VerifiedPlauditWordpressWebpackConfig } from "../shared";
|
|
4
3
|
import { Compilation } from "webpack";
|
|
5
4
|
import type WebpackRemoveEmptyScriptsPlugin from "webpack-remove-empty-scripts";
|
|
6
5
|
type WorkableBlockEntrypointInfo = Omit<FileSegmentBlockEntrypointInfo, 'originalValue'> & Partial<Pick<FileSegmentBlockEntrypointInfo, 'originalValue'>> & {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { VerifiedPlauditWordpressWebpackConfig } from "../shared";
|
|
2
2
|
import { AbstractBiPhasicGroupPlugin } from "./AbstractBiPhasicGroupPlugin";
|
|
3
3
|
import { Compilation } from "webpack";
|
|
4
4
|
export declare class SpecialAssetHandlingPlugin extends AbstractBiPhasicGroupPlugin {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractBiPhasicGroupPlugin } from "./AbstractBiPhasicGroupPlugin";
|
|
2
|
-
import
|
|
2
|
+
import { VerifiedPlauditWordpressWebpackConfig } from "../shared";
|
|
3
3
|
import { PHPWriter } from "../utils/php-writer";
|
|
4
4
|
import { PseudoSemaphore } from "../utils/pseduo-semaphore";
|
|
5
5
|
import { Compilation } from "webpack";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VerifiedPlauditWordpressWebpackConfig } from "../
|
|
1
|
+
import type { VerifiedPlauditWordpressWebpackConfig } from "../shared";
|
|
2
2
|
import type { Compiler, WebpackPluginInstance } from "webpack";
|
|
3
3
|
export declare class VariablesJSMonitorPlugin implements WebpackPluginInstance {
|
|
4
4
|
private readonly config;
|
package/build/shared.d.ts
CHANGED
|
@@ -14,8 +14,30 @@ export type HandleData = {
|
|
|
14
14
|
in_footer?: boolean;
|
|
15
15
|
} | boolean];
|
|
16
16
|
};
|
|
17
|
-
export declare const
|
|
18
|
-
|
|
17
|
+
export declare const standardLocationNamesMeta: {
|
|
18
|
+
readonly clientView: {
|
|
19
|
+
readonly action: "wp_enqueue_scripts";
|
|
20
|
+
};
|
|
21
|
+
readonly clientEditor: {
|
|
22
|
+
readonly action: "enqueue_block_editor_assets";
|
|
23
|
+
};
|
|
24
|
+
readonly blockAssets: {
|
|
25
|
+
readonly action: "enqueue_block_assets";
|
|
26
|
+
};
|
|
27
|
+
readonly admin: {
|
|
28
|
+
readonly action: "admin_enqueue_scripts";
|
|
29
|
+
};
|
|
30
|
+
readonly login: {
|
|
31
|
+
readonly action: "login_enqueue_scripts";
|
|
32
|
+
};
|
|
33
|
+
readonly customizer: {
|
|
34
|
+
readonly action: "customize_controls_enqueue_scripts";
|
|
35
|
+
};
|
|
36
|
+
readonly analytics: {
|
|
37
|
+
readonly action: "plaudit_enqueue_analytics";
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export type StandardLocationNames = keyof typeof standardLocationNamesMeta;
|
|
19
41
|
export type UsageLocations = {
|
|
20
42
|
[K in StandardLocationNames]?: boolean | number;
|
|
21
43
|
} & {
|
|
@@ -26,6 +48,12 @@ export type UsageLocations = {
|
|
|
26
48
|
in_footer?: boolean;
|
|
27
49
|
} | boolean;
|
|
28
50
|
};
|
|
51
|
+
export declare function constantKeys<K extends string, V>(object: {
|
|
52
|
+
[k in K]: V;
|
|
53
|
+
}): K[];
|
|
54
|
+
export declare function constantEntries<K extends string, V>(object: {
|
|
55
|
+
[k in K]: V;
|
|
56
|
+
}): [K, V][];
|
|
29
57
|
export declare const enum SourceType {
|
|
30
58
|
blocks = "blocks",
|
|
31
59
|
extensions = "extensions",
|
|
@@ -54,7 +82,11 @@ type OptionalCfgFields = 'directoryLayout' | 'externalize' | 'lazyLoader';
|
|
|
54
82
|
export type VerifiedAdvancedOutputConfig = Required<Omit<AdvancedOutputConfig, 'locations' | OptionalCfgFields>> & Pick<AdvancedOutputConfig, OptionalCfgFields> & {
|
|
55
83
|
locations: UsageLocations;
|
|
56
84
|
};
|
|
57
|
-
|
|
85
|
+
type DeprecatedPlauditWordpressWebpackConfigProps = {
|
|
86
|
+
plainEntrypointsHandlePrefix?: string;
|
|
87
|
+
plainEntrypointsVersion?: PlainEntrypointsSettings['version'];
|
|
88
|
+
};
|
|
89
|
+
type PlauditWordpressWebpackConfigProps = {
|
|
58
90
|
standaloneBlocks?: boolean;
|
|
59
91
|
variables?: Record<string, any>;
|
|
60
92
|
verbose?: boolean;
|
|
@@ -70,12 +102,23 @@ export type PlauditWordpressWebpackConfig = {
|
|
|
70
102
|
useWebpackResourceFiltering?: boolean;
|
|
71
103
|
outputDir?: string;
|
|
72
104
|
extensionsVersion?: 1 | 2 | 3;
|
|
73
|
-
|
|
74
|
-
|
|
105
|
+
targetHandlePrefix?: string;
|
|
106
|
+
plainEntrypointsSettings?: PlainEntrypointsSettings;
|
|
75
107
|
srcDir?: string;
|
|
76
108
|
srcPrefixes?: string[];
|
|
77
109
|
useUnifiedLoader?: boolean;
|
|
78
110
|
};
|
|
111
|
+
type PlainEntrypointsSettings = {
|
|
112
|
+
includePostInitFallback?: boolean;
|
|
113
|
+
version: 1 | 2;
|
|
114
|
+
};
|
|
115
|
+
export type PlauditWordpressWebpackConfig = PlauditWordpressWebpackConfigProps & DeprecatedPlauditWordpressWebpackConfigProps;
|
|
116
|
+
export type VerifiedPlauditWordpressWebpackConfig = Required<Omit<PlauditWordpressWebpackConfigProps, 'variables' | 'src' | 'externals' | 'plainEntrypointsSettings'>> & {
|
|
117
|
+
variablesFilePath?: string;
|
|
118
|
+
currentVariables: Record<string, any>;
|
|
119
|
+
} & Pick<PlauditWordpressWebpackConfig, 'externals'> & {
|
|
120
|
+
plainEntrypointsSettings: Required<PlainEntrypointsSettings>;
|
|
121
|
+
};
|
|
79
122
|
export type FileSegmentBlockEntrypointInfo = {
|
|
80
123
|
blockJsonOrigin: string;
|
|
81
124
|
entrypointField: EntrypointFields[number];
|
package/build/shared.js
CHANGED
|
@@ -3,8 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.styleExtension = exports.scriptWithModuleExtension = exports.scriptWithoutModuleExtension = exports.scriptExtension = exports.entrypointFields = exports.
|
|
6
|
+
exports.styleExtension = exports.scriptWithModuleExtension = exports.scriptWithoutModuleExtension = exports.scriptExtension = exports.entrypointFields = exports.standardLocationNamesMeta = void 0;
|
|
7
7
|
exports.isParsedAssetsJson = isParsedAssetsJson;
|
|
8
|
+
exports.constantKeys = constantKeys;
|
|
9
|
+
exports.constantEntries = constantEntries;
|
|
8
10
|
exports.determineCurrentSourceType = determineCurrentSourceType;
|
|
9
11
|
exports.convertUsageLocationsHandleToEmittableHandle = convertUsageLocationsHandleToEmittableHandle;
|
|
10
12
|
exports.makeEmittableConfigPHP = makeEmittableConfigPHP;
|
|
@@ -39,7 +41,17 @@ function isParsedAssetsJson(thing) {
|
|
|
39
41
|
}
|
|
40
42
|
return true;
|
|
41
43
|
}
|
|
42
|
-
exports.
|
|
44
|
+
exports.standardLocationNamesMeta = {
|
|
45
|
+
clientView: { action: "wp_enqueue_scripts" }, clientEditor: { action: "enqueue_block_editor_assets" }, blockAssets: { action: "enqueue_block_assets" },
|
|
46
|
+
admin: { action: "admin_enqueue_scripts" }, login: { action: "login_enqueue_scripts" }, customizer: { action: "customize_controls_enqueue_scripts" },
|
|
47
|
+
analytics: { action: "plaudit_enqueue_analytics" }
|
|
48
|
+
};
|
|
49
|
+
function constantKeys(object) {
|
|
50
|
+
return Object.keys(object);
|
|
51
|
+
}
|
|
52
|
+
function constantEntries(object) {
|
|
53
|
+
return Object.entries(object);
|
|
54
|
+
}
|
|
43
55
|
function determineCurrentSourceType(dest, srcIsDirectory) {
|
|
44
56
|
if (typeof dest === 'string') {
|
|
45
57
|
return srcIsDirectory ? "blocks" /* SourceType.blocks */ : "plain" /* SourceType.plain */;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import type { AbstractBiPhasicGroupAndEntryPlugin, EntryProvider } from "../plugins/AbstractBiPhasicGroupAndEntryPlugin";
|
|
2
2
|
import type { AdditionalDependencyInjectorPlugin } from "../plugins/AdditionalDependencyInjectorPlugin";
|
|
3
|
-
import { EntrypointFields,
|
|
3
|
+
import { EntrypointFields, VerifiedPlauditWordpressWebpackConfig, BlockEntrypointInfo, VerifiedAdvancedOutputConfig } from "../shared";
|
|
4
4
|
import type { Compiler, Configuration, DynamicEntryPlugin, WebpackPluginInstance } from "webpack";
|
|
5
5
|
import type WebpackRemoveEmptyScriptsPlugin from "webpack-remove-empty-scripts";
|
|
6
|
-
export type VerifiedPlauditWordpressWebpackConfig = Required<Omit<PlauditWordpressWebpackConfig, 'variables' | 'src' | 'externals'>> & {
|
|
7
|
-
variablesFilePath?: string;
|
|
8
|
-
currentVariables: Record<string, any>;
|
|
9
|
-
} & Pick<PlauditWordpressWebpackConfig, 'externals'>;
|
|
10
6
|
export type CommonPluginConfig = {
|
|
11
7
|
plugins: (WebpackPluginInstance | ((this: Compiler, compiler: Compiler) => void))[];
|
|
12
8
|
removeEmptyScriptsPlugin: WebpackRemoveEmptyScriptsPlugin;
|
|
@@ -172,7 +172,11 @@ function injectSupportForInliningSVGsAsStrings(rules) {
|
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
174
|
function buildVerifiedConfig(config) {
|
|
175
|
-
const { standaloneBlocks = false, stats = 'errors-warnings', variables: rawVariables, verbose = process.argv.includes('--verbose') || process.env['VERBOSE'] === 'true', postcss = {}, externals, assumeGlobalizedPlauditLibraries = true, processTranslationConfigs = true, combineAssetMetadata = true, useWebpackResourceFiltering = true, outputDir = "",
|
|
175
|
+
const { standaloneBlocks = false, stats = 'errors-warnings', variables: rawVariables, verbose = process.argv.includes('--verbose') || process.env['VERBOSE'] === 'true', postcss = {}, externals, assumeGlobalizedPlauditLibraries = true, processTranslationConfigs = true, combineAssetMetadata = true, useWebpackResourceFiltering = true, outputDir = "", srcDir = "", useUnifiedLoader = false } = config;
|
|
176
|
+
const plainEntrypointsSettings = {
|
|
177
|
+
version: config.plainEntrypointsSettings?.version ?? config.plainEntrypointsVersion ?? 1,
|
|
178
|
+
includePostInitFallback: config.plainEntrypointsSettings?.includePostInitFallback ?? true
|
|
179
|
+
};
|
|
176
180
|
let srcPrefixes;
|
|
177
181
|
const trailingSlashedSrcDir = srcDir && !srcDir.endsWith("/") ? srcDir + "/" : srcDir;
|
|
178
182
|
if (config.srcPrefixes === undefined) {
|
|
@@ -181,12 +185,12 @@ function buildVerifiedConfig(config) {
|
|
|
181
185
|
else {
|
|
182
186
|
srcPrefixes = (srcDir && !config.srcPrefixes.includes(trailingSlashedSrcDir) ? [...config.srcPrefixes, trailingSlashedSrcDir] : config.srcPrefixes);
|
|
183
187
|
}
|
|
184
|
-
let
|
|
185
|
-
if (
|
|
186
|
-
if (!
|
|
187
|
-
|
|
188
|
-
if (!
|
|
189
|
-
throw new Error("Plain Entrypoints V2 and higher require either '
|
|
188
|
+
let targetHandlePrefix = config.targetHandlePrefix ?? config.plainEntrypointsHandlePrefix ?? "";
|
|
189
|
+
if (plainEntrypointsSettings.version > 1) {
|
|
190
|
+
if (!targetHandlePrefix) {
|
|
191
|
+
targetHandlePrefix = deriveDefaultHandlePrefixFromComposerJsonOrThemeName();
|
|
192
|
+
if (!targetHandlePrefix) {
|
|
193
|
+
throw new Error("Plain Entrypoints V2 and higher require either 'targetHandlePrefix' to be set or an adjacent composer.json or style.css file to be present");
|
|
190
194
|
}
|
|
191
195
|
}
|
|
192
196
|
if (!outputDir) {
|
|
@@ -220,7 +224,7 @@ function buildVerifiedConfig(config) {
|
|
|
220
224
|
}
|
|
221
225
|
const cfg = {
|
|
222
226
|
currentVariables, postcss, standaloneBlocks, stats, variablesFilePath, verbose, externals, assumeGlobalizedPlauditLibraries, processTranslationConfigs, combineAssetMetadata,
|
|
223
|
-
useWebpackResourceFiltering, outputDir, extensionsVersion,
|
|
227
|
+
useWebpackResourceFiltering, outputDir, extensionsVersion, plainEntrypointsSettings, srcDir, srcPrefixes, targetHandlePrefix, useUnifiedLoader
|
|
224
228
|
};
|
|
225
229
|
// Destination -> source map
|
|
226
230
|
const allocatedDestinations = {};
|
|
@@ -309,7 +313,7 @@ function deriveDefaultHandlePrefixFromComposerJsonOrThemeName() {
|
|
|
309
313
|
return deriveDefaultHandlePrefixFromThemeName();
|
|
310
314
|
}
|
|
311
315
|
if (typeof composerJson !== 'object' || typeof composerJson.name !== 'string' || !composerJson.name) {
|
|
312
|
-
throw new ReferenceError("
|
|
316
|
+
throw new ReferenceError("targetHandlePrefix was not set and the adjacent composer.json file does not have a valid name in it");
|
|
313
317
|
}
|
|
314
318
|
return (0, shared_1.kebabCase)(composerJson.name.replace(/plaudit\/plaudit/, 'plaudit'));
|
|
315
319
|
}
|
|
@@ -317,7 +321,7 @@ function deriveDefaultHandlePrefixFromThemeName() {
|
|
|
317
321
|
const styleFileContents = node_fs_1.default.readFileSync(node_path_1.default.join(process.cwd(), "style.css"), 'utf-8');
|
|
318
322
|
const themeName = /^\W*Theme\s*Name:\s*(.+)$/im.exec(styleFileContents)?.[1]?.trim();
|
|
319
323
|
if (!themeName) {
|
|
320
|
-
throw new ReferenceError("
|
|
324
|
+
throw new ReferenceError("targetHandlePrefix was not set and the adjacent style.css file does not have a valid name in it");
|
|
321
325
|
}
|
|
322
326
|
return (0, shared_1.kebabCase)(themeName);
|
|
323
327
|
}
|
|
@@ -522,7 +526,7 @@ function processIndividualWebpackConfig(config, webpackConfig, sources, canClean
|
|
|
522
526
|
}
|
|
523
527
|
}
|
|
524
528
|
const baseDest = stripExtension(dest.destination);
|
|
525
|
-
if (config.
|
|
529
|
+
if (config.plainEntrypointsSettings.version > 1) {
|
|
526
530
|
const entry = srcIsDirectory // This being true implies that srcRoot is not an array
|
|
527
531
|
? (0, common_config_helpers_1.resolveEntryFromDirectory)(commonConfig, srcRoot, dest)
|
|
528
532
|
: () => ({ [baseDest]: { import: Array.isArray(srcRoot) ? srcRoot : [srcRoot], plauditMetadata: { purpose: "plain-entrypoint", dest } } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plaudit/webpack-extensions",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.69.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"files": [
|
|
6
6
|
"/build"
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@plaudit/gutenberg-api-extensions": "^2.77.
|
|
19
|
+
"@plaudit/gutenberg-api-extensions": "^2.77.2",
|
|
20
20
|
"@types/browser-sync-webpack-plugin": "^2.2.5",
|
|
21
|
-
"@types/node": "^24.
|
|
21
|
+
"@types/node": "^24.6.0",
|
|
22
22
|
"@types/postcss-functions": "^4.0.4",
|
|
23
23
|
"@types/tapable": "^2.2.7",
|
|
24
24
|
"@types/webpack": "^5.28.5",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"postcss-url": "^10.1.3",
|
|
60
60
|
"react": "^18.3.1",
|
|
61
61
|
"react-dom": "^18.3.1",
|
|
62
|
-
"webpack": "^5.
|
|
62
|
+
"webpack": "^5.102.0",
|
|
63
63
|
"webpack-remove-empty-scripts": "^1.1.1",
|
|
64
64
|
"xml-formatter": "^3.6.7"
|
|
65
65
|
},
|