@plaudit/webpack-extensions 2.30.0 → 2.30.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.
@@ -4,8 +4,10 @@ export default class BlockJSONManagingPlugin implements WebpackPluginInstance {
4
4
  private readonly processingModules;
5
5
  private static readonly sourceToOutputMapping;
6
6
  private static readonly blockJsonToEntrypointsMap;
7
+ private static readonly blockJsonRawDependenciesMap;
7
8
  private static readonly blockJSONAssetSources;
8
9
  constructor(standaloneBlocks: boolean, processingModules: boolean);
10
+ static recordRawDependency(entrypoint: string, dependency: string): void;
9
11
  apply(compiler: Compiler): void;
10
12
  static resolveDestinationBySourceExtension(srcPath: string, entrypoint: Compilation['asyncEntrypoints'][number]): string | undefined;
11
13
  static findCommonAncestor(...paths: string[]): string[];
@@ -13,11 +13,19 @@ class BlockJSONManagingPlugin {
13
13
  processingModules;
14
14
  static sourceToOutputMapping = new Map();
15
15
  static blockJsonToEntrypointsMap = new Map();
16
+ static blockJsonRawDependenciesMap = new Map();
16
17
  static blockJSONAssetSources = new Map();
17
18
  constructor(standaloneBlocks, processingModules) {
18
19
  this.standaloneBlocks = standaloneBlocks;
19
20
  this.processingModules = processingModules;
20
21
  }
22
+ static recordRawDependency(entrypoint, dependency) {
23
+ let deps = BlockJSONManagingPlugin.blockJsonRawDependenciesMap.get(entrypoint);
24
+ if (deps === undefined) {
25
+ BlockJSONManagingPlugin.blockJsonRawDependenciesMap.set(entrypoint, deps = new Set());
26
+ }
27
+ deps.add(dependency);
28
+ }
21
29
  apply(compiler) {
22
30
  compiler.hooks.compilation.tap(this.constructor.name, compilation => {
23
31
  compilation.hooks.processAssets.tap({ name: this.constructor.name, stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ANALYSE }, () => {
@@ -29,7 +37,7 @@ class BlockJSONManagingPlugin {
29
37
  continue;
30
38
  }
31
39
  BlockJSONManagingPlugin.blockJSONAssetSources.set(name, source);
32
- const dependencies = blockEntrypoint.getEntrypointChunk().getEntryOptions()?.dependOn;
40
+ const dependencies = BlockJSONManagingPlugin.blockJsonRawDependenciesMap.get(blockEntrypoint.name);
33
41
  if (dependencies) {
34
42
  for (const dependency of dependencies) {
35
43
  const entrypoint = compilation.entrypoints.get(dependency);
@@ -403,22 +403,7 @@ function processIndividualWebpackConfig(config, webpackConfig, sources) {
403
403
  // This is used to allow for block.json dependencies to correctly account for name-deduplication
404
404
  for (const [key, entry] of Object.entries(currentEntry)) {
405
405
  if (typeof entry === 'object' && !Array.isArray(entry) && 'lazyDependent' in entry && typeof entry.lazyDependent === 'string') {
406
- const target = currentEntry[entry.lazyDependent];
407
- if (typeof target === 'object' && !Array.isArray(target)) {
408
- let dependOn;
409
- if (target.dependOn === undefined) {
410
- dependOn = target.dependOn = [];
411
- }
412
- else if (typeof target.dependOn === 'string') {
413
- dependOn = target.dependOn = [target.dependOn];
414
- }
415
- else {
416
- dependOn = target.dependOn;
417
- }
418
- if (!dependOn.includes(key)) {
419
- dependOn.push(key);
420
- }
421
- }
406
+ BlockJSONManagingPlugin_1.default.recordRawDependency(entry.lazyDependent, key);
422
407
  }
423
408
  }
424
409
  return currentEntry;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "2.30.0",
3
+ "version": "2.30.1",
4
4
  "scripts": {
5
5
  "prepublishOnly": "rm -rf build && mkdir build && tsc",
6
6
  "build": "tsc",