react-native-bundle-discovery-ui 2.7.0 → 2.9.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 (38) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +12 -227
  3. package/assets/global.css +769 -53
  4. package/dist/bin.js +61 -16
  5. package/dist/client/issues.js +5 -0
  6. package/dist/client/pages/_common.js +258 -86
  7. package/dist/client/pages/_module.js +347 -0
  8. package/dist/client/pages/default.js +145 -62
  9. package/dist/client/pages/module.js +2 -309
  10. package/dist/client/pages/moduleDiff.js +76 -0
  11. package/dist/client/pages/package.js +172 -154
  12. package/dist/client/prepare.js +15 -0
  13. package/dist/client/queryHelpers.js +445 -81
  14. package/dist/client/views/{_theme.js → _colorScheme.js} +2 -9
  15. package/dist/client/views/_html.js +52 -0
  16. package/dist/client/views/codeDiff.js +66 -0
  17. package/dist/client/views/compare.js +237 -0
  18. package/dist/client/views/importGraph.js +255 -0
  19. package/dist/client/views/insights.js +80 -0
  20. package/dist/client/views/moduleOverview.js +134 -0
  21. package/dist/client/views/packageOverview.js +114 -0
  22. package/dist/client/views/persistedFilterInput.js +27 -0
  23. package/dist/client/views/reportBar.js +89 -0
  24. package/dist/client/views/treemap.js +598 -0
  25. package/dist/discoveryrc.js +26 -7
  26. package/dist/rsdoctor.js +5 -101
  27. package/dist/src-Bp8pPQrQ.js +1545 -0
  28. package/package.json +5 -3
  29. package/assets/highcharts.css +0 -1
  30. package/dist/client/_virtual/_rolldown/runtime.js +0 -37
  31. package/dist/client/views/foamtree.js +0 -103
  32. package/dist/client/views/highcharts.js +0 -33
  33. package/dist/src-BSLX-He2.js +0 -36
  34. package/vendors/foamtree.js +0 -9008
  35. package/vendors/high-contrast-dark.js +0 -1
  36. package/vendors/highcharts-exporting.js +0 -13
  37. package/vendors/highcharts-networkgraph.js +0 -1
  38. package/vendors/highcharts.js +0 -10
@@ -5,202 +5,220 @@ discovery.page.define("package", {
5
5
  data: `
6
6
  // Tmp variables
7
7
  $currentPkgName: #.id;
8
- ${require_pages__common.getPackage(`$pkg: modules.filter(=> path has "node_modules" and path has $currentPkgName)`)}[0];
9
- $copies: $pkg.pkgInstances.size() - 1;
10
- $ver: $pkg.pkgInstances[0].version;
8
+ ${require_pages__common.getPackage(`$pkg: modules.filter(=> path has "node_modules" and path.getModulesName() = $currentPkgName)`)}[0];
11
9
 
12
10
  // Return value
13
- {
14
- ...$,
15
- currentPkgHasCopies: $copies > 0,
16
- currentPkgCopiesCount: $copies,
17
- currentPkgVersion: $ver,
18
- currentPkgWithUniqVer: $pkg.pkgName + ($copies = 0 ? '@' + $ver : ''),
19
- currentPkgWithUniqVerNpm: $pkg.pkgName + ($copies = 0 ? '/v/' + $ver : ''),
11
+ {
12
+ ...$,
20
13
  currentPkg: $pkg,
21
- currentPkgInstancesWithMetadata: $pkg.pkgInstances.[metadata],
22
- currentPkgDeprecated: $pkg.pkgInstances.[metadata.deprecated],
23
- currentPkgOutdated: $pkg.pkgInstances.[metadata and not metadata.isLatest],
24
- currentPkgLatestVersion: $pkg.pkgInstances.metadata.latestVersion[0],
14
+ overview: $.packageOverview($currentPkgName),
15
+ currentPkgImportChain: $.importChain($currentPkgName),
25
16
  }
26
17
  `,
27
18
  content: [
19
+ {
20
+ view: "alert-warning",
21
+ when: "not overview",
22
+ data: "'Package ' + #.id + ' is not found in the bundle'",
23
+ },
28
24
  {
29
25
  view: "block",
26
+ when: "overview",
27
+ className: "mo-wrap",
30
28
  content: [
31
29
  {
32
- view: "h1",
33
- className: "inline-block no-margin",
34
- content: `badge: {
35
- text: $.currentPkgWithUniqVer,
36
- color: "#fffb5a",
37
- }`,
38
- },
39
- {
40
- when: "$.currentPkgCopiesCount > 0",
41
- view: "h2",
42
- className: "inline-block no-margin",
43
- content: [
44
- `badge: {
45
- text: '+' + $.currentPkgCopiesCount,
46
- postfix: $.currentPkgCopiesCount = 1 ? 'copy' : 'copies',
47
- color: "rgba(255, 0, 0, 0.35)"
48
- }`,
49
- ],
50
- },
51
- {
52
- when: "$.currentPkgDeprecated",
53
- view: "h2",
54
- className: "inline-block no-margin",
55
- content: `badge: { text: 'deprecated', color: "rgba(255, 0, 0, 0.35)" }`,
56
- },
57
- {
58
- when: "$.currentPkgOutdated",
59
- view: "h2",
60
- className: "inline-block no-margin",
61
- content: `badge: {
62
- prefix: 'latest',
63
- text: 'v' + $.currentPkgLatestVersion,
64
- color: "rgba(255, 165, 0, 0.35)"
65
- }`,
30
+ view: "package-overview",
31
+ data: "overview",
66
32
  },
67
33
  require_pages__common.getCopyToClipboardButton({
68
- textToCopy: `$.currentPkg.pkgName`,
69
- className: "m-l-0_5em",
34
+ textToCopy: "#.id",
35
+ className: "mo-copy",
70
36
  }),
71
37
  ],
72
38
  },
73
39
  {
74
- when: "$.currentPkgDeprecated",
75
40
  view: "list",
76
- data: "$.currentPkgDeprecated",
41
+ when: "overview.deprecated",
42
+ data: "overview.deprecated",
77
43
  item: {
78
44
  view: "alert-danger",
45
+ className: "m-v-8",
79
46
  content: [
80
47
  "html: '<b>Deprecated</b> '",
81
- "text: 'v' + version + (#.data.currentPkgHasCopies ? ' (' + pkgName + ')' : '') + ': '",
48
+ "text: 'v' + version + (#.data.overview.copies.size() > 1 ? ' (' + path + ')' : '') + ': '",
82
49
  "text: metadata.deprecated",
83
50
  ],
84
51
  },
85
52
  },
86
- "html: '<br>'",
87
53
  {
88
- view: "block",
89
- content: [
90
- "text: 'Links: '",
54
+ view: "tabs",
55
+ when: "overview",
56
+ name: "tabs",
57
+ className: "mo-tabs",
58
+ tabs: [
91
59
  {
92
- view: "link",
93
- external: true,
94
- data: `{ href: "https://www.npmjs.com/package/" + currentPkgWithUniqVerNpm }`,
95
- content: [
96
- "text: 'npmjs.com'",
97
- `html: '<span class="my-icon-inline my-icon-12">${require_pages__common.externalLinkHtml}</span>'`,
98
- ],
60
+ value: "files",
61
+ content: ["text:'Files '", "pill-badge: overview.filesCount"],
99
62
  },
100
- "text: ' '",
101
63
  {
102
- view: "link",
103
- external: true,
104
- data: `{ href: "https://bundlephobia.com/package/" + currentPkgWithUniqVer }`,
105
- content: [
106
- "text: 'bundlephobia.com'",
107
- `html: '<span class="my-icon-inline my-icon-12">${require_pages__common.externalLinkHtml}</span>'`,
108
- ],
64
+ value: "importers",
65
+ content: ["text:'Imported by '", "pill-badge: overview.importedBy"],
109
66
  },
110
- "text: ' '",
111
67
  {
112
- view: "link",
113
- external: true,
114
- data: `{ href: "https://packagephobia.com/result?p=" + currentPkgWithUniqVer }`,
115
- content: [
116
- "text: 'packagephobia.com'",
117
- `html: '<span class="my-icon-inline my-icon-12">${require_pages__common.externalLinkHtml}</span>'`,
118
- ],
68
+ value: "why",
69
+ when: "currentPkgImportChain",
70
+ text: "Why bundled",
119
71
  },
120
72
  {
121
- view: "link",
122
- external: true,
123
- data: `{ href: "https://bundlejs.com/?q=" + currentPkgWithUniqVer, q: currentPkgWithUniqVer }`,
124
- content: [
125
- {
126
- view: "html",
127
- data: `'<img class="bundlejs-badge-img" src="https://deno.bundlejs.com/?q=' + q + '&badge=detailed" />'`,
128
- },
129
- ],
73
+ value: "versions",
74
+ when: "overview.copies.[metadata]",
75
+ content: ["text:'Versions '", "pill-badge: overview.copies.size()"],
130
76
  },
131
77
  ],
132
- },
133
- {
134
- when: "$.currentPkgInstancesWithMetadata",
135
- view: "block",
136
- content: [
137
- "h3: 'Versions'",
138
- {
139
- view: "table",
140
- data: "$.currentPkgInstancesWithMetadata",
141
- cols: [
142
- {
143
- header: "Path",
144
- content: "text: pkgName",
145
- },
146
- {
147
- header: "Version",
148
- content: "pill-badge:{ text: 'v' + version, color: '#0af' }",
149
- },
150
- {
151
- header: "Published",
152
- data: "metadata.createdAt",
153
- content: [
154
- "text: formatDate()",
155
- "text: ' '",
156
- "pill-badge:{ text: timeAgo() }",
157
- ],
158
- },
159
- {
160
- header: "Latest",
78
+ content: {
79
+ view: "switch",
80
+ content: [
81
+ {
82
+ when: '#.tabs="files"',
83
+ content: require_pages__common.getPackageList({
84
+ data: "$.currentPkg",
85
+ itemPkgName: "text: pkgName",
86
+ showCopiesBadge: false,
87
+ expanded: true,
88
+ }),
89
+ },
90
+ {
91
+ when: '#.tabs="importers"',
92
+ content: [
93
+ {
94
+ view: "text",
95
+ className: "why-hint",
96
+ data: "'Modules outside of the package that import its files:'",
97
+ },
98
+ {
99
+ view: "list",
100
+ data: "overview.importers",
101
+ emptyText:
102
+ "Nothing imports it: the bundler loads it before the app code (e.g. polyfills)",
103
+ item: {
104
+ view: "tree",
105
+ expanded: false,
106
+ itemConfig: {
107
+ content: [
108
+ ...require_pages__common.getTreeModule(),
109
+ "pill-badge: imports.size().pluralBadge(['import', 'imports'])",
110
+ ],
111
+ children: "imports",
112
+ itemConfig: {
113
+ view: "tree-leaf",
114
+ content: require_pages__common.getTreeModule(),
115
+ },
116
+ },
117
+ },
118
+ },
119
+ ],
120
+ },
121
+ {
122
+ when: '#.tabs="why"',
123
+ content: {
124
+ view: "block",
125
+ data: "$.currentPkgImportChain",
126
+ className: "why",
161
127
  content: [
162
128
  {
163
- view: "link",
164
- external: true,
165
- data: `{
166
- href: "https://www.npmjs.com/package/" + #.data.currentPkg.pkgName + "/v/" + metadata.latestVersion,
167
- text: 'v' + metadata.latestVersion,
168
- }`,
129
+ view: "text",
130
+ className: "why-hint",
131
+ data: `fromEntry
132
+ ? 'The shortest import chain from the entry point:'
133
+ : 'Not imported from the entry point: the bundler runs it before the app code (e.g. polyfills). The shortest chain:'`,
134
+ },
135
+ {
136
+ view: "list",
137
+ data: "steps",
138
+ className: "why-chain",
139
+ item: {
140
+ view: "block",
141
+ className:
142
+ "=isTarget ? 'why-step why-step-target' : 'why-step'",
143
+ content: [
144
+ ...require_pages__common.getTreeModule(),
145
+ {
146
+ view: "pill-badge",
147
+ when: "entersPackage",
148
+ className: "why-enters",
149
+ data: "{ prefix: 'enters', text: entersPackage, color: 'rgba(0, 170, 255, 0.25)' }",
150
+ },
151
+ ],
152
+ },
169
153
  },
170
154
  ],
171
155
  },
172
- {
173
- header: "Status",
174
- content: {
175
- view: "switch",
176
- content: [
177
- {
178
- when: "metadata.deprecated",
179
- content: `badge: { text: 'deprecated', color: "rgba(255, 0, 0, 0.35)" }`,
180
- },
181
- {
182
- when: "metadata.isLatest",
183
- content: `badge: { text: 'latest', color: "rgba(120, 177, 9, 0.35)" }`,
184
- },
185
- {
186
- content: `badge: { text: 'outdated', color: "rgba(255, 165, 0, 0.35)" }`,
156
+ },
157
+ {
158
+ when: '#.tabs="versions"',
159
+ content: {
160
+ view: "table",
161
+ data: "overview.copies.[metadata]",
162
+ cols: [
163
+ {
164
+ header: "Path",
165
+ content: "text: path",
166
+ },
167
+ {
168
+ header: "Version",
169
+ content: "pill-badge:{ text: 'v' + version, color: '#0af' }",
170
+ },
171
+ {
172
+ header: "Size",
173
+ content:
174
+ "pill-badge:{ text: size.formatBytes(), color: 'rgba(120, 177, 9, 0.35)' }",
175
+ },
176
+ {
177
+ header: "Published",
178
+ data: "metadata.createdAt",
179
+ content: [
180
+ "text: formatDate()",
181
+ "text: ' '",
182
+ "pill-badge:{ text: timeAgo() }",
183
+ ],
184
+ },
185
+ {
186
+ header: "Latest",
187
+ content: [
188
+ {
189
+ view: "link",
190
+ external: true,
191
+ data: `{
192
+ href: "https://www.npmjs.com/package/" + #.id + "/v/" + metadata.latestVersion,
193
+ text: 'v' + metadata.latestVersion,
194
+ }`,
195
+ },
196
+ ],
197
+ },
198
+ {
199
+ header: "Status",
200
+ content: {
201
+ view: "switch",
202
+ content: [
203
+ {
204
+ when: "metadata.deprecated",
205
+ content: `badge: { text: 'deprecated', color: "rgba(255, 0, 0, 0.35)" }`,
206
+ },
207
+ {
208
+ when: "metadata.isLatest",
209
+ content: `badge: { text: 'latest', color: "rgba(120, 177, 9, 0.35)" }`,
210
+ },
211
+ {
212
+ content: `badge: { text: 'outdated', color: "rgba(255, 165, 0, 0.35)" }`,
213
+ },
214
+ ],
187
215
  },
188
- ],
189
- },
216
+ },
217
+ ],
190
218
  },
191
- ],
192
- },
193
- ],
194
- },
195
- "html: '<hr>'",
196
- {
197
- view: "block",
198
- content: require_pages__common.getPackageList({
199
- data: "$.currentPkg",
200
- itemPkgName: "text: pkgName",
201
- showCopiesBadge: false,
202
- expanded: true,
203
- }),
219
+ },
220
+ ],
221
+ },
204
222
  },
205
223
  ],
206
224
  });
@@ -1,4 +1,9 @@
1
+ const require_issues = require("./issues.js");
1
2
  //#region src/client/prepare.ts
3
+ function addIssue(module, issue) {
4
+ module.issues ??= [];
5
+ if (!module.issues.includes(issue)) module.issues.push(issue);
6
+ }
2
7
  function getDuplicateId(path) {
3
8
  const uniqueNodeModulePath = path.split("node_modules/").pop();
4
9
  const ids = [uniqueNodeModulePath];
@@ -19,6 +24,7 @@ function prepare(input) {
19
24
  const moduleMap = /* @__PURE__ */ new Map();
20
25
  const duplicatesMap = /* @__PURE__ */ new Map();
21
26
  const allLodashModules = /* @__PURE__ */ new Set();
27
+ data.recommendations ??= null;
22
28
  data.packages.forEach((pkg) => {
23
29
  pkg.path = pkg.absolutePath.replace(`${data.rootFolder}/`, "");
24
30
  });
@@ -52,11 +58,20 @@ function prepare(input) {
52
58
  if (m.path.endsWith("node_modules/lodash/index.js"))
53
59
  m.duplicates.push(...allLodashModules);
54
60
  delete m._tmp_ids;
61
+ if (m.duplicates.length > 0) addIssue(m, require_issues.DUPLICATE_ISSUE);
55
62
  m.dependencies.forEach((dependency) => {
56
63
  const dependentModule = moduleMap.get(dependency.absolutePath);
57
64
  if (dependentModule) dependentModule.dependents.push(m);
58
65
  });
59
66
  });
67
+ const modulesByPath = new Map(data.modules.map((m) => [m.absolutePath, m]));
68
+ data.recommendations?.forEach((finding) => {
69
+ finding.modules = finding.modules?.map((path) => {
70
+ const module = modulesByPath.get(path);
71
+ if (module && finding.sizeInBytes) addIssue(module, finding.title);
72
+ return module?.path ?? path;
73
+ });
74
+ });
60
75
  return data;
61
76
  }
62
77
  //#endregion