@plaudit/webpack-extensions 2.5.2 → 2.6.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.
|
@@ -231,50 +231,53 @@ module.exports = function (config, webpackConfig = require("@wordpress/scripts/c
|
|
|
231
231
|
}
|
|
232
232
|
let entry;
|
|
233
233
|
if (srcIsDirectory) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
const blockJSON = JSON.parse(node_fs_1.default.readFileSync(node_path_1.default.join(dir, 'block.json'), 'utf8'));
|
|
241
|
-
for (const key of ["editorStyle", "style", "editorScript", "viewScript", "script"]) {
|
|
242
|
-
if (key in blockJSON) {
|
|
243
|
-
res.push(...mapToRealEntrypoints(blockJSON[key], dir, ep => ep.startsWith("file:") ? ep.substring(5) : ep));
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
return res;
|
|
247
|
-
}
|
|
248
|
-
catch (e) {
|
|
234
|
+
entry = () => {
|
|
235
|
+
const rawEntrypoints = node_fs_1.default.readdirSync(srcRoot, 'utf8')
|
|
236
|
+
.map(dir => joinPossiblyAbsolutePaths(srcRoot, dir))
|
|
237
|
+
.filter(dir => node_fs_1.default.statSync(dir).isDirectory())
|
|
238
|
+
.flatMap(dir => {
|
|
239
|
+
const res = [];
|
|
249
240
|
try {
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
|
|
241
|
+
const blockJSON = JSON.parse(node_fs_1.default.readFileSync(node_path_1.default.join(dir, 'block.json'), 'utf8'));
|
|
242
|
+
for (const key of ["editorStyle", "style", "editorScript", "viewScript", "script"]) {
|
|
243
|
+
if (key in blockJSON) {
|
|
244
|
+
res.push(...mapToRealEntrypoints(blockJSON[key], dir, ep => ep.startsWith("file:") ? ep.substring(5) : ep));
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return res;
|
|
253
248
|
}
|
|
254
249
|
catch (e) {
|
|
255
250
|
try {
|
|
256
|
-
|
|
251
|
+
const packageJSON = JSON.parse(node_fs_1.default.readFileSync(node_path_1.default.join(dir, 'package.json'), 'utf8'));
|
|
252
|
+
res.push(...mapToRealEntrypoints(packageJSON['main'], dir));
|
|
253
|
+
res.push(...mapToRealEntrypoints(packageJSON['style'], dir));
|
|
257
254
|
}
|
|
258
255
|
catch (e) {
|
|
259
|
-
|
|
256
|
+
try {
|
|
257
|
+
res.push(...parseEntrypointsJSON(dir));
|
|
258
|
+
}
|
|
259
|
+
catch (e) {
|
|
260
|
+
// This just means that the directory doesn't contain any declared entrypoints.
|
|
261
|
+
}
|
|
260
262
|
}
|
|
261
263
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
264
|
+
return res;
|
|
265
|
+
});
|
|
266
|
+
const perAssetPathGroupedEntrypoints = groupEntrypointsByAssetFile(rawEntrypoints, e => e[0]);
|
|
267
|
+
const currentEntry = {};
|
|
268
|
+
for (const groupedEntrypoints of perAssetPathGroupedEntrypoints.values()) {
|
|
269
|
+
if (groupedEntrypoints.length === 1) {
|
|
270
|
+
currentEntry[groupedEntrypoints[0][0]] = groupedEntrypoints[0][1];
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
const typeCounts = {};
|
|
274
|
+
for (const entrypoint of groupedEntrypoints) {
|
|
275
|
+
addPotentiallyDuplicatedEntrypointName(currentEntry, entrypoint, typeCounts);
|
|
276
|
+
}
|
|
275
277
|
}
|
|
276
278
|
}
|
|
277
|
-
|
|
279
|
+
return currentEntry;
|
|
280
|
+
};
|
|
278
281
|
}
|
|
279
282
|
else {
|
|
280
283
|
const baseDest = node_path_1.default.basename(destPath);
|
|
@@ -282,24 +285,13 @@ module.exports = function (config, webpackConfig = require("@wordpress/scripts/c
|
|
|
282
285
|
[baseDest.includes('.') ? node_path_1.default.basename(baseDest, node_path_1.default.extname(baseDest)) : baseDest]: srcRoot
|
|
283
286
|
};
|
|
284
287
|
}
|
|
285
|
-
let output;
|
|
286
|
-
if (srcIsDirectory) {
|
|
287
|
-
output = {
|
|
288
|
-
path: joinPossiblyAbsolutePaths(process.cwd(), destPath)
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
else {
|
|
292
|
-
output = {
|
|
293
|
-
path: joinPossiblyAbsolutePaths(process.cwd(), node_path_1.default.dirname(destPath))
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
288
|
return {
|
|
297
289
|
...webpackConfig,
|
|
298
290
|
devtool: 'source-map',
|
|
299
291
|
mode: "production",
|
|
300
292
|
output: {
|
|
301
293
|
...webpackConfig.output,
|
|
302
|
-
|
|
294
|
+
path: joinPossiblyAbsolutePaths(process.cwd(), srcIsDirectory ? destPath : node_path_1.default.dirname(destPath))
|
|
303
295
|
},
|
|
304
296
|
plugins: copyFiles
|
|
305
297
|
? plugins.map(plugin => plugin.constructor.name === 'CopyPlugin'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plaudit/webpack-extensions",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepublishOnly": "rm -rf build && mkdir build && tsc",
|
|
6
6
|
"build": "tsc",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"eslint": "^8.43.0",
|
|
39
39
|
"eslint-plugin-jsdoc": "^43.1.1",
|
|
40
40
|
"fork-ts-checker-webpack-plugin": "^8.0.0",
|
|
41
|
-
"postcss": "^8.4.
|
|
41
|
+
"postcss": "^8.4.25",
|
|
42
42
|
"postcss-calc": "^9.0.1",
|
|
43
43
|
"postcss-fallback": "^0.1.0",
|
|
44
44
|
"postcss-functions": "^4.0.2",
|