@plaudit/webpack-extensions 2.35.0 → 2.37.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/wordpress-scripts-wrapper/BlockJSONManagingPlugin.js +3 -2
- package/build/wordpress-scripts-wrapper/MiniCSSExtractPluginErrorCleaner.d.ts +4 -0
- package/build/wordpress-scripts-wrapper/MiniCSSExtractPluginErrorCleaner.js +14 -0
- package/build/wordpress-scripts-wrapper/php-serializer.d.ts +6 -1
- package/build/wordpress-scripts-wrapper/php-serializer.js +15 -10
- package/build/wordpress-scripts-wrapper.js +2 -4
- package/package.json +1 -1
|
@@ -73,13 +73,13 @@ class BlockJSONManagingPlugin {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
+
//TODO: Fix modules support when running in non-dev mode
|
|
76
77
|
const blockDirConfigData = {};
|
|
77
78
|
for (const [name, sourceDir] of currentBlockJSONAssets) {
|
|
78
79
|
const assetContents = this.processingModules ? node_fs_1.default.readFileSync(testableCompilationAssets[name], 'utf8') : compilation.assets[name]?.buffer().toString();
|
|
79
80
|
if (!assetContents) {
|
|
80
81
|
continue;
|
|
81
82
|
}
|
|
82
|
-
blockDirConfigData[name] = true;
|
|
83
83
|
const json = JSON.parse(assetContents);
|
|
84
84
|
const currentAssetKeyMappings = { directMappings: {}, referencedFiles: {}, compositeHash: "" };
|
|
85
85
|
for (const mappableKey of BlockJSONManagingPlugin[this.processingModules ? 'mappableModuleKeys' : 'mappableNonModuleKeys']) {
|
|
@@ -193,10 +193,11 @@ class BlockJSONManagingPlugin {
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
compilation[name in compilation.assets ? 'updateAsset' : 'emitAsset'](name, new webpack_1.sources.RawSource(JSON.stringify(json, undefined, " ")));
|
|
196
|
+
blockDirConfigData[node_path_1.default.dirname(name)] = json;
|
|
196
197
|
}
|
|
197
198
|
const sortedBlockDirConfigData = Object.fromEntries(Object.entries(blockDirConfigData)
|
|
198
199
|
.sort(([a], [b]) => a.localeCompare(b)));
|
|
199
|
-
compilation.emitAsset("blockdir.config", new webpack_1.sources.RawSource((0, php_serializer_1.default)(sortedBlockDirConfigData)));
|
|
200
|
+
compilation.emitAsset("blockdir.config", new webpack_1.sources.RawSource((0, php_serializer_1.default)(sortedBlockDirConfigData, { excludedKeys: ["$schema"] })));
|
|
200
201
|
});
|
|
201
202
|
});
|
|
202
203
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class MiniCSSExtractPluginErrorCleaner {
|
|
4
|
+
apply(compiler) {
|
|
5
|
+
compiler.hooks.done.tap("CleanupMiniCssExtractPlugin", stats => {
|
|
6
|
+
if (stats.hasErrors()) {
|
|
7
|
+
if (!stats.compilation.errors.every(error => error.message.includes("mini-css-extract-plugin")) && stats.compilation.errors.length % 2 === 0) {
|
|
8
|
+
stats.compilation.errors = stats.compilation.errors.filter(error => !error.message.includes("mini-css-extract-plugin"));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.default = MiniCSSExtractPluginErrorCleaner;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = phpSerialize;
|
|
4
|
-
function phpSerialize(value,
|
|
4
|
+
function phpSerialize(value, config) {
|
|
5
5
|
switch (typeof value) {
|
|
6
6
|
case "undefined":
|
|
7
7
|
return "N;";
|
|
@@ -12,15 +12,15 @@ function phpSerialize(value, objectsAsArrays = true) {
|
|
|
12
12
|
else if (Array.isArray(value)) {
|
|
13
13
|
let res = `a:${value.length}:{`;
|
|
14
14
|
for (let i = 0; i < value.length; i++) {
|
|
15
|
-
res += `i:${i};${phpSerialize(value[i],
|
|
15
|
+
res += `i:${i};${phpSerialize(value[i], config)}`;
|
|
16
16
|
}
|
|
17
17
|
return (res.endsWith('};') ? res.substring(0, res.length - 1) : res) + "}";
|
|
18
18
|
}
|
|
19
|
-
return entriesInArrayAndObjectFormat(objectsAsArrays ? 'a' : 'O:8:"stdClass"', Object.entries(value),
|
|
19
|
+
return entriesInArrayAndObjectFormat(config?.objectsAsArrays ?? true ? 'a' : 'O:8:"stdClass"', Object.entries(value), config);
|
|
20
20
|
case "boolean":
|
|
21
21
|
return `b:${value ? 1 : 0};`;
|
|
22
22
|
case "number":
|
|
23
|
-
return Number.isInteger(value) ? serializeInteger(value) : `d:${value}
|
|
23
|
+
return Number.isInteger(value) ? serializeInteger(value) : `d:${value};`;
|
|
24
24
|
case "string":
|
|
25
25
|
return `s:${Buffer.byteLength(value, 'utf8')}:"${value}";`;
|
|
26
26
|
case "function":
|
|
@@ -35,14 +35,19 @@ function phpSerialize(value, objectsAsArrays = true) {
|
|
|
35
35
|
function serializeInteger(value) {
|
|
36
36
|
const str = value.toString();
|
|
37
37
|
if (str.includes("e") || str.includes("E")) {
|
|
38
|
-
return `d:${str.replace(/e/i, ".0e")}
|
|
38
|
+
return `d:${str.replace(/e/i, ".0e")};`;
|
|
39
39
|
}
|
|
40
|
-
return `i:${str}
|
|
40
|
+
return `i:${str};`;
|
|
41
41
|
}
|
|
42
|
-
function entriesInArrayAndObjectFormat(prefix, entries,
|
|
43
|
-
|
|
42
|
+
function entriesInArrayAndObjectFormat(prefix, entries, config) {
|
|
43
|
+
const excludedKeys = config?.excludedKeys ?? [];
|
|
44
|
+
let res = "";
|
|
45
|
+
let count = 0;
|
|
44
46
|
for (const [k, v] of entries) {
|
|
45
|
-
|
|
47
|
+
if (!excludedKeys.includes(k)) {
|
|
48
|
+
count++;
|
|
49
|
+
res += `${phpSerialize(k, config)}${phpSerialize(v, config)}`;
|
|
50
|
+
}
|
|
46
51
|
}
|
|
47
|
-
return (res.endsWith('};') ? res.substring(0, res.length - 1) : res) + "}";
|
|
52
|
+
return `${prefix}:${count}:{` + (res.endsWith('};') ? res.substring(0, res.length - 1) : res) + "}";
|
|
48
53
|
}
|
|
@@ -7,6 +7,7 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
|
7
7
|
const AdditionalDependencyInjectorPlugin_1 = __importDefault(require("./wordpress-scripts-wrapper/AdditionalDependencyInjectorPlugin"));
|
|
8
8
|
const BlockJSONManagingPlugin_1 = __importDefault(require("./wordpress-scripts-wrapper/BlockJSONManagingPlugin"));
|
|
9
9
|
const ExtensionsConfigFileGeneratorPlugin_1 = __importDefault(require("./wordpress-scripts-wrapper/ExtensionsConfigFileGeneratorPlugin"));
|
|
10
|
+
const MiniCSSExtractPluginErrorCleaner_1 = __importDefault(require("./wordpress-scripts-wrapper/MiniCSSExtractPluginErrorCleaner"));
|
|
10
11
|
const VariablesJSMonitorPlugin_1 = __importDefault(require("./wordpress-scripts-wrapper/VariablesJSMonitorPlugin"));
|
|
11
12
|
const BrowserSyncPlugin_1 = require("./wordpress-scripts-wrapper/BrowserSyncPlugin");
|
|
12
13
|
const static_configs_1 = require("./wordpress-scripts-wrapper/static-configs");
|
|
@@ -17,9 +18,6 @@ const webpack_remove_empty_scripts_1 = __importDefault(require("webpack-remove-e
|
|
|
17
18
|
function joinPossiblyAbsolutePaths(...paths) {
|
|
18
19
|
return paths.reduce((res, p) => !res || node_path_1.default.isAbsolute(p) ? p : node_path_1.default.join(res, p), '') || '.';
|
|
19
20
|
}
|
|
20
|
-
function test(content, map, meta) {
|
|
21
|
-
this.resourcePath;
|
|
22
|
-
}
|
|
23
21
|
function mapToRealEntrypoints(entrypoint, dir, mapper = (entrypoint) => entrypoint, lazyDependent) {
|
|
24
22
|
return (Array.isArray(entrypoint) ? entrypoint : [entrypoint])
|
|
25
23
|
.map(ep => joinPossiblyAbsolutePaths(dir, mapper(ep)))
|
|
@@ -342,7 +340,7 @@ function processIndividualWebpackConfig(config, webpackConfig, sources) {
|
|
|
342
340
|
plugins.push(new webpack_remove_empty_scripts_1.default({
|
|
343
341
|
stage: webpack_remove_empty_scripts_1.default.STAGE_AFTER_PROCESS_PLUGINS,
|
|
344
342
|
extensions: ['css', 'scss', 'sass', 'less', 'styl', 'pcss']
|
|
345
|
-
}));
|
|
343
|
+
}), new MiniCSSExtractPluginErrorCleaner_1.default());
|
|
346
344
|
if (variablesFilePath) {
|
|
347
345
|
plugins.push(new VariablesJSMonitorPlugin_1.default(variablesFilePath));
|
|
348
346
|
}
|