knip 5.78.0 → 5.80.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/dist/ConfigurationChief.d.ts +18 -0
- package/dist/ProjectPrincipal.js +1 -1
- package/dist/binaries/package-manager/bun.js +21 -0
- package/dist/compilers/index.d.ts +30 -0
- package/dist/graph/analyze.js +34 -30
- package/dist/graph/build.js +1 -1
- package/dist/graph-explorer/explorer.js +1 -1
- package/dist/graph-explorer/operations/build-exports-tree.js +2 -2
- package/dist/graph-explorer/operations/get-contention.js +4 -4
- package/dist/graph-explorer/operations/has-strictly-ns-references.d.ts +1 -1
- package/dist/graph-explorer/operations/has-strictly-ns-references.js +73 -85
- package/dist/graph-explorer/operations/is-referenced.js +23 -24
- package/dist/graph-explorer/visitors.js +7 -7
- package/dist/graph-explorer/walk-down.js +8 -8
- package/dist/plugins/index.d.ts +3 -0
- package/dist/plugins/index.js +6 -0
- package/dist/plugins/knex/helpers.d.ts +1 -0
- package/dist/plugins/knex/helpers.js +19 -0
- package/dist/plugins/knex/index.d.ts +3 -0
- package/dist/plugins/knex/index.js +37 -0
- package/dist/plugins/knex/types.d.ts +11 -0
- package/dist/plugins/knex/types.js +1 -0
- package/dist/plugins/parcel/index.d.ts +3 -0
- package/dist/plugins/parcel/index.js +54 -0
- package/dist/plugins/parcel/types.d.ts +13 -0
- package/dist/plugins/parcel/types.js +1 -0
- package/dist/plugins/tanstack-router/index.d.ts +3 -0
- package/dist/plugins/tanstack-router/index.js +19 -0
- package/dist/reporters/trace.d.ts +2 -3
- package/dist/reporters/trace.js +2 -3
- package/dist/schema/configuration.d.ts +45 -0
- package/dist/schema/plugins.d.ts +15 -0
- package/dist/schema/plugins.js +3 -0
- package/dist/session/build-maps.js +4 -4
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +3 -0
- package/dist/types/module-graph.d.ts +12 -17
- package/dist/typescript/ast-helpers.d.ts +1 -1
- package/dist/typescript/ast-helpers.js +10 -8
- package/dist/typescript/find-internal-references.d.ts +2 -2
- package/dist/typescript/find-internal-references.js +18 -30
- package/dist/typescript/get-imports-and-exports.d.ts +8 -1
- package/dist/typescript/get-imports-and-exports.js +40 -35
- package/dist/util/create-options.d.ts +30 -0
- package/dist/util/glob-core.js +21 -4
- package/dist/util/module-graph.js +27 -27
- package/dist/util/trace.js +2 -2
- package/dist/util/watch.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schema.json +12 -0
|
@@ -243,6 +243,11 @@ export declare class ConfigurationChief {
|
|
|
243
243
|
entry?: string | string[] | undefined;
|
|
244
244
|
project?: string | string[] | undefined;
|
|
245
245
|
} | undefined;
|
|
246
|
+
knex?: string | boolean | string[] | {
|
|
247
|
+
config?: string | string[] | undefined;
|
|
248
|
+
entry?: string | string[] | undefined;
|
|
249
|
+
project?: string | string[] | undefined;
|
|
250
|
+
} | undefined;
|
|
246
251
|
ladle?: string | boolean | string[] | {
|
|
247
252
|
config?: string | string[] | undefined;
|
|
248
253
|
entry?: string | string[] | undefined;
|
|
@@ -383,6 +388,11 @@ export declare class ConfigurationChief {
|
|
|
383
388
|
entry?: string | string[] | undefined;
|
|
384
389
|
project?: string | string[] | undefined;
|
|
385
390
|
} | undefined;
|
|
391
|
+
parcel?: string | boolean | string[] | {
|
|
392
|
+
config?: string | string[] | undefined;
|
|
393
|
+
entry?: string | string[] | undefined;
|
|
394
|
+
project?: string | string[] | undefined;
|
|
395
|
+
} | undefined;
|
|
386
396
|
playwright?: string | boolean | string[] | {
|
|
387
397
|
config?: string | string[] | undefined;
|
|
388
398
|
entry?: string | string[] | undefined;
|
|
@@ -558,6 +568,11 @@ export declare class ConfigurationChief {
|
|
|
558
568
|
entry?: string | string[] | undefined;
|
|
559
569
|
project?: string | string[] | undefined;
|
|
560
570
|
} | undefined;
|
|
571
|
+
'tanstack-router'?: string | boolean | string[] | {
|
|
572
|
+
config?: string | string[] | undefined;
|
|
573
|
+
entry?: string | string[] | undefined;
|
|
574
|
+
project?: string | string[] | undefined;
|
|
575
|
+
} | undefined;
|
|
561
576
|
taskfile?: string | boolean | string[] | {
|
|
562
577
|
config?: string | string[] | undefined;
|
|
563
578
|
entry?: string | string[] | undefined;
|
|
@@ -732,6 +747,7 @@ export declare class ConfigurationChief {
|
|
|
732
747
|
husky?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
733
748
|
"i18next-parser"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
734
749
|
karma?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
750
|
+
knex?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
735
751
|
ladle?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
736
752
|
lefthook?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
737
753
|
"lint-staged"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
@@ -759,6 +775,7 @@ export declare class ConfigurationChief {
|
|
|
759
775
|
nyc?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
760
776
|
oclif?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
761
777
|
oxlint?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
778
|
+
parcel?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
762
779
|
playwright?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
763
780
|
"playwright-ct"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
764
781
|
"playwright-test"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
@@ -793,6 +810,7 @@ export declare class ConfigurationChief {
|
|
|
793
810
|
swc?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
794
811
|
syncpack?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
795
812
|
tailwind?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
813
|
+
"tanstack-router"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
796
814
|
taskfile?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
797
815
|
travis?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
798
816
|
"ts-node"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
package/dist/ProjectPrincipal.js
CHANGED
|
@@ -226,7 +226,7 @@ export class ProjectPrincipal {
|
|
|
226
226
|
const fd = this.cache.getFileDescriptor(filePath);
|
|
227
227
|
if (!fd?.meta)
|
|
228
228
|
continue;
|
|
229
|
-
fd.meta.data = { ...file, internalImportCache: undefined,
|
|
229
|
+
fd.meta.data = { ...file, internalImportCache: undefined, importedBy: undefined };
|
|
230
230
|
}
|
|
231
231
|
this.cache.reconcile();
|
|
232
232
|
}
|
|
@@ -6,26 +6,47 @@ import { resolveX } from './bunx.js';
|
|
|
6
6
|
const commands = [
|
|
7
7
|
'add',
|
|
8
8
|
'audit',
|
|
9
|
+
'auth',
|
|
9
10
|
'build',
|
|
11
|
+
'c',
|
|
10
12
|
'ci',
|
|
13
|
+
'cloud',
|
|
14
|
+
'completions',
|
|
15
|
+
'config',
|
|
11
16
|
'create',
|
|
17
|
+
'deploy',
|
|
18
|
+
'discord',
|
|
12
19
|
'exec',
|
|
13
20
|
'feedback',
|
|
21
|
+
'fuzzilli',
|
|
22
|
+
'getcompletes',
|
|
23
|
+
'help',
|
|
24
|
+
'i',
|
|
14
25
|
'info',
|
|
15
26
|
'init',
|
|
16
27
|
'install',
|
|
17
28
|
'link',
|
|
29
|
+
'list',
|
|
30
|
+
'login',
|
|
31
|
+
'logout',
|
|
18
32
|
'outdated',
|
|
19
33
|
'patch',
|
|
34
|
+
'patch-commit',
|
|
20
35
|
'pm',
|
|
36
|
+
'prune',
|
|
21
37
|
'publish',
|
|
38
|
+
'r',
|
|
22
39
|
'remove',
|
|
23
40
|
'repl',
|
|
41
|
+
'rm',
|
|
24
42
|
'run',
|
|
25
43
|
'test',
|
|
26
44
|
'unlink',
|
|
45
|
+
'uninstall',
|
|
27
46
|
'update',
|
|
28
47
|
'upgrade',
|
|
48
|
+
'use',
|
|
49
|
+
'whoami',
|
|
29
50
|
'why',
|
|
30
51
|
'x',
|
|
31
52
|
];
|
|
@@ -194,6 +194,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
194
194
|
entry?: string | string[] | undefined;
|
|
195
195
|
project?: string | string[] | undefined;
|
|
196
196
|
} | undefined;
|
|
197
|
+
knex?: string | boolean | string[] | {
|
|
198
|
+
config?: string | string[] | undefined;
|
|
199
|
+
entry?: string | string[] | undefined;
|
|
200
|
+
project?: string | string[] | undefined;
|
|
201
|
+
} | undefined;
|
|
197
202
|
ladle?: string | boolean | string[] | {
|
|
198
203
|
config?: string | string[] | undefined;
|
|
199
204
|
entry?: string | string[] | undefined;
|
|
@@ -334,6 +339,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
334
339
|
entry?: string | string[] | undefined;
|
|
335
340
|
project?: string | string[] | undefined;
|
|
336
341
|
} | undefined;
|
|
342
|
+
parcel?: string | boolean | string[] | {
|
|
343
|
+
config?: string | string[] | undefined;
|
|
344
|
+
entry?: string | string[] | undefined;
|
|
345
|
+
project?: string | string[] | undefined;
|
|
346
|
+
} | undefined;
|
|
337
347
|
playwright?: string | boolean | string[] | {
|
|
338
348
|
config?: string | string[] | undefined;
|
|
339
349
|
entry?: string | string[] | undefined;
|
|
@@ -509,6 +519,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
509
519
|
entry?: string | string[] | undefined;
|
|
510
520
|
project?: string | string[] | undefined;
|
|
511
521
|
} | undefined;
|
|
522
|
+
'tanstack-router'?: string | boolean | string[] | {
|
|
523
|
+
config?: string | string[] | undefined;
|
|
524
|
+
entry?: string | string[] | undefined;
|
|
525
|
+
project?: string | string[] | undefined;
|
|
526
|
+
} | undefined;
|
|
512
527
|
taskfile?: string | boolean | string[] | {
|
|
513
528
|
config?: string | string[] | undefined;
|
|
514
529
|
entry?: string | string[] | undefined;
|
|
@@ -815,6 +830,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
815
830
|
entry?: string | string[] | undefined;
|
|
816
831
|
project?: string | string[] | undefined;
|
|
817
832
|
} | undefined;
|
|
833
|
+
knex?: string | boolean | string[] | {
|
|
834
|
+
config?: string | string[] | undefined;
|
|
835
|
+
entry?: string | string[] | undefined;
|
|
836
|
+
project?: string | string[] | undefined;
|
|
837
|
+
} | undefined;
|
|
818
838
|
ladle?: string | boolean | string[] | {
|
|
819
839
|
config?: string | string[] | undefined;
|
|
820
840
|
entry?: string | string[] | undefined;
|
|
@@ -955,6 +975,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
955
975
|
entry?: string | string[] | undefined;
|
|
956
976
|
project?: string | string[] | undefined;
|
|
957
977
|
} | undefined;
|
|
978
|
+
parcel?: string | boolean | string[] | {
|
|
979
|
+
config?: string | string[] | undefined;
|
|
980
|
+
entry?: string | string[] | undefined;
|
|
981
|
+
project?: string | string[] | undefined;
|
|
982
|
+
} | undefined;
|
|
958
983
|
playwright?: string | boolean | string[] | {
|
|
959
984
|
config?: string | string[] | undefined;
|
|
960
985
|
entry?: string | string[] | undefined;
|
|
@@ -1130,6 +1155,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
1130
1155
|
entry?: string | string[] | undefined;
|
|
1131
1156
|
project?: string | string[] | undefined;
|
|
1132
1157
|
} | undefined;
|
|
1158
|
+
'tanstack-router'?: string | boolean | string[] | {
|
|
1159
|
+
config?: string | string[] | undefined;
|
|
1160
|
+
entry?: string | string[] | undefined;
|
|
1161
|
+
project?: string | string[] | undefined;
|
|
1162
|
+
} | undefined;
|
|
1133
1163
|
taskfile?: string | boolean | string[] | {
|
|
1134
1164
|
config?: string | string[] | undefined;
|
|
1135
1165
|
entry?: string | string[] | undefined;
|
package/dist/graph/analyze.js
CHANGED
|
@@ -8,12 +8,15 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
8
8
|
const shouldIgnore = getShouldIgnoreHandler(options.isProduction);
|
|
9
9
|
const shouldIgnoreTags = getShouldIgnoreTagHandler(options.tags);
|
|
10
10
|
const explorer = createGraphExplorer(graph, entryPaths);
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
const isReferencedInUsedExport = (exportedItem, filePath, includeEntryExports) => {
|
|
12
|
+
if (!exportedItem.referencedIn)
|
|
13
|
+
return false;
|
|
14
|
+
for (const containingExport of exportedItem.referencedIn) {
|
|
15
|
+
if (explorer.isReferenced(filePath, containingExport, { includeEntryExports })[0])
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
};
|
|
17
20
|
const analyzeGraph = async () => {
|
|
18
21
|
if (options.isReportValues || options.isReportTypes) {
|
|
19
22
|
streamer.cast('Connecting the dots');
|
|
@@ -29,7 +32,7 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
29
32
|
if (!isIncludeEntryExports && isEntry) {
|
|
30
33
|
continue;
|
|
31
34
|
}
|
|
32
|
-
const importsForExport = file.
|
|
35
|
+
const importsForExport = file.importedBy;
|
|
33
36
|
for (const [identifier, exportedItem] of exportItems) {
|
|
34
37
|
if (shouldIgnore(exportedItem.jsDocTags))
|
|
35
38
|
continue;
|
|
@@ -38,7 +41,8 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
38
41
|
const [isReferenced, reExportingEntryFile] = explorer.isReferenced(filePath, identifier, {
|
|
39
42
|
includeEntryExports: isIncludeEntryExports,
|
|
40
43
|
});
|
|
41
|
-
if (
|
|
44
|
+
if (isIgnored &&
|
|
45
|
+
(isReferenced || isReferencedInUsedExport(exportedItem, filePath, isIncludeEntryExports))) {
|
|
42
46
|
for (const tagName of exportedItem.jsDocTags) {
|
|
43
47
|
if (options.tags[1].includes(tagName.replace(/^@/, ''))) {
|
|
44
48
|
collector.addTagHint({ type: 'tag', filePath, identifier, tagName });
|
|
@@ -66,7 +70,7 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
66
70
|
continue;
|
|
67
71
|
if (shouldIgnore(member.jsDocTags))
|
|
68
72
|
continue;
|
|
69
|
-
if (member.
|
|
73
|
+
if (!member.hasRefsInFile) {
|
|
70
74
|
const id = `${identifier}.${member.identifier}`;
|
|
71
75
|
const [isMemberReferenced] = explorer.isReferenced(filePath, id, {
|
|
72
76
|
includeEntryExports: true,
|
|
@@ -127,28 +131,28 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
127
131
|
}
|
|
128
132
|
const [hasStrictlyNsRefs, namespace] = explorer.hasStrictlyNsReferences(filePath, identifier);
|
|
129
133
|
const isType = ['enum', 'type', 'interface'].includes(exportedItem.type);
|
|
130
|
-
if (
|
|
131
|
-
|
|
134
|
+
if (isIgnored ||
|
|
135
|
+
exportedItem.hasRefsInFile ||
|
|
136
|
+
isReferencedInUsedExport(exportedItem, filePath, isIncludeEntryExports) ||
|
|
137
|
+
(hasStrictlyNsRefs &&
|
|
138
|
+
((!options.includedIssueTypes.nsTypes && isType) ||
|
|
139
|
+
!(options.includedIssueTypes.nsExports || isType))) ||
|
|
140
|
+
(!options.isSkipLibs && principal?.hasExternalReferences(filePath, exportedItem))) {
|
|
132
141
|
continue;
|
|
133
|
-
if (!isExportReferencedInFile(exportedItem)) {
|
|
134
|
-
if (isIgnored)
|
|
135
|
-
continue;
|
|
136
|
-
if (!options.isSkipLibs && principal?.hasExternalReferences(filePath, exportedItem))
|
|
137
|
-
continue;
|
|
138
|
-
const type = getIssueType(hasStrictlyNsRefs, isType);
|
|
139
|
-
collector.addIssue({
|
|
140
|
-
type,
|
|
141
|
-
filePath,
|
|
142
|
-
workspace: workspace.name,
|
|
143
|
-
symbol: identifier,
|
|
144
|
-
symbolType: exportedItem.type,
|
|
145
|
-
parentSymbol: namespace,
|
|
146
|
-
pos: exportedItem.pos,
|
|
147
|
-
line: exportedItem.line,
|
|
148
|
-
col: exportedItem.col,
|
|
149
|
-
fixes: exportedItem.fixes,
|
|
150
|
-
});
|
|
151
142
|
}
|
|
143
|
+
const type = getIssueType(hasStrictlyNsRefs, isType);
|
|
144
|
+
collector.addIssue({
|
|
145
|
+
type,
|
|
146
|
+
filePath,
|
|
147
|
+
workspace: workspace.name,
|
|
148
|
+
symbol: identifier,
|
|
149
|
+
symbolType: exportedItem.type,
|
|
150
|
+
parentSymbol: namespace,
|
|
151
|
+
pos: exportedItem.pos,
|
|
152
|
+
line: exportedItem.line,
|
|
153
|
+
col: exportedItem.col,
|
|
154
|
+
fixes: exportedItem.fixes,
|
|
155
|
+
});
|
|
152
156
|
}
|
|
153
157
|
}
|
|
154
158
|
}
|
|
@@ -231,6 +235,6 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
231
235
|
};
|
|
232
236
|
await analyzeGraph();
|
|
233
237
|
if (options.isTrace)
|
|
234
|
-
traceReporter({ graph, explorer, options
|
|
238
|
+
traceReporter({ graph, explorer, options });
|
|
235
239
|
return analyzeGraph;
|
|
236
240
|
};
|
package/dist/graph/build.js
CHANGED
|
@@ -212,7 +212,7 @@ export async function build({ chief, collector, counselor, deputy, factory, isGi
|
|
|
212
212
|
collector.addConfigurationHint(hint);
|
|
213
213
|
}
|
|
214
214
|
principal.addEntryPaths(userEntryPaths);
|
|
215
|
-
if (options.isUseTscFiles) {
|
|
215
|
+
if (options.isUseTscFiles && isFile) {
|
|
216
216
|
const isIgnoredWorkspace = chief.createIgnoredWorkspaceMatcher(name, dir);
|
|
217
217
|
debugLogArray(name, 'Using tsconfig files as project files', tscSourcePaths);
|
|
218
218
|
for (const filePath of tscSourcePaths) {
|
|
@@ -10,7 +10,7 @@ import { resolveDefinition } from './operations/resolve-definition.js';
|
|
|
10
10
|
export const createGraphExplorer = (graph, entryPaths) => {
|
|
11
11
|
return {
|
|
12
12
|
isReferenced: (filePath, identifier, options) => isReferenced(graph, entryPaths, filePath, identifier, options),
|
|
13
|
-
hasStrictlyNsReferences: (filePath, identifier) => hasStrictlyNsReferences(graph, graph.get(filePath)?.
|
|
13
|
+
hasStrictlyNsReferences: (filePath, identifier) => hasStrictlyNsReferences(graph, filePath, graph.get(filePath)?.importedBy, identifier),
|
|
14
14
|
buildExportsTree: (options) => buildExportsTree(graph, entryPaths, options),
|
|
15
15
|
getDependencyUsage: (pattern) => getDependencyUsage(graph, pattern),
|
|
16
16
|
resolveDefinition: (filePath, identifier) => resolveDefinition(graph, filePath, identifier),
|
|
@@ -27,7 +27,7 @@ const buildExportTree = (graph, entryPaths, filePath, identifier) => {
|
|
|
27
27
|
const rootNode = {
|
|
28
28
|
filePath,
|
|
29
29
|
identifier,
|
|
30
|
-
refs: filterRefs(file?.
|
|
30
|
+
refs: filterRefs(file?.importedBy?.refs, identifier),
|
|
31
31
|
isEntry: entryPaths.has(filePath),
|
|
32
32
|
children: [],
|
|
33
33
|
originalId: undefined,
|
|
@@ -82,7 +82,7 @@ const hasRelevantRef = (refs, id) => {
|
|
|
82
82
|
const isNsReExported = (importMaps, ns) => {
|
|
83
83
|
if (!importMaps)
|
|
84
84
|
return false;
|
|
85
|
-
return importMaps.
|
|
85
|
+
return importMaps.reExportAs.has(ns) || importMaps.reExportNs.has(ns);
|
|
86
86
|
};
|
|
87
87
|
const hasNonReExportStar = (node) => {
|
|
88
88
|
if (node.via && node.via !== 'reExportStar')
|
|
@@ -100,7 +100,7 @@ const walkDown = (graph, network, filePath, identifier, visited) => {
|
|
|
100
100
|
return;
|
|
101
101
|
visited.add(filePath);
|
|
102
102
|
const node = graph.get(filePath);
|
|
103
|
-
if (!node?.
|
|
103
|
+
if (!node?.importedBy)
|
|
104
104
|
return;
|
|
105
105
|
const processConsumer = (consumerPath) => {
|
|
106
106
|
network.files.add(consumerPath);
|
|
@@ -110,12 +110,12 @@ const walkDown = (graph, network, filePath, identifier, visited) => {
|
|
|
110
110
|
network.definitions.add(consumerPath);
|
|
111
111
|
walkDown(graph, network, consumerPath, identifier, visited);
|
|
112
112
|
};
|
|
113
|
-
const directConsumers = node.
|
|
113
|
+
const directConsumers = node.importedBy.reExport.get(identifier);
|
|
114
114
|
if (directConsumers) {
|
|
115
115
|
for (const consumerPath of directConsumers)
|
|
116
116
|
processConsumer(consumerPath);
|
|
117
117
|
}
|
|
118
|
-
for (const [sourceId, aliasMap] of node.
|
|
118
|
+
for (const [sourceId, aliasMap] of node.importedBy.reExportAs) {
|
|
119
119
|
if (sourceId === identifier) {
|
|
120
120
|
for (const [_alias, consumers] of aliasMap) {
|
|
121
121
|
for (const consumerPath of consumers)
|
|
@@ -123,7 +123,7 @@ const walkDown = (graph, network, filePath, identifier, visited) => {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
const starConsumers = node.
|
|
126
|
+
const starConsumers = node.importedBy.reExport.get(IMPORT_STAR);
|
|
127
127
|
if (starConsumers) {
|
|
128
128
|
for (const consumerPath of starConsumers) {
|
|
129
129
|
const consumerExports = getExportedIdentifiers(graph, consumerPath);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ImportMaps, ModuleGraph } from '../../types/module-graph.js';
|
|
2
|
-
export declare const hasStrictlyNsReferences: (graph: ModuleGraph, importsForExport: ImportMaps | undefined, identifier: string) => [boolean, string?];
|
|
2
|
+
export declare const hasStrictlyNsReferences: (graph: ModuleGraph, filePath: string, importsForExport: ImportMaps | undefined, identifier: string) => [boolean, string?];
|
|
@@ -1,98 +1,86 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const hasStrictlyNsReferences = (graph, importsForExport, identifier) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
import { getAliasReExportMap, getPassThroughReExportSources, getStarReExportSources } from '../visitors.js';
|
|
2
|
+
export const hasStrictlyNsReferences = (graph, filePath, importsForExport, identifier) => {
|
|
3
|
+
const seen = new Set();
|
|
4
|
+
const walkDown = (path, importMaps, id) => {
|
|
5
|
+
if (!importMaps)
|
|
6
|
+
return [false];
|
|
7
|
+
if (seen.has(path))
|
|
8
|
+
return [false];
|
|
9
|
+
seen.add(path);
|
|
10
|
+
let namespace;
|
|
11
|
+
const follow = (sources, nextId) => {
|
|
12
|
+
for (const filePath of sources) {
|
|
13
|
+
const file = graph.get(filePath);
|
|
14
|
+
if (!file?.importedBy)
|
|
15
|
+
continue;
|
|
16
|
+
const result = walkDown(filePath, file.importedBy, nextId);
|
|
17
|
+
if (result[0] === false && result[1])
|
|
18
|
+
return result;
|
|
19
|
+
if (result[1] && !namespace)
|
|
20
|
+
namespace = result[1];
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
};
|
|
24
|
+
for (const ns of importMaps.importNs.keys()) {
|
|
25
|
+
if (!importMaps.refs.has(ns))
|
|
26
|
+
return [false, ns];
|
|
27
|
+
for (const ref of importMaps.refs) {
|
|
28
|
+
if (ref.startsWith(`${ns}.`))
|
|
29
|
+
return [false, ns];
|
|
30
|
+
}
|
|
31
|
+
namespace = ns;
|
|
32
|
+
const nsAliases = getAliasReExportMap(importMaps, ns);
|
|
33
|
+
if (nsAliases) {
|
|
34
|
+
for (const [alias, sources] of nsAliases) {
|
|
35
|
+
const result = follow(sources, alias);
|
|
36
|
+
if (result)
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
27
40
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
for (const filePath of sources) {
|
|
33
|
-
const file = graph.get(filePath);
|
|
34
|
-
if (!file?.imported)
|
|
35
|
-
continue;
|
|
36
|
-
const result = hasStrictlyNsReferences(graph, file.imported, nextId);
|
|
37
|
-
if (result[0] === false)
|
|
41
|
+
const directSources = getPassThroughReExportSources(importMaps, id);
|
|
42
|
+
if (directSources) {
|
|
43
|
+
const result = follow(directSources, id);
|
|
44
|
+
if (result)
|
|
38
45
|
return result;
|
|
39
|
-
if (propagateNamespace && result[1])
|
|
40
|
-
foundNamespace = result[1];
|
|
41
46
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return [false, ns];
|
|
48
|
-
for (const ref of importsForExport.refs) {
|
|
49
|
-
if (ref.startsWith(`${ns}.`))
|
|
50
|
-
return [false, ns];
|
|
47
|
+
const starSources = getStarReExportSources(importMaps);
|
|
48
|
+
if (starSources) {
|
|
49
|
+
const result = follow(starSources, id);
|
|
50
|
+
if (result)
|
|
51
|
+
return result;
|
|
51
52
|
}
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
const [_id, ...rest] = id.split('.');
|
|
54
|
+
const aliasEntries = getAliasReExportMap(importMaps, _id);
|
|
55
|
+
if (aliasEntries) {
|
|
56
|
+
for (const [alias, sources] of aliasEntries) {
|
|
57
|
+
const result = follow(sources, [alias, ...rest].join('.'));
|
|
56
58
|
if (result)
|
|
57
59
|
return result;
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (result)
|
|
65
|
-
return result;
|
|
66
|
-
}
|
|
62
|
+
for (const [ns, sources] of importMaps.reExportNs) {
|
|
63
|
+
const result = follow(sources, `${ns}.${id}`);
|
|
64
|
+
if (result)
|
|
65
|
+
return result;
|
|
67
66
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (directSources) {
|
|
72
|
-
const result = followReExports(directSources, identifier, true);
|
|
73
|
-
if (result)
|
|
74
|
-
return result;
|
|
75
|
-
}
|
|
76
|
-
if (starSources) {
|
|
77
|
-
const result = followReExports(starSources, identifier, true);
|
|
78
|
-
if (result)
|
|
79
|
-
return result;
|
|
80
|
-
}
|
|
81
|
-
const [id, ...rest] = identifier.split('.');
|
|
82
|
-
const aliasEntries = aliasByIdentifier.get(id);
|
|
83
|
-
if (aliasEntries) {
|
|
84
|
-
for (const { alias, sources } of aliasEntries) {
|
|
85
|
-
const result = followReExports(sources, [alias, ...rest].join('.'), true);
|
|
67
|
+
const importedSources = importMaps.import.get(id);
|
|
68
|
+
if (importedSources) {
|
|
69
|
+
const result = follow(importedSources, id);
|
|
86
70
|
if (result)
|
|
87
71
|
return result;
|
|
88
72
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
73
|
+
const importAsMap = importMaps.importAs.get(id);
|
|
74
|
+
if (importAsMap) {
|
|
75
|
+
for (const [alias, sources] of importAsMap) {
|
|
76
|
+
const result = follow(sources, alias);
|
|
77
|
+
if (result)
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (namespace)
|
|
82
|
+
return [true, namespace];
|
|
83
|
+
return [false];
|
|
84
|
+
};
|
|
85
|
+
return walkDown(filePath, importsForExport, identifier);
|
|
98
86
|
};
|