@rsdoctor/graph 1.5.12 → 2.0.0-alpha.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.
@@ -4,7 +4,7 @@ export declare class ModuleGraph implements SDK.ModuleGraphInstance {
4
4
  static fromData(data: Partial<SDK.ModuleGraphData>): ModuleGraph;
5
5
  private _dependenciesIdMap;
6
6
  private _connectionsOnlyImports;
7
- private _moduleWebpackIdMap;
7
+ private _moduleIdentifierMap;
8
8
  private _moduleIdMap;
9
9
  private _moduleGraphModules;
10
10
  private _exportIdMap;
@@ -20,7 +20,7 @@ export declare class ModuleGraph implements SDK.ModuleGraphInstance {
20
20
  getEntryModules(): SDK.ModuleInstance[];
21
21
  getModuleById(id: number): SDK.ModuleInstance | undefined;
22
22
  getDependencyById(id: number): SDK.DependencyInstance | undefined;
23
- getModuleByWebpackId(id: string): SDK.ModuleInstance | undefined;
23
+ getModuleByIdentifier(id: string): SDK.ModuleInstance | undefined;
24
24
  getModuleByFile(file: string, layer?: string): SDK.ModuleInstance[];
25
25
  addModule(...modules: SDK.ModuleInstance[]): void;
26
26
  addDependency(...deps: SDK.DependencyInstance[]): void;
@@ -4,7 +4,7 @@ export declare class ModuleGraph implements SDK.ModuleGraphInstance {
4
4
  static fromData(data: Partial<SDK.ModuleGraphData>): ModuleGraph;
5
5
  private _dependenciesIdMap;
6
6
  private _connectionsOnlyImports;
7
- private _moduleWebpackIdMap;
7
+ private _moduleIdentifierMap;
8
8
  private _moduleIdMap;
9
9
  private _moduleGraphModules;
10
10
  private _exportIdMap;
@@ -20,7 +20,7 @@ export declare class ModuleGraph implements SDK.ModuleGraphInstance {
20
20
  getEntryModules(): SDK.ModuleInstance[];
21
21
  getModuleById(id: number): SDK.ModuleInstance | undefined;
22
22
  getDependencyById(id: number): SDK.DependencyInstance | undefined;
23
- getModuleByWebpackId(id: string): SDK.ModuleInstance | undefined;
23
+ getModuleByIdentifier(id: string): SDK.ModuleInstance | undefined;
24
24
  getModuleByFile(file: string, layer?: string): SDK.ModuleInstance[];
25
25
  addModule(...modules: SDK.ModuleInstance[]): void;
26
26
  addDependency(...deps: SDK.DependencyInstance[]): void;
@@ -14,7 +14,7 @@ export declare class Module implements SDK.ModuleInstance {
14
14
  sideEffectLocations: SDK.SideEffectLocationData[];
15
15
  /** Side effect code snippets */
16
16
  private sideEffectCodes;
17
- readonly webpackId: string;
17
+ readonly identifier: string;
18
18
  readonly path: string;
19
19
  readonly isEntry: boolean;
20
20
  readonly kind: SDK.ModuleKind;
@@ -30,7 +30,7 @@ export declare class Module implements SDK.ModuleInstance {
30
30
  private concatenationModules;
31
31
  private _isPreferSource?;
32
32
  meta: SDK.ModuleBuildMeta;
33
- constructor(webpackId: string, path: string, isEntry?: boolean, kind?: SDK.ModuleKind, renderId?: string | undefined, layer?: string);
33
+ constructor(identifier: string, path: string, isEntry?: boolean, kind?: SDK.ModuleKind, renderId?: string | undefined, layer?: string);
34
34
  get rootModule(): SDK.ModuleInstance | undefined;
35
35
  get isPreferSource(): boolean;
36
36
  addBailoutReason(reason: string): void;
@@ -14,7 +14,7 @@ export declare class Module implements SDK.ModuleInstance {
14
14
  sideEffectLocations: SDK.SideEffectLocationData[];
15
15
  /** Side effect code snippets */
16
16
  private sideEffectCodes;
17
- readonly webpackId: string;
17
+ readonly identifier: string;
18
18
  readonly path: string;
19
19
  readonly isEntry: boolean;
20
20
  readonly kind: SDK.ModuleKind;
@@ -30,7 +30,7 @@ export declare class Module implements SDK.ModuleInstance {
30
30
  private concatenationModules;
31
31
  private _isPreferSource?;
32
32
  meta: SDK.ModuleBuildMeta;
33
- constructor(webpackId: string, path: string, isEntry?: boolean, kind?: SDK.ModuleKind, renderId?: string | undefined, layer?: string);
33
+ constructor(identifier: string, path: string, isEntry?: boolean, kind?: SDK.ModuleKind, renderId?: string | undefined, layer?: string);
34
34
  get rootModule(): SDK.ModuleInstance | undefined;
35
35
  get isPreferSource(): boolean;
36
36
  addBailoutReason(reason: string): void;
package/dist/index.cjs CHANGED
@@ -477,7 +477,7 @@ class Module {
477
477
  static init() {
478
478
  module_id = 1;
479
479
  }
480
- constructor(webpackId, path, isEntry = !1, kind = types_namespaceObject.SDK.ModuleKind.Normal, renderId, layer = ''){
480
+ constructor(identifier, path, isEntry = !1, kind = types_namespaceObject.SDK.ModuleKind.Normal, renderId, layer = ''){
481
481
  this.issuerPath = [], this.bailoutReason = [], this.sideEffectLocations = [], this.sideEffectCodes = [], this.source = {
482
482
  source: '',
483
483
  transformed: '',
@@ -490,7 +490,7 @@ class Module {
490
490
  }, this.chunks = [], this.dependencies = [], this.imported = [], this.modules = [], this.concatenationModules = [], this.meta = {
491
491
  hasSetEsModuleStatement: !1,
492
492
  strictHarmonyModule: !1
493
- }, this.id = module_id++, this.webpackId = webpackId, this.path = path, this.isEntry = isEntry, this.kind = kind, this.renderId = renderId, this.layer = layer;
493
+ }, this.id = module_id++, this.identifier = identifier, this.path = path, this.isEntry = isEntry, this.kind = kind, this.renderId = renderId, this.layer = layer;
494
494
  }
495
495
  get rootModule() {
496
496
  return this.modules.find((item)=>item.path === this.path);
@@ -667,10 +667,10 @@ class Module {
667
667
  return this.concatenationModules.slice();
668
668
  }
669
669
  toData(contextPath, isBrief) {
670
- let { isPreferSource } = this, moduleName = getModuleName(this.webpackId), data = {
670
+ let { isPreferSource } = this, moduleName = getModuleName(this.identifier), data = {
671
671
  id: this.id,
672
672
  renderId: this.renderId,
673
- webpackId: contextPath && moduleName.indexOf('.') > 0 ? external_path_default().relative(contextPath, moduleName) : this.webpackId,
673
+ identifier: contextPath && moduleName.indexOf('.') > 0 ? external_path_default().relative(contextPath, moduleName) : this.identifier,
674
674
  path: this.path,
675
675
  isPreferSource,
676
676
  dependencies: this.dependencies.map((item)=>item.id),
@@ -969,7 +969,7 @@ class ModuleGraph {
969
969
  return ModuleGraph.init(), moduleGraph;
970
970
  }
971
971
  clear() {
972
- this._dependenciesIdMap = new Map(), this._moduleWebpackIdMap = new Map(), this._moduleIdMap = new Map(), this._moduleGraphModules = new Map(), this._exportIdMap = new Map(), this._sideEffectIdMap = new Map(), this._varIdMap = new Map(), this._layers = new Map();
972
+ this._dependenciesIdMap = new Map(), this._moduleIdentifierMap = new Map(), this._moduleIdMap = new Map(), this._moduleGraphModules = new Map(), this._exportIdMap = new Map(), this._sideEffectIdMap = new Map(), this._varIdMap = new Map(), this._layers = new Map();
973
973
  }
974
974
  size() {
975
975
  return this._moduleIdMap.size;
@@ -986,7 +986,7 @@ class ModuleGraph {
986
986
  return result;
987
987
  }
988
988
  getModules() {
989
- return Array.from(this._moduleWebpackIdMap.values());
989
+ return Array.from(this._moduleIdentifierMap.values());
990
990
  }
991
991
  getDependencies() {
992
992
  return Array.from(this._dependenciesIdMap.values());
@@ -1000,20 +1000,20 @@ class ModuleGraph {
1000
1000
  getDependencyById(id) {
1001
1001
  return this._dependenciesIdMap.get(id);
1002
1002
  }
1003
- getModuleByWebpackId(id) {
1004
- return this._moduleWebpackIdMap.get(id);
1003
+ getModuleByIdentifier(id) {
1004
+ return this._moduleIdentifierMap.get(id);
1005
1005
  }
1006
1006
  getModuleByFile(file, layer) {
1007
1007
  return this.getModules().filter((item)=>item.path === file && (void 0 === layer || item.layer === layer));
1008
1008
  }
1009
1009
  addModule(...modules) {
1010
- for (let module of modules)!this._moduleIdMap.has(module.id) && (this._moduleWebpackIdMap.set(module.webpackId, module), this._moduleIdMap.set(module.id, module), module.layer && this.addLayer(module.layer));
1010
+ for (let module of modules)!this._moduleIdMap.has(module.id) && (this._moduleIdentifierMap.set(module.identifier, module), this._moduleIdMap.set(module.id, module), module.layer && this.addLayer(module.layer));
1011
1011
  }
1012
1012
  addDependency(...deps) {
1013
1013
  for (let dep of deps)this._dependenciesIdMap.has(dep.id) || (this._dependenciesIdMap.set(dep.id, dep), this.addModule(dep.module), this.addModule(dep.dependency));
1014
1014
  }
1015
1015
  removeModule(module) {
1016
- for (let dep of (this._moduleIdMap.delete(module.id), this._moduleWebpackIdMap.delete(module.webpackId), module.getDependencies()))this.removeDependency(dep), this._dependenciesIdMap.delete(dep.id);
1016
+ for (let dep of (this._moduleIdMap.delete(module.id), this._moduleIdentifierMap.delete(module.identifier), module.getDependencies()))this.removeDependency(dep), this._dependenciesIdMap.delete(dep.id);
1017
1017
  for (let imported of module.getImported())imported.removeDependencyByModule(imported);
1018
1018
  }
1019
1019
  removeDependency(dep) {
@@ -1075,8 +1075,8 @@ class ModuleGraph {
1075
1075
  this._moduleIdMap = new Map(modules.map((m)=>[
1076
1076
  m.id,
1077
1077
  m
1078
- ])), this._moduleWebpackIdMap = new Map(modules.map((m)=>[
1079
- m.webpackId,
1078
+ ])), this._moduleIdentifierMap = new Map(modules.map((m)=>[
1079
+ m.identifier,
1080
1080
  m
1081
1081
  ])), this._layers = new Map(modules.filter((m)=>m.layer).map((m)=>[
1082
1082
  m.layer,
@@ -1096,7 +1096,7 @@ class ModuleGraph {
1096
1096
  return this._connectionsOnlyImports;
1097
1097
  }
1098
1098
  constructor(){
1099
- this._dependenciesIdMap = new Map(), this._connectionsOnlyImports = [], this._moduleWebpackIdMap = new Map(), this._moduleIdMap = new Map(), this._moduleGraphModules = new Map(), this._exportIdMap = new Map(), this._sideEffectIdMap = new Map(), this._varIdMap = new Map(), this._layers = new Map();
1099
+ this._dependenciesIdMap = new Map(), this._connectionsOnlyImports = [], this._moduleIdentifierMap = new Map(), this._moduleIdMap = new Map(), this._moduleGraphModules = new Map(), this._exportIdMap = new Map(), this._sideEffectIdMap = new Map(), this._varIdMap = new Map(), this._layers = new Map();
1100
1100
  }
1101
1101
  }
1102
1102
  let package_graph_dependency_id = 1;
@@ -1338,7 +1338,7 @@ async function getAssetsModulesData(moduleGraph, chunkGraph, bundleDir, opts, so
1338
1338
  }
1339
1339
  function transformAssetsModulesData(parsedModulesData, moduleGraph) {
1340
1340
  moduleGraph && Object.entries(parsedModulesData).forEach(([moduleId, parsedData])=>{
1341
- let gzipSize, module = moduleGraph.getModuleByWebpackId(moduleId ?? '');
1341
+ let gzipSize, module = moduleGraph.getModuleByIdentifier(moduleId ?? '');
1342
1342
  try {
1343
1343
  parsedData?.content && 'string' == typeof parsedData.content && parsedData.content.length > 0 && (gzipSize = (0, external_node_zlib_namespaceObject.gzipSync)(parsedData.content, {
1344
1344
  level: 9
@@ -1464,7 +1464,7 @@ function getModuleGraphByStats({ modules, chunks }, root, chunkGraph) {
1464
1464
  ModuleGraph.init();
1465
1465
  let moduleGraph = new ModuleGraph(), allModules = [], collectedModules = [];
1466
1466
  for (let data of (getModulesFromArray(modules ?? [], collectedModules), getModulesFromChunks(chunks ?? [], collectedModules), collectedModules ?? [])){
1467
- if (getCanSkip(data) || moduleGraph.getModuleByWebpackId(data.identifier)) continue;
1467
+ if (getCanSkip(data) || moduleGraph.getModuleByIdentifier(data.identifier)) continue;
1468
1468
  allModules.push(data);
1469
1469
  let isConcatenated = !!(data.modules && data.modules.length > 0), concatenatedModule = new Module(data.identifier ?? data.moduleIdentifier, getGetModuleName(root, data), 0 === data.depth, isConcatenated ? types_namespaceObject.SDK.ModuleKind.Concatenation : types_namespaceObject.SDK.ModuleKind.Normal, data.id ? String(data.id) : void 0, data.layer);
1470
1470
  if (data.optimizationBailout && data.optimizationBailout.forEach((reason)=>concatenatedModule.addBailoutReason(reason)), data.issuerPath && concatenatedModule.addIssuerPath(data.issuerPath), data.chunks?.forEach((_chunkId)=>{
@@ -1487,8 +1487,8 @@ function getModuleGraphByStats({ modules, chunks }, root, chunkGraph) {
1487
1487
  let normalModule;
1488
1488
  if (getCanSkip(normal)) continue;
1489
1489
  allModules.push(normal);
1490
- let webpackId = normal.identifier, registeredModule = moduleGraph.getModuleByWebpackId(webpackId);
1491
- if (normalModule = registeredModule || (moduleGraph.getModuleByWebpackId(webpackId) ?? new Module(webpackId, getGetModuleName(root, normal), 0 === normal.depth, types_namespaceObject.SDK.ModuleKind.Normal, normal.id ? String(normal.id) : void 0, normal.layer)), normal.optimizationBailout && normal.optimizationBailout.filter((reason)=>!reason.includes('ModuleConcatenation bailout')).forEach((reason)=>normalModule.addBailoutReason(reason)), normal.issuerPath && normalModule.addIssuerPath(normal.issuerPath), normal.chunks?.length ? normal.chunks?.forEach((_chunkId)=>{
1490
+ let identifier = normal.identifier, registeredModule = moduleGraph.getModuleByIdentifier(identifier);
1491
+ if (normalModule = registeredModule || (moduleGraph.getModuleByIdentifier(identifier) ?? new Module(identifier, getGetModuleName(root, normal), 0 === normal.depth, types_namespaceObject.SDK.ModuleKind.Normal, normal.id ? String(normal.id) : void 0, normal.layer)), normal.optimizationBailout && normal.optimizationBailout.filter((reason)=>!reason.includes('ModuleConcatenation bailout')).forEach((reason)=>normalModule.addBailoutReason(reason)), normal.issuerPath && normalModule.addIssuerPath(normal.issuerPath), normal.chunks?.length ? normal.chunks?.forEach((_chunkId)=>{
1492
1492
  let chunk = chunkGraph.getChunkById(String(_chunkId));
1493
1493
  chunk && normalModule.addChunk(chunk);
1494
1494
  }) : data.chunks?.forEach((_chunkId)=>{
@@ -1511,7 +1511,7 @@ function getModuleGraphByStats({ modules, chunks }, root, chunkGraph) {
1511
1511
  }
1512
1512
  }
1513
1513
  for (let module of allModules){
1514
- let currentModule = moduleGraph.getModuleByWebpackId(module.identifier ?? '');
1514
+ let currentModule = moduleGraph.getModuleByIdentifier(module.identifier ?? '');
1515
1515
  if (!currentModule) continue;
1516
1516
  let dependencies = (module.reasons ?? []).filter(isImportDependency).filter((item)=>!!(item.moduleIdentifier && item.userRequest));
1517
1517
  for (let dep of ((module.reasons ?? []).filter((item)=>'from origin' === item.type).forEach((dep)=>dep?.children?.forEach((_d)=>dependencies.push({
@@ -1519,7 +1519,7 @@ function getModuleGraphByStats({ modules, chunks }, root, chunkGraph) {
1519
1519
  ..._d,
1520
1520
  children: void 0
1521
1521
  }))), dependencies)){
1522
- let rawRequest = dep.userRequest, requestModule = moduleGraph.getModuleByWebpackId(dep.moduleIdentifier);
1522
+ let rawRequest = dep.userRequest, requestModule = moduleGraph.getModuleByIdentifier(dep.moduleIdentifier);
1523
1523
  if (!requestModule) continue;
1524
1524
  if (!requestModule.getDependencyByRequest(rawRequest)) {
1525
1525
  let data = requestModule.addDependency(rawRequest, currentModule, getImportKind(dep));
@@ -1538,7 +1538,7 @@ function getModuleGraphByStats({ modules, chunks }, root, chunkGraph) {
1538
1538
  return moduleGraph.getModules().forEach((module)=>{
1539
1539
  module.issuerPath && module.issuerPath.forEach((issuer)=>{
1540
1540
  let moduleInstance = moduleCache.get(issuer.identifier);
1541
- !moduleInstance && (moduleInstance = moduleGraph.getModuleByWebpackId(issuer.identifier)) && moduleCache.set(issuer.identifier, moduleInstance), moduleInstance && (issuer.moduleId = moduleInstance.id);
1541
+ !moduleInstance && (moduleInstance = moduleGraph.getModuleByIdentifier(issuer.identifier)) && moduleCache.set(issuer.identifier, moduleInstance), moduleInstance && (issuer.moduleId = moduleInstance.id);
1542
1542
  });
1543
1543
  }), moduleGraph;
1544
1544
  }
@@ -1604,7 +1604,7 @@ function getExportStatement(info, normalModule, graph) {
1604
1604
  if (!webpackDependency) return;
1605
1605
  let modulePath = getWebpackModulePath(normalModule), request = getWebpackDependencyRequest(webpackDependency), sdkDependency = graph.getDependencies().find((item)=>item.module.path === modulePath && item.request === request);
1606
1606
  if (sdkDependency && 1 === sdkDependency.statements.length) return sdkDependency.statements[0];
1607
- let sdkModule = graph.getModuleByWebpackId(getWebpackModuleId(normalModule));
1607
+ let sdkModule = graph.getModuleByIdentifier(getWebpackModuleId(normalModule));
1608
1608
  if (sdkModule) return getDependencyPosition(webpackDependency, sdkModule);
1609
1609
  }
1610
1610
  function getLastExportInfo(info, webpackGraph) {
package/dist/index.js CHANGED
@@ -445,7 +445,7 @@ class Module {
445
445
  static init() {
446
446
  module_id = 1;
447
447
  }
448
- constructor(webpackId, path, isEntry = !1, kind = SDK.ModuleKind.Normal, renderId, layer = ''){
448
+ constructor(identifier, path, isEntry = !1, kind = SDK.ModuleKind.Normal, renderId, layer = ''){
449
449
  this.issuerPath = [], this.bailoutReason = [], this.sideEffectLocations = [], this.sideEffectCodes = [], this.source = {
450
450
  source: '',
451
451
  transformed: '',
@@ -458,7 +458,7 @@ class Module {
458
458
  }, this.chunks = [], this.dependencies = [], this.imported = [], this.modules = [], this.concatenationModules = [], this.meta = {
459
459
  hasSetEsModuleStatement: !1,
460
460
  strictHarmonyModule: !1
461
- }, this.id = module_id++, this.webpackId = webpackId, this.path = path, this.isEntry = isEntry, this.kind = kind, this.renderId = renderId, this.layer = layer;
461
+ }, this.id = module_id++, this.identifier = identifier, this.path = path, this.isEntry = isEntry, this.kind = kind, this.renderId = renderId, this.layer = layer;
462
462
  }
463
463
  get rootModule() {
464
464
  return this.modules.find((item)=>item.path === this.path);
@@ -635,10 +635,10 @@ class Module {
635
635
  return this.concatenationModules.slice();
636
636
  }
637
637
  toData(contextPath, isBrief) {
638
- let { isPreferSource } = this, moduleName = getModuleName(this.webpackId), data = {
638
+ let { isPreferSource } = this, moduleName = getModuleName(this.identifier), data = {
639
639
  id: this.id,
640
640
  renderId: this.renderId,
641
- webpackId: contextPath && moduleName.indexOf('.') > 0 ? path_0.relative(contextPath, moduleName) : this.webpackId,
641
+ identifier: contextPath && moduleName.indexOf('.') > 0 ? path_0.relative(contextPath, moduleName) : this.identifier,
642
642
  path: this.path,
643
643
  isPreferSource,
644
644
  dependencies: this.dependencies.map((item)=>item.id),
@@ -937,7 +937,7 @@ class ModuleGraph {
937
937
  return ModuleGraph.init(), moduleGraph;
938
938
  }
939
939
  clear() {
940
- this._dependenciesIdMap = new Map(), this._moduleWebpackIdMap = new Map(), this._moduleIdMap = new Map(), this._moduleGraphModules = new Map(), this._exportIdMap = new Map(), this._sideEffectIdMap = new Map(), this._varIdMap = new Map(), this._layers = new Map();
940
+ this._dependenciesIdMap = new Map(), this._moduleIdentifierMap = new Map(), this._moduleIdMap = new Map(), this._moduleGraphModules = new Map(), this._exportIdMap = new Map(), this._sideEffectIdMap = new Map(), this._varIdMap = new Map(), this._layers = new Map();
941
941
  }
942
942
  size() {
943
943
  return this._moduleIdMap.size;
@@ -954,7 +954,7 @@ class ModuleGraph {
954
954
  return result;
955
955
  }
956
956
  getModules() {
957
- return Array.from(this._moduleWebpackIdMap.values());
957
+ return Array.from(this._moduleIdentifierMap.values());
958
958
  }
959
959
  getDependencies() {
960
960
  return Array.from(this._dependenciesIdMap.values());
@@ -968,20 +968,20 @@ class ModuleGraph {
968
968
  getDependencyById(id) {
969
969
  return this._dependenciesIdMap.get(id);
970
970
  }
971
- getModuleByWebpackId(id) {
972
- return this._moduleWebpackIdMap.get(id);
971
+ getModuleByIdentifier(id) {
972
+ return this._moduleIdentifierMap.get(id);
973
973
  }
974
974
  getModuleByFile(file, layer) {
975
975
  return this.getModules().filter((item)=>item.path === file && (void 0 === layer || item.layer === layer));
976
976
  }
977
977
  addModule(...modules) {
978
- for (let module of modules)!this._moduleIdMap.has(module.id) && (this._moduleWebpackIdMap.set(module.webpackId, module), this._moduleIdMap.set(module.id, module), module.layer && this.addLayer(module.layer));
978
+ for (let module of modules)!this._moduleIdMap.has(module.id) && (this._moduleIdentifierMap.set(module.identifier, module), this._moduleIdMap.set(module.id, module), module.layer && this.addLayer(module.layer));
979
979
  }
980
980
  addDependency(...deps) {
981
981
  for (let dep of deps)this._dependenciesIdMap.has(dep.id) || (this._dependenciesIdMap.set(dep.id, dep), this.addModule(dep.module), this.addModule(dep.dependency));
982
982
  }
983
983
  removeModule(module) {
984
- for (let dep of (this._moduleIdMap.delete(module.id), this._moduleWebpackIdMap.delete(module.webpackId), module.getDependencies()))this.removeDependency(dep), this._dependenciesIdMap.delete(dep.id);
984
+ for (let dep of (this._moduleIdMap.delete(module.id), this._moduleIdentifierMap.delete(module.identifier), module.getDependencies()))this.removeDependency(dep), this._dependenciesIdMap.delete(dep.id);
985
985
  for (let imported of module.getImported())imported.removeDependencyByModule(imported);
986
986
  }
987
987
  removeDependency(dep) {
@@ -1043,8 +1043,8 @@ class ModuleGraph {
1043
1043
  this._moduleIdMap = new Map(modules.map((m)=>[
1044
1044
  m.id,
1045
1045
  m
1046
- ])), this._moduleWebpackIdMap = new Map(modules.map((m)=>[
1047
- m.webpackId,
1046
+ ])), this._moduleIdentifierMap = new Map(modules.map((m)=>[
1047
+ m.identifier,
1048
1048
  m
1049
1049
  ])), this._layers = new Map(modules.filter((m)=>m.layer).map((m)=>[
1050
1050
  m.layer,
@@ -1064,7 +1064,7 @@ class ModuleGraph {
1064
1064
  return this._connectionsOnlyImports;
1065
1065
  }
1066
1066
  constructor(){
1067
- this._dependenciesIdMap = new Map(), this._connectionsOnlyImports = [], this._moduleWebpackIdMap = new Map(), this._moduleIdMap = new Map(), this._moduleGraphModules = new Map(), this._exportIdMap = new Map(), this._sideEffectIdMap = new Map(), this._varIdMap = new Map(), this._layers = new Map();
1067
+ this._dependenciesIdMap = new Map(), this._connectionsOnlyImports = [], this._moduleIdentifierMap = new Map(), this._moduleIdMap = new Map(), this._moduleGraphModules = new Map(), this._exportIdMap = new Map(), this._sideEffectIdMap = new Map(), this._varIdMap = new Map(), this._layers = new Map();
1068
1068
  }
1069
1069
  }
1070
1070
  let package_graph_dependency_id = 1;
@@ -1301,7 +1301,7 @@ async function getAssetsModulesData(moduleGraph, chunkGraph, bundleDir, opts, so
1301
1301
  }
1302
1302
  function transformAssetsModulesData(parsedModulesData, moduleGraph) {
1303
1303
  moduleGraph && Object.entries(parsedModulesData).forEach(([moduleId, parsedData])=>{
1304
- let gzipSize, module = moduleGraph.getModuleByWebpackId(moduleId ?? '');
1304
+ let gzipSize, module = moduleGraph.getModuleByIdentifier(moduleId ?? '');
1305
1305
  try {
1306
1306
  parsedData?.content && 'string' == typeof parsedData.content && parsedData.content.length > 0 && (gzipSize = gzipSync(parsedData.content, {
1307
1307
  level: 9
@@ -1420,7 +1420,7 @@ function getModuleGraphByStats({ modules, chunks }, root, chunkGraph) {
1420
1420
  name: module.name ?? module.moduleName
1421
1421
  })));
1422
1422
  }), collectedModules ?? [])){
1423
- if (getCanSkip(data) || moduleGraph.getModuleByWebpackId(data.identifier)) continue;
1423
+ if (getCanSkip(data) || moduleGraph.getModuleByIdentifier(data.identifier)) continue;
1424
1424
  allModules.push(data);
1425
1425
  let isConcatenated = !!(data.modules && data.modules.length > 0), concatenatedModule = new Module(data.identifier ?? data.moduleIdentifier, getGetModuleName(root, data), 0 === data.depth, isConcatenated ? SDK.ModuleKind.Concatenation : SDK.ModuleKind.Normal, data.id ? String(data.id) : void 0, data.layer);
1426
1426
  if (data.optimizationBailout && data.optimizationBailout.forEach((reason)=>concatenatedModule.addBailoutReason(reason)), data.issuerPath && concatenatedModule.addIssuerPath(data.issuerPath), data.chunks?.forEach((_chunkId)=>{
@@ -1443,8 +1443,8 @@ function getModuleGraphByStats({ modules, chunks }, root, chunkGraph) {
1443
1443
  let normalModule;
1444
1444
  if (getCanSkip(normal)) continue;
1445
1445
  allModules.push(normal);
1446
- let webpackId = normal.identifier, registeredModule = moduleGraph.getModuleByWebpackId(webpackId);
1447
- if (normalModule = registeredModule || (moduleGraph.getModuleByWebpackId(webpackId) ?? new Module(webpackId, getGetModuleName(root, normal), 0 === normal.depth, SDK.ModuleKind.Normal, normal.id ? String(normal.id) : void 0, normal.layer)), normal.optimizationBailout && normal.optimizationBailout.filter((reason)=>!reason.includes('ModuleConcatenation bailout')).forEach((reason)=>normalModule.addBailoutReason(reason)), normal.issuerPath && normalModule.addIssuerPath(normal.issuerPath), normal.chunks?.length ? normal.chunks?.forEach((_chunkId)=>{
1446
+ let identifier = normal.identifier, registeredModule = moduleGraph.getModuleByIdentifier(identifier);
1447
+ if (normalModule = registeredModule || (moduleGraph.getModuleByIdentifier(identifier) ?? new Module(identifier, getGetModuleName(root, normal), 0 === normal.depth, SDK.ModuleKind.Normal, normal.id ? String(normal.id) : void 0, normal.layer)), normal.optimizationBailout && normal.optimizationBailout.filter((reason)=>!reason.includes('ModuleConcatenation bailout')).forEach((reason)=>normalModule.addBailoutReason(reason)), normal.issuerPath && normalModule.addIssuerPath(normal.issuerPath), normal.chunks?.length ? normal.chunks?.forEach((_chunkId)=>{
1448
1448
  let chunk = chunkGraph.getChunkById(String(_chunkId));
1449
1449
  chunk && normalModule.addChunk(chunk);
1450
1450
  }) : data.chunks?.forEach((_chunkId)=>{
@@ -1467,7 +1467,7 @@ function getModuleGraphByStats({ modules, chunks }, root, chunkGraph) {
1467
1467
  }
1468
1468
  }
1469
1469
  for (let module of allModules){
1470
- let currentModule = moduleGraph.getModuleByWebpackId(module.identifier ?? '');
1470
+ let currentModule = moduleGraph.getModuleByIdentifier(module.identifier ?? '');
1471
1471
  if (!currentModule) continue;
1472
1472
  let dependencies = (module.reasons ?? []).filter(isImportDependency).filter((item)=>!!(item.moduleIdentifier && item.userRequest));
1473
1473
  for (let dep of ((module.reasons ?? []).filter((item)=>'from origin' === item.type).forEach((dep)=>dep?.children?.forEach((_d)=>dependencies.push({
@@ -1475,7 +1475,7 @@ function getModuleGraphByStats({ modules, chunks }, root, chunkGraph) {
1475
1475
  ..._d,
1476
1476
  children: void 0
1477
1477
  }))), dependencies)){
1478
- let rawRequest = dep.userRequest, requestModule = moduleGraph.getModuleByWebpackId(dep.moduleIdentifier);
1478
+ let rawRequest = dep.userRequest, requestModule = moduleGraph.getModuleByIdentifier(dep.moduleIdentifier);
1479
1479
  if (!requestModule) continue;
1480
1480
  if (!requestModule.getDependencyByRequest(rawRequest)) {
1481
1481
  let data = requestModule.addDependency(rawRequest, currentModule, getImportKind(dep));
@@ -1494,7 +1494,7 @@ function getModuleGraphByStats({ modules, chunks }, root, chunkGraph) {
1494
1494
  return moduleGraph.getModules().forEach((module)=>{
1495
1495
  module.issuerPath && module.issuerPath.forEach((issuer)=>{
1496
1496
  let moduleInstance = moduleCache.get(issuer.identifier);
1497
- !moduleInstance && (moduleInstance = moduleGraph.getModuleByWebpackId(issuer.identifier)) && moduleCache.set(issuer.identifier, moduleInstance), moduleInstance && (issuer.moduleId = moduleInstance.id);
1497
+ !moduleInstance && (moduleInstance = moduleGraph.getModuleByIdentifier(issuer.identifier)) && moduleCache.set(issuer.identifier, moduleInstance), moduleInstance && (issuer.moduleId = moduleInstance.id);
1498
1498
  });
1499
1499
  }), moduleGraph;
1500
1500
  }
@@ -1560,7 +1560,7 @@ function getExportStatement(info, normalModule, graph) {
1560
1560
  if (!webpackDependency) return;
1561
1561
  let modulePath = getWebpackModulePath(normalModule), request = getWebpackDependencyRequest(webpackDependency), sdkDependency = graph.getDependencies().find((item)=>item.module.path === modulePath && item.request === request);
1562
1562
  if (sdkDependency && 1 === sdkDependency.statements.length) return sdkDependency.statements[0];
1563
- let sdkModule = graph.getModuleByWebpackId(getWebpackModuleId(normalModule));
1563
+ let sdkModule = graph.getModuleByIdentifier(getWebpackModuleId(normalModule));
1564
1564
  if (sdkModule) return getDependencyPosition(webpackDependency, sdkModule);
1565
1565
  }
1566
1566
  function getLastExportInfo(info, webpackGraph) {
@@ -1,5 +1,5 @@
1
1
  import { SDK } from '@rsdoctor/types';
2
- export type ParseBundle = (assetFile: string, modules: Pick<SDK.ModuleInstance, 'renderId' | 'webpackId'>[]) => {
2
+ export type ParseBundle = (assetFile: string, modules: Pick<SDK.ModuleInstance, 'renderId' | 'identifier'>[]) => {
3
3
  modules?: Record<string, any>;
4
4
  src?: string;
5
5
  runtimeSrc?: string;
@@ -1,5 +1,5 @@
1
1
  import { SDK } from '@rsdoctor/types';
2
- export type ParseBundle = (assetFile: string, modules: Pick<SDK.ModuleInstance, 'renderId' | 'webpackId'>[]) => {
2
+ export type ParseBundle = (assetFile: string, modules: Pick<SDK.ModuleInstance, 'renderId' | 'identifier'>[]) => {
3
3
  modules?: Record<string, any>;
4
4
  src?: string;
5
5
  runtimeSrc?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdoctor/graph",
3
- "version": "1.5.12",
3
+ "version": "2.0.0-alpha.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/web-infra-dev/rsdoctor",
@@ -30,8 +30,8 @@
30
30
  "es-toolkit": "^1.45.1",
31
31
  "path-browserify": "1.0.1",
32
32
  "source-map": "^0.7.6",
33
- "@rsdoctor/types": "1.5.12",
34
- "@rsdoctor/utils": "1.5.12"
33
+ "@rsdoctor/types": "2.0.0-alpha.0",
34
+ "@rsdoctor/utils": "2.0.0-alpha.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/body-parser": "1.19.6",