@plaudit/webpack-extensions 2.72.1 → 2.73.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/shared.d.ts CHANGED
@@ -148,4 +148,5 @@ export declare function emitResolveBaseUriFunction(writer: PHPWriter): void;
148
148
  export declare function getAssetsJson(compilation: Compilation): ParsedAssetsJson;
149
149
  export declare function emitPHPWriterAsAsset(writer: PHPWriter, compilation: Compilation, file: string, assetInfo?: AssetInfo): void;
150
150
  export declare function dedent(text: TemplateStringsArray): string;
151
+ export declare function resolveLegacyBlockScriptsInFolder(folder: string): string[];
151
152
  export {};
package/build/shared.js CHANGED
@@ -26,7 +26,10 @@ exports.emitResolveBaseUriFunction = emitResolveBaseUriFunction;
26
26
  exports.getAssetsJson = getAssetsJson;
27
27
  exports.emitPHPWriterAsAsset = emitPHPWriterAsAsset;
28
28
  exports.dedent = dedent;
29
+ exports.resolveLegacyBlockScriptsInFolder = resolveLegacyBlockScriptsInFolder;
30
+ const node_fs_1 = __importDefault(require("node:fs"));
29
31
  const promises_1 = __importDefault(require("node:fs/promises"));
32
+ const node_path_1 = __importDefault(require("node:path"));
30
33
  const php_writer_1 = require("@plaudit/php-writer");
31
34
  const expressions_1 = require("@plaudit/php-writer/expressions");
32
35
  const webpack_1 = require("webpack");
@@ -192,3 +195,17 @@ function dedent(text) {
192
195
  }
193
196
  return actualText.replaceAll(new RegExp("^" + firstLineIndent, 'mg'), "").replace(/\n{2}$/, "\n");
194
197
  }
198
+ function resolveLegacyBlockScriptsInFolder(folder) {
199
+ const blockScriptEntrypoints = [];
200
+ for (const blockDir of node_fs_1.default.readdirSync(folder)) {
201
+ const fullBlockDir = node_path_1.default.join(folder, blockDir);
202
+ const packageJSON = node_path_1.default.join(fullBlockDir, 'package.json');
203
+ if (node_fs_1.default.existsSync(packageJSON)) {
204
+ const main = JSON.parse(node_fs_1.default.readFileSync(packageJSON, 'utf8'))['main'];
205
+ if (main && node_fs_1.default.existsSync(node_path_1.default.join(fullBlockDir, main))) {
206
+ blockScriptEntrypoints.push(node_path_1.default.join(fullBlockDir, main));
207
+ }
208
+ }
209
+ }
210
+ return blockScriptEntrypoints;
211
+ }
@@ -25,20 +25,6 @@ const UnifiedLoaderGenerator_1 = require("./plugins/UnifiedLoaderGenerator");
25
25
  const copy_webpack_plugin_1 = __importDefault(require("copy-webpack-plugin"));
26
26
  const fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
27
27
  const webpack_remove_empty_scripts_1 = __importDefault(require("webpack-remove-empty-scripts"));
28
- function resolveLegacyBlockScriptsInFolder(folder) {
29
- const blockScriptEntrypoints = [];
30
- for (const blockDir of node_fs_1.default.readdirSync(folder)) {
31
- const fullBlockDir = node_path_1.default.join(folder, blockDir);
32
- const packageJSON = node_path_1.default.join(fullBlockDir, 'package.json');
33
- if (node_fs_1.default.existsSync(packageJSON)) {
34
- const main = JSON.parse(node_fs_1.default.readFileSync(packageJSON, 'utf8'))['main'];
35
- if (main && node_fs_1.default.existsSync(node_path_1.default.join(fullBlockDir, main))) {
36
- blockScriptEntrypoints.push(node_path_1.default.join(fullBlockDir, main));
37
- }
38
- }
39
- }
40
- return blockScriptEntrypoints;
41
- }
42
28
  function testForDuplicatedEntryPaths(sources) {
43
29
  const seenPaths = (0, common_config_helpers_1.groupEntrypointsByAssetFile)(Array.isArray(sources)
44
30
  ? sources.map(s => typeof s === 'string' ? s : s[1].destination)
@@ -466,7 +452,7 @@ function processIndividualWebpackConfig(config, webpackConfig, sources, canClean
466
452
  const { processingModules, scriptExtension } = commonConfig;
467
453
  const allSrcRoots = sources.map(([src, dest]) => {
468
454
  const srcRoots = (dest.withLegacyBlocksIn
469
- ? [...src.split(','), ...resolveLegacyBlockScriptsInFolder(node_path_1.default.join(config.srcDir, dest.withLegacyBlocksIn))]
455
+ ? [...src.split(','), ...(0, shared_1.resolveLegacyBlockScriptsInFolder)(node_path_1.default.join(config.srcDir, dest.withLegacyBlocksIn))]
470
456
  : src.split(',')).filter(s => s.endsWith(".json") || !s.substring(s.lastIndexOf('/')).includes('.') || processingModules === shared_1.scriptWithModuleExtension.test(s));
471
457
  const srcRoot = srcRoots.length < 2 ? (0, common_config_helpers_1.joinPossiblyAbsolutePaths)(process.cwd(), src) : srcRoots.map(s => (0, common_config_helpers_1.joinPossiblyAbsolutePaths)(process.cwd(), s));
472
458
  const srcIsDirectory = !Array.isArray(srcRoot) && node_fs_1.default.lstatSync(srcRoot, { throwIfNoEntry: false })?.isDirectory();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "2.72.1",
3
+ "version": "2.73.0",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "files": [
6
6
  "/build"