@rsdoctor/graph 0.0.2-beta.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.
Files changed (81) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +15 -0
  3. package/dist/cjs/graph/chunk-graph/asset.js +44 -0
  4. package/dist/cjs/graph/chunk-graph/chunk.js +105 -0
  5. package/dist/cjs/graph/chunk-graph/entrypoint.js +52 -0
  6. package/dist/cjs/graph/chunk-graph/graph.js +88 -0
  7. package/dist/cjs/graph/chunk-graph/index.js +28 -0
  8. package/dist/cjs/graph/index.js +26 -0
  9. package/dist/cjs/graph/module-graph/dependency.js +91 -0
  10. package/dist/cjs/graph/module-graph/graph.js +354 -0
  11. package/dist/cjs/graph/module-graph/index.js +32 -0
  12. package/dist/cjs/graph/module-graph/module.js +284 -0
  13. package/dist/cjs/graph/module-graph/statement.js +82 -0
  14. package/dist/cjs/graph/module-graph/tree-shaking/export.js +107 -0
  15. package/dist/cjs/graph/module-graph/tree-shaking/index.js +30 -0
  16. package/dist/cjs/graph/module-graph/tree-shaking/module.js +98 -0
  17. package/dist/cjs/graph/module-graph/tree-shaking/sideEffect.js +94 -0
  18. package/dist/cjs/graph/module-graph/tree-shaking/types.js +16 -0
  19. package/dist/cjs/graph/module-graph/tree-shaking/variable.js +63 -0
  20. package/dist/cjs/graph/module-graph/types.js +16 -0
  21. package/dist/cjs/graph/module-graph/utils.js +65 -0
  22. package/dist/cjs/graph/package-graph/dependency.js +56 -0
  23. package/dist/cjs/graph/package-graph/graph.js +173 -0
  24. package/dist/cjs/graph/package-graph/index.js +28 -0
  25. package/dist/cjs/graph/package-graph/package.js +121 -0
  26. package/dist/cjs/graph/package-graph/types.js +16 -0
  27. package/dist/cjs/graph/package-graph/utils.js +30 -0
  28. package/dist/cjs/index.js +22 -0
  29. package/dist/esm/graph/chunk-graph/asset.js +20 -0
  30. package/dist/esm/graph/chunk-graph/chunk.js +81 -0
  31. package/dist/esm/graph/chunk-graph/entrypoint.js +28 -0
  32. package/dist/esm/graph/chunk-graph/graph.js +64 -0
  33. package/dist/esm/graph/chunk-graph/index.js +4 -0
  34. package/dist/esm/graph/index.js +3 -0
  35. package/dist/esm/graph/module-graph/dependency.js +67 -0
  36. package/dist/esm/graph/module-graph/graph.js +335 -0
  37. package/dist/esm/graph/module-graph/index.js +6 -0
  38. package/dist/esm/graph/module-graph/module.js +250 -0
  39. package/dist/esm/graph/module-graph/statement.js +58 -0
  40. package/dist/esm/graph/module-graph/tree-shaking/export.js +83 -0
  41. package/dist/esm/graph/module-graph/tree-shaking/index.js +5 -0
  42. package/dist/esm/graph/module-graph/tree-shaking/module.js +74 -0
  43. package/dist/esm/graph/module-graph/tree-shaking/sideEffect.js +70 -0
  44. package/dist/esm/graph/module-graph/tree-shaking/types.js +0 -0
  45. package/dist/esm/graph/module-graph/tree-shaking/variable.js +39 -0
  46. package/dist/esm/graph/module-graph/types.js +0 -0
  47. package/dist/esm/graph/module-graph/utils.js +39 -0
  48. package/dist/esm/graph/package-graph/dependency.js +32 -0
  49. package/dist/esm/graph/package-graph/graph.js +149 -0
  50. package/dist/esm/graph/package-graph/index.js +4 -0
  51. package/dist/esm/graph/package-graph/package.js +97 -0
  52. package/dist/esm/graph/package-graph/types.js +0 -0
  53. package/dist/esm/graph/package-graph/utils.js +6 -0
  54. package/dist/esm/index.js +1 -0
  55. package/dist/type/graph/chunk-graph/asset.d.ts +10 -0
  56. package/dist/type/graph/chunk-graph/chunk.d.ts +30 -0
  57. package/dist/type/graph/chunk-graph/entrypoint.d.ts +12 -0
  58. package/dist/type/graph/chunk-graph/graph.d.ts +22 -0
  59. package/dist/type/graph/chunk-graph/index.d.ts +4 -0
  60. package/dist/type/graph/index.d.ts +3 -0
  61. package/dist/type/graph/module-graph/dependency.d.ts +25 -0
  62. package/dist/type/graph/module-graph/graph.d.ts +38 -0
  63. package/dist/type/graph/module-graph/index.d.ts +6 -0
  64. package/dist/type/graph/module-graph/module.d.ts +64 -0
  65. package/dist/type/graph/module-graph/statement.d.ts +12 -0
  66. package/dist/type/graph/module-graph/tree-shaking/export.d.ts +22 -0
  67. package/dist/type/graph/module-graph/tree-shaking/index.d.ts +5 -0
  68. package/dist/type/graph/module-graph/tree-shaking/module.d.ts +28 -0
  69. package/dist/type/graph/module-graph/tree-shaking/sideEffect.d.ts +27 -0
  70. package/dist/type/graph/module-graph/tree-shaking/types.d.ts +5 -0
  71. package/dist/type/graph/module-graph/tree-shaking/variable.d.ts +18 -0
  72. package/dist/type/graph/module-graph/types.d.ts +12 -0
  73. package/dist/type/graph/module-graph/utils.d.ts +4 -0
  74. package/dist/type/graph/package-graph/dependency.d.ts +15 -0
  75. package/dist/type/graph/package-graph/graph.d.ts +25 -0
  76. package/dist/type/graph/package-graph/index.d.ts +4 -0
  77. package/dist/type/graph/package-graph/package.d.ts +25 -0
  78. package/dist/type/graph/package-graph/types.d.ts +6 -0
  79. package/dist/type/graph/package-graph/utils.d.ts +1 -0
  80. package/dist/type/index.d.ts +1 -0
  81. package/package.json +42 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-present Bytedance, Inc. and its affiliates.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # Rsdoctor
2
+
3
+ Rsdoctor is a tool for diagnosing and analyzing the build process and build artifacts to help developers quickly identify and solve problems.
4
+
5
+ It also supports Webpack and Rspack builders, as well as various build frameworks, such as Rsbuild.
6
+
7
+ ## Documentation
8
+
9
+ ## Contributing
10
+
11
+ Please read the [Contributing Guide](https://github.com/web-infra-dev/rsdoctor/blob/main/CONTRIBUTING.md).
12
+
13
+ ## License
14
+
15
+ Rsdoctor is [MIT licensed](https://github.com/web-infra-dev/rsdoctor/blob/main/LICENSE).
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var asset_exports = {};
20
+ __export(asset_exports, {
21
+ Asset: () => Asset
22
+ });
23
+ module.exports = __toCommonJS(asset_exports);
24
+ var import_types = require("@rsdoctor/types");
25
+ class Asset {
26
+ constructor(path, size, chunks, content) {
27
+ this.path = path;
28
+ this.size = size;
29
+ this.chunks = chunks;
30
+ this.content = content;
31
+ }
32
+ toData(types) {
33
+ return {
34
+ path: this.path,
35
+ size: this.size,
36
+ chunks: this.chunks?.map((ck) => ck.id),
37
+ content: types === import_types.SDK.ToDataType.LiteAndNoAsset ? "" : this.content
38
+ };
39
+ }
40
+ }
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ Asset
44
+ });
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var chunk_exports = {};
20
+ __export(chunk_exports, {
21
+ Chunk: () => Chunk
22
+ });
23
+ module.exports = __toCommonJS(chunk_exports);
24
+ class Chunk {
25
+ constructor(id, name, size, initial, entry) {
26
+ this._assets = [];
27
+ this._modules = [];
28
+ this._dependencies = [];
29
+ this._imported = [];
30
+ this.id = id;
31
+ this.name = name;
32
+ this.size = size;
33
+ this.initial = initial;
34
+ this.entry = entry;
35
+ }
36
+ isEntry() {
37
+ return this.entry;
38
+ }
39
+ isChunkEntryModule(module2) {
40
+ return module2.isEntry || module2.getImported().every((item) => !this.hasModule(item));
41
+ }
42
+ hasModule(module2) {
43
+ return this._modules.includes(module2);
44
+ }
45
+ addModule(module2) {
46
+ if (!this.hasModule(module2)) {
47
+ this._modules.push(module2);
48
+ module2.addChunk(this);
49
+ }
50
+ }
51
+ addAsset(asset) {
52
+ this._assets.push(asset);
53
+ }
54
+ addModules(modules) {
55
+ modules.forEach((module2) => {
56
+ if (!this.hasModule(module2)) {
57
+ this._modules.push(module2);
58
+ module2.addChunk(this);
59
+ }
60
+ });
61
+ }
62
+ addDependency(dep) {
63
+ if (!this._dependencies.includes(dep)) {
64
+ this._dependencies.push(dep);
65
+ }
66
+ }
67
+ addImported(imported) {
68
+ if (!this._imported.includes(imported)) {
69
+ this._imported.push(imported);
70
+ }
71
+ }
72
+ getAssets() {
73
+ return this._assets.slice();
74
+ }
75
+ getModules() {
76
+ return this._modules.slice();
77
+ }
78
+ getDependencies() {
79
+ return this._dependencies.slice();
80
+ }
81
+ getImported() {
82
+ return this._imported.slice();
83
+ }
84
+ setParsedSize(parsedSize) {
85
+ this._parsedSize = parsedSize;
86
+ }
87
+ toData() {
88
+ return {
89
+ id: this.id,
90
+ name: this.name,
91
+ initial: this.initial,
92
+ size: this.size,
93
+ parsedSize: this._parsedSize || 0,
94
+ entry: this.isEntry(),
95
+ assets: this._assets.map(({ path }) => path),
96
+ modules: this._modules.map(({ id }) => id),
97
+ dependencies: this._dependencies.map(({ id }) => id),
98
+ imported: this._imported.map(({ id }) => id)
99
+ };
100
+ }
101
+ }
102
+ // Annotate the CommonJS export names for ESM import in node:
103
+ 0 && (module.exports = {
104
+ Chunk
105
+ });
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var entrypoint_exports = {};
20
+ __export(entrypoint_exports, {
21
+ EntryPoint: () => EntryPoint
22
+ });
23
+ module.exports = __toCommonJS(entrypoint_exports);
24
+ class EntryPoint {
25
+ constructor(name) {
26
+ this.name = name;
27
+ this._chunks = [];
28
+ this._assets = [];
29
+ }
30
+ addChunk(chunk) {
31
+ if (this._chunks.includes(chunk))
32
+ return;
33
+ this._chunks.push(chunk);
34
+ }
35
+ addAsset(asset) {
36
+ if (this._assets.includes(asset))
37
+ return;
38
+ this._assets.push(asset);
39
+ }
40
+ toData() {
41
+ return {
42
+ name: this.name,
43
+ chunks: this._chunks.map((e) => e.id),
44
+ assets: this._assets.map((e) => e.path),
45
+ size: this._assets.length ? this._assets.reduce((t, e) => t + e.size, 0) : 0
46
+ };
47
+ }
48
+ }
49
+ // Annotate the CommonJS export names for ESM import in node:
50
+ 0 && (module.exports = {
51
+ EntryPoint
52
+ });
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var graph_exports = {};
20
+ __export(graph_exports, {
21
+ ChunkGraph: () => ChunkGraph
22
+ });
23
+ module.exports = __toCommonJS(graph_exports);
24
+ class ChunkGraph {
25
+ constructor() {
26
+ this._assets = [];
27
+ this._chunks = [];
28
+ this._entrypoints = [];
29
+ }
30
+ getAssets() {
31
+ return this._assets.slice();
32
+ }
33
+ getChunks() {
34
+ return this._chunks.slice();
35
+ }
36
+ addAsset(...assets) {
37
+ assets.forEach((asset) => {
38
+ if (!this._assets.includes(asset)) {
39
+ this._assets.push(asset);
40
+ }
41
+ });
42
+ }
43
+ addChunk(...chunks) {
44
+ chunks.forEach((chunk) => {
45
+ if (!this._chunks.includes(chunk)) {
46
+ this._chunks.push(chunk);
47
+ }
48
+ });
49
+ }
50
+ getChunkById(id) {
51
+ return this._chunks.find((item) => item.id === id);
52
+ }
53
+ getChunkByModule(module2) {
54
+ return this._chunks.find((item) => item.hasModule(module2));
55
+ }
56
+ getAssetByPath(path) {
57
+ return this._assets.find((item) => item.path === path);
58
+ }
59
+ getAssetsByChunk(chunk) {
60
+ return this._assets.filter((item) => {
61
+ const _chunk = item.chunks.find((ck) => ck.id === chunk.id);
62
+ if (_chunk)
63
+ return true;
64
+ });
65
+ }
66
+ getEntryPoints() {
67
+ return this._entrypoints.slice();
68
+ }
69
+ addEntryPoint(...entrypoints) {
70
+ entrypoints.forEach((entrypoint) => {
71
+ if (!this._entrypoints.includes(entrypoint)) {
72
+ this._entrypoints.push(entrypoint);
73
+ }
74
+ });
75
+ }
76
+ /** output the chunk graph data */
77
+ toData(type) {
78
+ return {
79
+ assets: this._assets.map((item) => item.toData(type)),
80
+ chunks: this._chunks.map((item) => item.toData()),
81
+ entrypoints: this._entrypoints.map((item) => item.toData())
82
+ };
83
+ }
84
+ }
85
+ // Annotate the CommonJS export names for ESM import in node:
86
+ 0 && (module.exports = {
87
+ ChunkGraph
88
+ });
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var chunk_graph_exports = {};
17
+ module.exports = __toCommonJS(chunk_graph_exports);
18
+ __reExport(chunk_graph_exports, require("./chunk"), module.exports);
19
+ __reExport(chunk_graph_exports, require("./graph"), module.exports);
20
+ __reExport(chunk_graph_exports, require("./asset"), module.exports);
21
+ __reExport(chunk_graph_exports, require("./entrypoint"), module.exports);
22
+ // Annotate the CommonJS export names for ESM import in node:
23
+ 0 && (module.exports = {
24
+ ...require("./chunk"),
25
+ ...require("./graph"),
26
+ ...require("./asset"),
27
+ ...require("./entrypoint")
28
+ });
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var graph_exports = {};
17
+ module.exports = __toCommonJS(graph_exports);
18
+ __reExport(graph_exports, require("./chunk-graph"), module.exports);
19
+ __reExport(graph_exports, require("./module-graph"), module.exports);
20
+ __reExport(graph_exports, require("./package-graph"), module.exports);
21
+ // Annotate the CommonJS export names for ESM import in node:
22
+ 0 && (module.exports = {
23
+ ...require("./chunk-graph"),
24
+ ...require("./module-graph"),
25
+ ...require("./package-graph")
26
+ });
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var dependency_exports = {};
20
+ __export(dependency_exports, {
21
+ Dependency: () => Dependency
22
+ });
23
+ module.exports = __toCommonJS(dependency_exports);
24
+ var import_types = require("@rsdoctor/types");
25
+ let id = 1;
26
+ class Dependency {
27
+ constructor(request, module2, dependency, kind, statements) {
28
+ this.statements = [];
29
+ this.meta = {
30
+ exportsType: "default-with-named"
31
+ };
32
+ this.id = id++;
33
+ this.request = request;
34
+ this.module = module2;
35
+ this._originDependency = dependency;
36
+ this.kind = kind;
37
+ this.statements = statements ?? [];
38
+ }
39
+ static init() {
40
+ id = 1;
41
+ }
42
+ get resolvedRequest() {
43
+ return this.dependency.path;
44
+ }
45
+ get dependency() {
46
+ return this.originDependency.rootModule ?? this.originDependency;
47
+ }
48
+ get originDependency() {
49
+ return this._originDependency;
50
+ }
51
+ get kindString() {
52
+ return import_types.SDK.DependencyKind[this.kind];
53
+ }
54
+ get resolveConcatenationModule() {
55
+ return this.dependency.kind === import_types.SDK.ModuleKind.Concatenation;
56
+ }
57
+ isSameWithoutStatements(dep) {
58
+ return this.request === dep.request && this.kind === dep.kind && this.module.id === dep.module.id && this.dependency.id === dep.dependency.id;
59
+ }
60
+ addStatement(statement) {
61
+ if (!this.hasStatement(statement)) {
62
+ this.statements.push(statement);
63
+ }
64
+ }
65
+ hasStatement(statement) {
66
+ return this.statements.some((item) => item.isSame(statement));
67
+ }
68
+ setBuildMeta(data) {
69
+ this.meta = {
70
+ ...this.meta,
71
+ ...data
72
+ };
73
+ }
74
+ toData() {
75
+ return {
76
+ id: this.id,
77
+ request: this.request,
78
+ resolvedRequest: this.resolvedRequest,
79
+ kind: this.kind,
80
+ module: this.module.id,
81
+ dependency: this.dependency.id,
82
+ originDependency: this.originDependency.id,
83
+ statements: this.statements.map((item) => item.toData())
84
+ };
85
+ }
86
+ }
87
+ Dependency.kind = import_types.SDK.DependencyKind;
88
+ // Annotate the CommonJS export names for ESM import in node:
89
+ 0 && (module.exports = {
90
+ Dependency
91
+ });