knip 5.79.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.
Files changed (36) hide show
  1. package/dist/ConfigurationChief.d.ts +6 -0
  2. package/dist/ProjectPrincipal.js +1 -1
  3. package/dist/compilers/index.d.ts +10 -0
  4. package/dist/graph/analyze.js +1 -1
  5. package/dist/graph/build.js +1 -1
  6. package/dist/graph-explorer/explorer.js +1 -1
  7. package/dist/graph-explorer/operations/build-exports-tree.js +2 -2
  8. package/dist/graph-explorer/operations/get-contention.js +4 -4
  9. package/dist/graph-explorer/operations/has-strictly-ns-references.d.ts +1 -1
  10. package/dist/graph-explorer/operations/has-strictly-ns-references.js +73 -88
  11. package/dist/graph-explorer/operations/is-referenced.js +23 -24
  12. package/dist/graph-explorer/visitors.js +7 -7
  13. package/dist/graph-explorer/walk-down.js +8 -8
  14. package/dist/plugins/index.d.ts +1 -0
  15. package/dist/plugins/index.js +2 -0
  16. package/dist/plugins/parcel/index.d.ts +3 -0
  17. package/dist/plugins/parcel/index.js +54 -0
  18. package/dist/plugins/parcel/types.d.ts +13 -0
  19. package/dist/plugins/parcel/types.js +1 -0
  20. package/dist/schema/configuration.d.ts +15 -0
  21. package/dist/schema/plugins.d.ts +5 -0
  22. package/dist/schema/plugins.js +1 -0
  23. package/dist/session/build-maps.js +4 -4
  24. package/dist/types/PluginNames.d.ts +2 -2
  25. package/dist/types/PluginNames.js +1 -0
  26. package/dist/types/module-graph.d.ts +7 -7
  27. package/dist/typescript/find-internal-references.d.ts +1 -1
  28. package/dist/typescript/find-internal-references.js +3 -1
  29. package/dist/typescript/get-imports-and-exports.js +16 -16
  30. package/dist/util/create-options.d.ts +10 -0
  31. package/dist/util/module-graph.js +27 -27
  32. package/dist/util/trace.js +2 -2
  33. package/dist/util/watch.js +1 -1
  34. package/dist/version.d.ts +1 -1
  35. package/dist/version.js +1 -1
  36. package/package.json +1 -1
@@ -388,6 +388,11 @@ export declare class ConfigurationChief {
388
388
  entry?: string | string[] | undefined;
389
389
  project?: string | string[] | undefined;
390
390
  } | undefined;
391
+ parcel?: string | boolean | string[] | {
392
+ config?: string | string[] | undefined;
393
+ entry?: string | string[] | undefined;
394
+ project?: string | string[] | undefined;
395
+ } | undefined;
391
396
  playwright?: string | boolean | string[] | {
392
397
  config?: string | string[] | undefined;
393
398
  entry?: string | string[] | undefined;
@@ -770,6 +775,7 @@ export declare class ConfigurationChief {
770
775
  nyc?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
771
776
  oclif?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
772
777
  oxlint?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
778
+ parcel?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
773
779
  playwright?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
774
780
  "playwright-ct"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
775
781
  "playwright-test"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
@@ -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, imported: undefined };
229
+ fd.meta.data = { ...file, internalImportCache: undefined, importedBy: undefined };
230
230
  }
231
231
  this.cache.reconcile();
232
232
  }
@@ -339,6 +339,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
339
339
  entry?: string | string[] | undefined;
340
340
  project?: string | string[] | undefined;
341
341
  } | undefined;
342
+ parcel?: string | boolean | string[] | {
343
+ config?: string | string[] | undefined;
344
+ entry?: string | string[] | undefined;
345
+ project?: string | string[] | undefined;
346
+ } | undefined;
342
347
  playwright?: string | boolean | string[] | {
343
348
  config?: string | string[] | undefined;
344
349
  entry?: string | string[] | undefined;
@@ -970,6 +975,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
970
975
  entry?: string | string[] | undefined;
971
976
  project?: string | string[] | undefined;
972
977
  } | undefined;
978
+ parcel?: string | boolean | string[] | {
979
+ config?: string | string[] | undefined;
980
+ entry?: string | string[] | undefined;
981
+ project?: string | string[] | undefined;
982
+ } | undefined;
973
983
  playwright?: string | boolean | string[] | {
974
984
  config?: string | string[] | undefined;
975
985
  entry?: string | string[] | undefined;
@@ -32,7 +32,7 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
32
32
  if (!isIncludeEntryExports && isEntry) {
33
33
  continue;
34
34
  }
35
- const importsForExport = file.imported;
35
+ const importsForExport = file.importedBy;
36
36
  for (const [identifier, exportedItem] of exportItems) {
37
37
  if (shouldIgnore(exportedItem.jsDocTags))
38
38
  continue;
@@ -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, filePath, graph.get(filePath)?.imported, identifier),
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?.imported?.refs, identifier),
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.reExportedAs.has(ns) || importMaps.reExportedNs.has(ns);
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?.imported)
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.imported.reExported.get(identifier);
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.imported.reExportedAs) {
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.imported.reExported.get(IMPORT_STAR);
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, filePath: string, importsForExport: ImportMaps | undefined, identifier: string, seenFiles?: Set<string>) => [boolean, string?];
2
+ export declare const hasStrictlyNsReferences: (graph: ModuleGraph, filePath: string, importsForExport: ImportMaps | undefined, identifier: string) => [boolean, string?];
@@ -1,101 +1,86 @@
1
- import { forEachAliasReExport, forEachNamespaceReExport, forEachPassThroughReExport, getStarReExportSources, } from '../visitors.js';
2
- export const hasStrictlyNsReferences = (graph, filePath, importsForExport, identifier, seenFiles = new Set()) => {
3
- if (!importsForExport)
4
- return [false];
5
- if (seenFiles.has(filePath))
6
- return [false];
7
- seenFiles.add(filePath);
8
- let foundNamespace;
9
- const aliasByIdentifier = new Map();
10
- const namespaceReExports = new Map();
11
- const namespaceEdges = [];
12
- const directById = new Map();
13
- forEachPassThroughReExport(importsForExport, (id, sources) => {
14
- directById.set(id, sources);
15
- });
16
- forEachAliasReExport(importsForExport, (id, alias, sources) => {
17
- let arr = aliasByIdentifier.get(id);
18
- if (!arr) {
19
- arr = [];
20
- aliasByIdentifier.set(id, arr);
21
- }
22
- arr.push({ alias, sources });
23
- });
24
- forEachNamespaceReExport(importsForExport, (namespace, sources) => {
25
- namespaceEdges.push({ namespace, sources });
26
- let arr = namespaceReExports.get(namespace);
27
- if (!arr) {
28
- arr = [];
29
- namespaceReExports.set(namespace, arr);
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
+ }
30
40
  }
31
- arr.push(sources);
32
- });
33
- const starSources = getStarReExportSources(importsForExport);
34
- const followReExports = (sources, nextId, propagateNamespace = true) => {
35
- for (const filePath of sources) {
36
- const file = graph.get(filePath);
37
- if (!file?.imported)
38
- continue;
39
- const result = hasStrictlyNsReferences(graph, filePath, file.imported, nextId, seenFiles);
40
- if (result[0] === false)
41
+ const directSources = getPassThroughReExportSources(importMaps, id);
42
+ if (directSources) {
43
+ const result = follow(directSources, id);
44
+ if (result)
41
45
  return result;
42
- if (propagateNamespace && result[1])
43
- foundNamespace = result[1];
44
46
  }
45
- return undefined;
46
- };
47
- for (const ns of importsForExport.importedNs.keys()) {
48
- const hasNsRef = importsForExport.refs.has(ns);
49
- if (!hasNsRef)
50
- return [false, ns];
51
- for (const ref of importsForExport.refs) {
52
- if (ref.startsWith(`${ns}.`))
53
- return [false, ns];
47
+ const starSources = getStarReExportSources(importMaps);
48
+ if (starSources) {
49
+ const result = follow(starSources, id);
50
+ if (result)
51
+ return result;
54
52
  }
55
- const nsReExports = namespaceReExports.get(ns);
56
- if (nsReExports) {
57
- for (const sources of nsReExports) {
58
- const result = followReExports(sources, identifier, false);
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('.'));
59
58
  if (result)
60
59
  return result;
61
60
  }
62
61
  }
63
- const nsAliases = aliasByIdentifier.get(ns);
64
- if (nsAliases) {
65
- for (const { sources } of nsAliases) {
66
- const result = followReExports(sources, identifier, false);
67
- if (result)
68
- return result;
69
- }
62
+ for (const [ns, sources] of importMaps.reExportNs) {
63
+ const result = follow(sources, `${ns}.${id}`);
64
+ if (result)
65
+ return result;
70
66
  }
71
- foundNamespace = ns;
72
- }
73
- const directSources = directById.get(identifier);
74
- if (directSources) {
75
- const result = followReExports(directSources, identifier, true);
76
- if (result)
77
- return result;
78
- }
79
- if (starSources) {
80
- const result = followReExports(starSources, identifier, true);
81
- if (result)
82
- return result;
83
- }
84
- const [id, ...rest] = identifier.split('.');
85
- const aliasEntries = aliasByIdentifier.get(id);
86
- if (aliasEntries) {
87
- for (const { alias, sources } of aliasEntries) {
88
- const result = followReExports(sources, [alias, ...rest].join('.'), true);
67
+ const importedSources = importMaps.import.get(id);
68
+ if (importedSources) {
69
+ const result = follow(importedSources, id);
89
70
  if (result)
90
71
  return result;
91
72
  }
92
- }
93
- for (const { namespace: ns, sources } of namespaceEdges) {
94
- const result = followReExports(sources, `${ns}.${identifier}`, true);
95
- if (result)
96
- return result;
97
- }
98
- if (foundNamespace)
99
- return [true, foundNamespace];
100
- return [false];
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);
101
86
  };
@@ -2,23 +2,23 @@ import { OPAQUE } from '../../constants.js';
2
2
  import { getAliasReExportMap, getNamespaceReExportSources, getPassThroughReExportSources, getStarReExportSources, } from '../visitors.js';
3
3
  export const isReferenced = (graph, entryPaths, filePath, id, options) => {
4
4
  const seen = new Set();
5
- const check = (currentPath, currentId) => {
6
- const isEntryFile = entryPaths.has(currentPath);
7
- let reExportingEntryFile = isEntryFile ? currentPath : undefined;
8
- if (seen.has(currentPath))
5
+ const walkDown = (path, id) => {
6
+ const isEntryFile = entryPaths.has(path);
7
+ let reExportingEntryFile = isEntryFile ? path : undefined;
8
+ if (seen.has(path))
9
9
  return [false, reExportingEntryFile];
10
- seen.add(currentPath);
11
- const restIds = currentId.split('.');
10
+ seen.add(path);
11
+ const restIds = id.split('.');
12
12
  const identifier = restIds.shift();
13
- const file = graph.get(currentPath)?.imported;
13
+ const file = graph.get(path)?.importedBy;
14
14
  if (!identifier || !file) {
15
15
  return [false, reExportingEntryFile];
16
16
  }
17
- const followSources = (sources, nextId) => {
17
+ const follow = (sources, nextId) => {
18
18
  for (const byFilePath of sources) {
19
19
  if (seen.has(byFilePath))
20
20
  continue;
21
- const result = check(byFilePath, nextId);
21
+ const result = walkDown(byFilePath, nextId);
22
22
  if (result[1])
23
23
  reExportingEntryFile = result[1];
24
24
  if (result[0])
@@ -26,12 +26,12 @@ export const isReferenced = (graph, entryPaths, filePath, id, options) => {
26
26
  }
27
27
  return false;
28
28
  };
29
- if (file.imported.get(OPAQUE) ||
30
- ((identifier === currentId || (identifier !== currentId && file.refs.has(currentId))) &&
31
- (file.imported.has(identifier) || file.importedAs.has(identifier)))) {
29
+ if (file.import.get(OPAQUE) ||
30
+ ((identifier === id || (identifier !== id && file.refs.has(id))) &&
31
+ (file.import.has(identifier) || file.importAs.has(identifier)))) {
32
32
  return [true, reExportingEntryFile];
33
33
  }
34
- for (const [exportId, aliases] of file.importedAs) {
34
+ for (const [exportId, aliases] of file.importAs) {
35
35
  if (identifier === exportId) {
36
36
  for (const alias of aliases.keys()) {
37
37
  const aliasedRef = [alias, ...restIds].join('.');
@@ -41,20 +41,20 @@ export const isReferenced = (graph, entryPaths, filePath, id, options) => {
41
41
  }
42
42
  }
43
43
  }
44
- for (const namespace of file.importedNs.keys()) {
45
- if (file.refs.has(`${namespace}.${currentId}`)) {
44
+ for (const namespace of file.importNs.keys()) {
45
+ if (file.refs.has(`${namespace}.${id}`)) {
46
46
  return [true, reExportingEntryFile];
47
47
  }
48
48
  const nsAliasMap = getAliasReExportMap(file, namespace);
49
49
  if (nsAliasMap) {
50
50
  for (const [alias, sources] of nsAliasMap) {
51
- if (followSources(sources, `${alias}.${currentId}`))
51
+ if (follow(sources, `${alias}.${id}`))
52
52
  return [true, reExportingEntryFile];
53
53
  }
54
54
  }
55
55
  const nsReExportSources = getNamespaceReExportSources(file, namespace);
56
56
  if (nsReExportSources) {
57
- if (followSources(nsReExportSources, `${namespace}.${currentId}`))
57
+ if (follow(nsReExportSources, `${namespace}.${id}`))
58
58
  return [true, reExportingEntryFile];
59
59
  }
60
60
  }
@@ -63,27 +63,26 @@ export const isReferenced = (graph, entryPaths, filePath, id, options) => {
63
63
  const aliasMap = getAliasReExportMap(file, identifier);
64
64
  if (aliasMap) {
65
65
  for (const [alias, sources] of aliasMap) {
66
- const ref = [alias, ...restIds].join('.');
67
- if (followSources(sources, ref))
66
+ if (follow(sources, [alias, ...restIds].join('.')))
68
67
  return [true, reExportingEntryFile];
69
68
  }
70
69
  }
71
70
  const directSources = getPassThroughReExportSources(file, identifier);
72
71
  const starSources = getStarReExportSources(file);
73
72
  if (directSources) {
74
- if (followSources(directSources, currentId))
73
+ if (follow(directSources, id))
75
74
  return [true, reExportingEntryFile];
76
75
  }
77
76
  else if (starSources) {
78
- if (followSources(starSources, currentId))
77
+ if (follow(starSources, id))
79
78
  return [true, reExportingEntryFile];
80
79
  }
81
- for (const [namespace, sources] of file.reExportedNs) {
82
- if (followSources(sources, `${namespace}.${currentId}`)) {
80
+ for (const [namespace, sources] of file.reExportNs) {
81
+ if (follow(sources, `${namespace}.${id}`)) {
83
82
  return [true, reExportingEntryFile];
84
83
  }
85
84
  }
86
85
  return [false, reExportingEntryFile];
87
86
  };
88
- return check(filePath, id);
87
+ return walkDown(filePath, id);
89
88
  };
@@ -1,6 +1,6 @@
1
1
  import { IMPORT_STAR } from '../constants.js';
2
2
  export const forEachPassThroughReExport = (importMaps, callback) => {
3
- for (const [identifier, sources] of importMaps.reExported) {
3
+ for (const [identifier, sources] of importMaps.reExport) {
4
4
  if (identifier === IMPORT_STAR)
5
5
  continue;
6
6
  if (callback(identifier, sources) === false)
@@ -9,7 +9,7 @@ export const forEachPassThroughReExport = (importMaps, callback) => {
9
9
  return true;
10
10
  };
11
11
  export const forEachAliasReExport = (importMaps, callback) => {
12
- for (const [identifier, aliasMap] of importMaps.reExportedAs) {
12
+ for (const [identifier, aliasMap] of importMaps.reExportAs) {
13
13
  for (const [alias, sources] of aliasMap) {
14
14
  if (callback(identifier, alias, sources) === false)
15
15
  return false;
@@ -18,13 +18,13 @@ export const forEachAliasReExport = (importMaps, callback) => {
18
18
  return true;
19
19
  };
20
20
  export const forEachNamespaceReExport = (importMaps, callback) => {
21
- for (const [namespace, sources] of importMaps.reExportedNs) {
21
+ for (const [namespace, sources] of importMaps.reExportNs) {
22
22
  if (callback(namespace, sources) === false)
23
23
  return false;
24
24
  }
25
25
  return true;
26
26
  };
27
- export const getStarReExportSources = (importMaps) => importMaps.reExported.get(IMPORT_STAR);
28
- export const getPassThroughReExportSources = (importMaps, identifier) => importMaps.reExported.get(identifier);
29
- export const getAliasReExportMap = (importMaps, identifier) => importMaps.reExportedAs.get(identifier);
30
- export const getNamespaceReExportSources = (importMaps, namespace) => importMaps.reExportedNs.get(namespace);
27
+ export const getStarReExportSources = (importMaps) => importMaps.reExport.get(IMPORT_STAR);
28
+ export const getPassThroughReExportSources = (importMaps, identifier) => importMaps.reExport.get(identifier);
29
+ export const getAliasReExportMap = (importMaps, identifier) => importMaps.reExportAs.get(identifier);
30
+ export const getNamespaceReExportSources = (importMaps, namespace) => importMaps.reExportNs.get(namespace);
@@ -6,14 +6,14 @@ export const walkDown = (graph, filePath, identifier, visitor, entryPaths, visit
6
6
  return false;
7
7
  visited.add(key);
8
8
  const file = graph.get(filePath);
9
- if (!file?.imported)
9
+ if (!file?.importedBy)
10
10
  return false;
11
11
  const restIds = identifier.split('.');
12
12
  const id = restIds.shift();
13
13
  if (!id)
14
14
  return false;
15
- const imported = file.imported;
16
- const importedByFiles = imported.imported.get(id);
15
+ const imported = file.importedBy;
16
+ const importedByFiles = imported.import.get(id);
17
17
  if (importedByFiles) {
18
18
  for (const importingFile of importedByFiles) {
19
19
  const isEntry = entryPaths.has(importingFile);
@@ -21,9 +21,9 @@ export const walkDown = (graph, filePath, identifier, visitor, entryPaths, visit
21
21
  return true;
22
22
  }
23
23
  }
24
- const importedAsAliases = imported.importedAs.get(id);
25
- if (importedAsAliases) {
26
- for (const [alias, byFilePaths] of importedAsAliases) {
24
+ const importAsAliases = imported.importAs.get(id);
25
+ if (importAsAliases) {
26
+ for (const [alias, byFilePaths] of importAsAliases) {
27
27
  for (const importingFile of byFilePaths) {
28
28
  const isEntry = entryPaths.has(importingFile);
29
29
  if (visitor(filePath, id, importingFile, alias, isEntry, 'importAs') === STOP)
@@ -31,7 +31,7 @@ export const walkDown = (graph, filePath, identifier, visitor, entryPaths, visit
31
31
  }
32
32
  }
33
33
  }
34
- for (const [namespace, byFilePaths] of imported.importedNs) {
34
+ for (const [namespace, byFilePaths] of imported.importNs) {
35
35
  for (const importingFile of byFilePaths) {
36
36
  const isEntry = entryPaths.has(importingFile);
37
37
  if (visitor(filePath, identifier, importingFile, `${namespace}.${identifier}`, isEntry, 'importNS') === STOP) {
@@ -77,7 +77,7 @@ export const walkDown = (graph, filePath, identifier, visitor, entryPaths, visit
77
77
  }
78
78
  }
79
79
  if (!done) {
80
- for (const [namespace, sources] of imported.reExportedNs) {
80
+ for (const [namespace, sources] of imported.reExportNs) {
81
81
  for (const reExportingFile of sources) {
82
82
  const isEntry = entryPaths.has(reExportingFile);
83
83
  if (visitor(filePath, identifier, reExportingFile, `${namespace}.${identifier}`, isEntry, 'reExportNS') === STOP) {
@@ -66,6 +66,7 @@ export declare const Plugins: {
66
66
  nyc: import("../types/config.js").Plugin;
67
67
  oclif: import("../types/config.js").Plugin;
68
68
  oxlint: import("../types/config.js").Plugin;
69
+ parcel: import("../types/config.js").Plugin;
69
70
  playwright: import("../types/config.js").Plugin;
70
71
  'playwright-ct': import("../types/config.js").Plugin;
71
72
  'playwright-test': import("../types/config.js").Plugin;
@@ -65,6 +65,7 @@ import { default as nx } from './nx/index.js';
65
65
  import { default as nyc } from './nyc/index.js';
66
66
  import { default as oclif } from './oclif/index.js';
67
67
  import { default as oxlint } from './oxlint/index.js';
68
+ import { default as parcel } from './parcel/index.js';
68
69
  import { default as playwright } from './playwright/index.js';
69
70
  import { default as playwrightCt } from './playwright-ct/index.js';
70
71
  import { default as playwrightTest } from './playwright-test/index.js';
@@ -192,6 +193,7 @@ export const Plugins = {
192
193
  nyc,
193
194
  oclif,
194
195
  oxlint,
196
+ parcel,
195
197
  playwright,
196
198
  'playwright-ct': playwrightCt,
197
199
  'playwright-test': playwrightTest,
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.js';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,54 @@
1
+ import { toDeferResolve } from '../../util/input.js';
2
+ import { hasDependency } from '../../util/plugin.js';
3
+ const title = 'Parcel';
4
+ const enablers = ['parcel', '@parcel/core'];
5
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
+ const config = ['.parcelrc'];
7
+ const resolveConfig = async (config) => {
8
+ const dependencies = [];
9
+ if (typeof config.extends === 'string') {
10
+ dependencies.push(config.extends);
11
+ }
12
+ else if (Array.isArray(config.extends)) {
13
+ dependencies.push(...config.extends);
14
+ }
15
+ const extractPlugins = (plugins) => {
16
+ if (!plugins)
17
+ return [];
18
+ return typeof plugins === 'string' ? [plugins] : plugins;
19
+ };
20
+ const extractPluginsFromMap = (pluginMap) => {
21
+ if (!pluginMap)
22
+ return [];
23
+ return Object.values(pluginMap).flatMap(extractPlugins);
24
+ };
25
+ if (config.resolvers)
26
+ dependencies.push(...extractPlugins(config.resolvers));
27
+ if (config.transformers)
28
+ dependencies.push(...extractPluginsFromMap(config.transformers));
29
+ if (config.bundler)
30
+ dependencies.push(config.bundler);
31
+ if (config.namers)
32
+ dependencies.push(...extractPlugins(config.namers));
33
+ if (config.runtimes)
34
+ dependencies.push(...extractPluginsFromMap(config.runtimes));
35
+ if (config.packagers)
36
+ dependencies.push(...extractPluginsFromMap(config.packagers));
37
+ if (config.optimizers)
38
+ dependencies.push(...extractPluginsFromMap(config.optimizers));
39
+ if (config.compressors)
40
+ dependencies.push(...extractPluginsFromMap(config.compressors));
41
+ if (config.reporters)
42
+ dependencies.push(...extractPlugins(config.reporters));
43
+ if (config.validators)
44
+ dependencies.push(...extractPluginsFromMap(config.validators));
45
+ return dependencies.map(id => toDeferResolve(id));
46
+ };
47
+ const plugin = {
48
+ title,
49
+ enablers,
50
+ isEnabled,
51
+ config,
52
+ resolveConfig,
53
+ };
54
+ export default plugin;
@@ -0,0 +1,13 @@
1
+ export type ParcelConfig = {
2
+ extends?: string | string[];
3
+ resolvers?: string | string[];
4
+ transformers?: Record<string, string | string[]>;
5
+ bundler?: string;
6
+ namers?: string | string[];
7
+ runtimes?: Record<string, string | string[]>;
8
+ packagers?: Record<string, string | string[]>;
9
+ optimizers?: Record<string, string | string[]>;
10
+ compressors?: Record<string, string | string[]>;
11
+ reporters?: string | string[];
12
+ validators?: Record<string, string | string[]>;
13
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -337,6 +337,11 @@ export declare const workspaceConfigurationSchema: z.ZodMiniObject<{
337
337
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
338
338
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
339
339
  }, z.core.$strip>]>>;
340
+ parcel: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
341
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
342
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
343
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
344
+ }, z.core.$strip>]>>;
340
345
  playwright: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
341
346
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
342
347
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -979,6 +984,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
979
984
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
980
985
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
981
986
  }, z.core.$strip>]>>;
987
+ parcel: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
988
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
989
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
990
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
991
+ }, z.core.$strip>]>>;
982
992
  playwright: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
983
993
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
984
994
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -1610,6 +1620,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
1610
1620
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1611
1621
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1612
1622
  }, z.core.$strip>]>>;
1623
+ parcel: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1624
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1625
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1626
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1627
+ }, z.core.$strip>]>>;
1613
1628
  playwright: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1614
1629
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1615
1630
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -341,6 +341,11 @@ export declare const pluginsSchema: z.ZodMiniObject<{
341
341
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
342
342
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
343
343
  }, z.core.$strip>]>;
344
+ parcel: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
345
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
346
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
347
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
348
+ }, z.core.$strip>]>;
344
349
  playwright: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
345
350
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
346
351
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -77,6 +77,7 @@ export const pluginsSchema = z.object({
77
77
  nyc: pluginSchema,
78
78
  oclif: pluginSchema,
79
79
  oxlint: pluginSchema,
80
+ parcel: pluginSchema,
80
81
  playwright: pluginSchema,
81
82
  'playwright-ct': pluginSchema,
82
83
  'playwright-test': pluginSchema,
@@ -128,19 +128,19 @@ export const buildInternalImports = (fileNode, explorer, importLookup) => {
128
128
  });
129
129
  };
130
130
  for (const [importedFilePath, importMaps] of fileNode.imports.internal) {
131
- for (const identifier of importMaps.imported.keys()) {
131
+ for (const identifier of importMaps.import.keys()) {
132
132
  const _import = getImport(importedFilePath, identifier);
133
133
  addInternalImport(importedFilePath, identifier, _import.identifier, _import.line, _import.col);
134
134
  }
135
- for (const [identifier, aliasMap] of importMaps.importedAs) {
135
+ for (const [identifier, aliasMap] of importMaps.importAs) {
136
136
  for (const [alias] of aliasMap) {
137
137
  const _import = getImport(importedFilePath, identifier);
138
138
  addInternalImport(importedFilePath, identifier, alias, _import.line, _import.col);
139
139
  }
140
140
  }
141
- if (importMaps.importedNs.size > 0) {
141
+ if (importMaps.importNs.size > 0) {
142
142
  const _import = getImport(importedFilePath, IMPORT_STAR);
143
- for (const namespace of importMaps.importedNs.keys()) {
143
+ for (const namespace of importMaps.importNs.keys()) {
144
144
  addInternalImport(importedFilePath, namespace, namespace, _import.line, _import.col);
145
145
  }
146
146
  }
@@ -1,2 +1,2 @@
1
- export type PluginName = 'angular' | 'astro' | 'astro-db' | 'ava' | 'babel' | 'biome' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'eleventy' | 'eslint' | 'expo' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jest' | 'karma' | 'knex' | 'ladle' | 'lefthook' | 'lint-staged' | 'linthtml' | 'lockfile-lint' | 'lost-pixel' | 'markdownlint' | 'mdx' | 'mdxlint' | 'metro' | 'mocha' | 'moonrepo' | 'msw' | 'nano-staged' | 'nest' | 'netlify' | 'next' | 'next-intl' | 'next-mdx' | 'node' | 'node-modules-inspector' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nx' | 'nyc' | 'oclif' | 'oxlint' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'react-cosmos' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'semantic-release' | 'sentry' | 'simple-git-hooks' | 'size-limit' | 'sst' | 'starlight' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'svgo' | 'svgr' | 'swc' | 'syncpack' | 'tailwind' | 'tanstack-router' | 'taskfile' | 'travis' | 'ts-node' | 'tsdown' | 'tsup' | 'tsx' | 'typedoc' | 'typescript' | 'unbuild' | 'unocss' | 'vercel-og' | 'vike' | 'vite' | 'vitepress' | 'vitest' | 'vue' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'xo' | 'yarn' | 'yorkie';
2
- export declare const pluginNames: readonly ["angular", "astro", "astro-db", "ava", "babel", "biome", "bumpp", "bun", "c8", "capacitor", "changelogen", "changelogithub", "changesets", "commitizen", "commitlint", "convex", "create-typescript-app", "cspell", "cucumber", "cypress", "danger", "dependency-cruiser", "docusaurus", "dotenv", "drizzle", "eleventy", "eslint", "expo", "gatsby", "github-action", "github-actions", "glob", "graphql-codegen", "hardhat", "husky", "i18next-parser", "jest", "karma", "knex", "ladle", "lefthook", "lint-staged", "linthtml", "lockfile-lint", "lost-pixel", "markdownlint", "mdx", "mdxlint", "metro", "mocha", "moonrepo", "msw", "nano-staged", "nest", "netlify", "next", "next-intl", "next-mdx", "node", "node-modules-inspector", "nodemon", "npm-package-json-lint", "nuxt", "nx", "nyc", "oclif", "oxlint", "playwright", "playwright-ct", "playwright-test", "plop", "pnpm", "postcss", "preconstruct", "prettier", "prisma", "react-cosmos", "react-router", "relay", "release-it", "remark", "remix", "rollup", "rsbuild", "rslib", "rspack", "rstest", "semantic-release", "sentry", "simple-git-hooks", "size-limit", "sst", "starlight", "storybook", "stryker", "stylelint", "svelte", "svgo", "svgr", "swc", "syncpack", "tailwind", "tanstack-router", "taskfile", "travis", "ts-node", "tsdown", "tsup", "tsx", "typedoc", "typescript", "unbuild", "unocss", "vercel-og", "vike", "vite", "vitepress", "vitest", "vue", "webdriver-io", "webpack", "wireit", "wrangler", "xo", "yarn", "yorkie"];
1
+ export type PluginName = 'angular' | 'astro' | 'astro-db' | 'ava' | 'babel' | 'biome' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'eleventy' | 'eslint' | 'expo' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jest' | 'karma' | 'knex' | 'ladle' | 'lefthook' | 'lint-staged' | 'linthtml' | 'lockfile-lint' | 'lost-pixel' | 'markdownlint' | 'mdx' | 'mdxlint' | 'metro' | 'mocha' | 'moonrepo' | 'msw' | 'nano-staged' | 'nest' | 'netlify' | 'next' | 'next-intl' | 'next-mdx' | 'node' | 'node-modules-inspector' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nx' | 'nyc' | 'oclif' | 'oxlint' | 'parcel' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'react-cosmos' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'semantic-release' | 'sentry' | 'simple-git-hooks' | 'size-limit' | 'sst' | 'starlight' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'svgo' | 'svgr' | 'swc' | 'syncpack' | 'tailwind' | 'tanstack-router' | 'taskfile' | 'travis' | 'ts-node' | 'tsdown' | 'tsup' | 'tsx' | 'typedoc' | 'typescript' | 'unbuild' | 'unocss' | 'vercel-og' | 'vike' | 'vite' | 'vitepress' | 'vitest' | 'vue' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'xo' | 'yarn' | 'yorkie';
2
+ export declare const pluginNames: readonly ["angular", "astro", "astro-db", "ava", "babel", "biome", "bumpp", "bun", "c8", "capacitor", "changelogen", "changelogithub", "changesets", "commitizen", "commitlint", "convex", "create-typescript-app", "cspell", "cucumber", "cypress", "danger", "dependency-cruiser", "docusaurus", "dotenv", "drizzle", "eleventy", "eslint", "expo", "gatsby", "github-action", "github-actions", "glob", "graphql-codegen", "hardhat", "husky", "i18next-parser", "jest", "karma", "knex", "ladle", "lefthook", "lint-staged", "linthtml", "lockfile-lint", "lost-pixel", "markdownlint", "mdx", "mdxlint", "metro", "mocha", "moonrepo", "msw", "nano-staged", "nest", "netlify", "next", "next-intl", "next-mdx", "node", "node-modules-inspector", "nodemon", "npm-package-json-lint", "nuxt", "nx", "nyc", "oclif", "oxlint", "parcel", "playwright", "playwright-ct", "playwright-test", "plop", "pnpm", "postcss", "preconstruct", "prettier", "prisma", "react-cosmos", "react-router", "relay", "release-it", "remark", "remix", "rollup", "rsbuild", "rslib", "rspack", "rstest", "semantic-release", "sentry", "simple-git-hooks", "size-limit", "sst", "starlight", "storybook", "stryker", "stylelint", "svelte", "svgo", "svgr", "swc", "syncpack", "tailwind", "tanstack-router", "taskfile", "travis", "ts-node", "tsdown", "tsup", "tsx", "typedoc", "typescript", "unbuild", "unocss", "vercel-og", "vike", "vite", "vitepress", "vitest", "vue", "webdriver-io", "webpack", "wireit", "wrangler", "xo", "yarn", "yorkie"];
@@ -66,6 +66,7 @@ export const pluginNames = [
66
66
  'nyc',
67
67
  'oclif',
68
68
  'oxlint',
69
+ 'parcel',
69
70
  'playwright',
70
71
  'playwright-ct',
71
72
  'playwright-test',
@@ -15,12 +15,12 @@ export type IdToFileMap = Map<Identifier, Set<FilePath>>;
15
15
  export type IdToNsToFileMap = Map<Identifier, Map<NamespaceOrAlias, Set<FilePath>>>;
16
16
  export type ImportMaps = {
17
17
  refs: References;
18
- imported: IdToFileMap;
19
- importedAs: IdToNsToFileMap;
20
- importedNs: IdToFileMap;
21
- reExported: IdToFileMap;
22
- reExportedAs: IdToNsToFileMap;
23
- reExportedNs: IdToFileMap;
18
+ import: IdToFileMap;
19
+ importAs: IdToNsToFileMap;
20
+ importNs: IdToFileMap;
21
+ reExport: IdToFileMap;
22
+ reExportNs: IdToFileMap;
23
+ reExportAs: IdToNsToFileMap;
24
24
  };
25
25
  export type ImportMap = Map<FilePath, ImportMaps>;
26
26
  export interface Import extends Position {
@@ -66,7 +66,7 @@ export type FileNode = {
66
66
  exports: ExportMap;
67
67
  duplicates: Iterable<Array<IssueSymbol>>;
68
68
  scripts: Set<string>;
69
- imported: undefined | ImportMaps;
69
+ importedBy: undefined | ImportMaps;
70
70
  internalImportCache: undefined | ImportMap;
71
71
  };
72
72
  export type ModuleGraph = Map<FilePath, FileNode>;
@@ -1,3 +1,3 @@
1
1
  import ts from 'typescript';
2
2
  import type { ExportWithSymbol, MemberWithSymbol } from './get-imports-and-exports.js';
3
- export declare const hasRefsInFile: (item: ExportWithSymbol | MemberWithSymbol, sourceFile: ts.SourceFile, typeChecker: ts.TypeChecker) => boolean;
3
+ export declare const _hasRefsInFile: (item: ExportWithSymbol | MemberWithSymbol, sourceFile: ts.SourceFile, typeChecker: ts.TypeChecker) => boolean;
@@ -1,4 +1,5 @@
1
1
  import ts from 'typescript';
2
+ import { timerify } from '../util/Performance.js';
2
3
  import { isIdChar } from '../util/regex.js';
3
4
  const findInFlow = (flowNode, targetSymbol) => {
4
5
  if (!flowNode?.node)
@@ -7,7 +8,7 @@ const findInFlow = (flowNode, targetSymbol) => {
7
8
  return true;
8
9
  return findInFlow(flowNode.antecedent, targetSymbol);
9
10
  };
10
- export const hasRefsInFile = (item, sourceFile, typeChecker) => {
11
+ const hasRefsInFile = (item, sourceFile, typeChecker) => {
11
12
  if (!item.symbol)
12
13
  return false;
13
14
  if (item.identifier === '')
@@ -46,3 +47,4 @@ export const hasRefsInFile = (item, sourceFile, typeChecker) => {
46
47
  }
47
48
  return false;
48
49
  };
50
+ export const _hasRefsInFile = timerify(hasRefsInFile);
@@ -7,7 +7,7 @@ import { timerify } from '../util/Performance.js';
7
7
  import { dirname, isInNodeModules, resolve } from '../util/path.js';
8
8
  import { shouldIgnore } from '../util/tag.js';
9
9
  import { getAccessMembers, getDestructuredNames, getJSDocTags, getLineAndCharacterOfPosition, getTypeRef, isAccessExpression, isConsiderReferencedNS, isDestructuring, isImportSpecifier, isInForIteration, isObjectEnumerationCallExpressionArgument, isReferencedInExport, } from './ast-helpers.js';
10
- import { hasRefsInFile } from './find-internal-references.js';
10
+ import { _hasRefsInFile } from './find-internal-references.js';
11
11
  import { getImportsFromPragmas } from './pragmas/index.js';
12
12
  import getDynamicImportVisitors from './visitors/dynamic-imports/index.js';
13
13
  import getExportVisitors from './visitors/exports/index.js';
@@ -105,26 +105,26 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
105
105
  const nsOrAlias = symbol ? String(symbol.escapedName) : options.alias;
106
106
  if (modifiers & IMPORT_FLAGS.RE_EXPORT) {
107
107
  if (isStar && namespace) {
108
- addValue(importMaps.reExportedNs, namespace, sourceFile.fileName);
108
+ addValue(importMaps.reExportNs, namespace, sourceFile.fileName);
109
109
  }
110
110
  else if (nsOrAlias) {
111
- addNsValue(importMaps.reExportedAs, identifier, nsOrAlias, sourceFile.fileName);
111
+ addNsValue(importMaps.reExportAs, identifier, nsOrAlias, sourceFile.fileName);
112
112
  }
113
113
  else {
114
- addValue(importMaps.reExported, identifier, sourceFile.fileName);
114
+ addValue(importMaps.reExport, identifier, sourceFile.fileName);
115
115
  }
116
116
  }
117
117
  else {
118
118
  if (nsOrAlias && nsOrAlias !== identifier) {
119
119
  if (isStar) {
120
- addValue(importMaps.importedNs, nsOrAlias, sourceFile.fileName);
120
+ addValue(importMaps.importNs, nsOrAlias, sourceFile.fileName);
121
121
  }
122
122
  else {
123
- addNsValue(importMaps.importedAs, identifier, nsOrAlias, sourceFile.fileName);
123
+ addNsValue(importMaps.importAs, identifier, nsOrAlias, sourceFile.fileName);
124
124
  }
125
125
  }
126
126
  else if (identifier !== IMPORT_STAR) {
127
- addValue(importMaps.imported, identifier, sourceFile.fileName);
127
+ addValue(importMaps.import, identifier, sourceFile.fileName);
128
128
  }
129
129
  if (symbol)
130
130
  importedInternalSymbols.set(symbol, filePath);
@@ -209,13 +209,13 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
209
209
  const internalImport = internal.get(importedSymbolFilePath);
210
210
  if (internalImport) {
211
211
  if (importId !== identifier) {
212
- addNsValue(internalImport.reExportedAs, importId, identifier, sourceFile.fileName);
212
+ addNsValue(internalImport.reExportAs, importId, identifier, sourceFile.fileName);
213
213
  }
214
214
  else if (symbol.declarations && ts.isNamespaceImport(symbol.declarations[0])) {
215
- addValue(internalImport.reExportedNs, identifier, sourceFile.fileName);
215
+ addValue(internalImport.reExportNs, identifier, sourceFile.fileName);
216
216
  }
217
217
  else {
218
- addValue(internalImport.reExported, importId, sourceFile.fileName);
218
+ addValue(internalImport.reExport, importId, sourceFile.fileName);
219
219
  }
220
220
  }
221
221
  }
@@ -354,7 +354,7 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
354
354
  if (_node && ts.isIdentifier(_node.name)) {
355
355
  const varName = _node.name.text;
356
356
  if (exports.has(varName)) {
357
- addNsValue(imports.reExportedAs, id, [varName, ...path].join('.'), sourceFile.fileName);
357
+ addNsValue(imports.reExportAs, id, [varName, ...path].join('.'), sourceFile.fileName);
358
358
  }
359
359
  else if (path.length === 0) {
360
360
  addImportAlias(varName, id, filePath);
@@ -380,7 +380,7 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
380
380
  ts.isIdentifier(node.parent.name)) {
381
381
  const aliasName = node.parent.name.text;
382
382
  if (exports.has(aliasName)) {
383
- addNsValue(imports.reExportedAs, id, aliasName, sourceFile.fileName);
383
+ addNsValue(imports.reExportAs, id, aliasName, sourceFile.fileName);
384
384
  }
385
385
  else {
386
386
  addImportAlias(aliasName, id, filePath);
@@ -403,7 +403,7 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
403
403
  addImportAlias(`${_node.name.text}.${id}`, id, filePath);
404
404
  imports.refs.add(id);
405
405
  }
406
- else if (imports.importedNs.has(id) && isConsiderReferencedNS(node)) {
406
+ else if (imports.importNs.has(id) && isConsiderReferencedNS(node)) {
407
407
  imports.refs.add(id);
408
408
  }
409
409
  else if (isObjectEnumerationCallExpressionArgument(node)) {
@@ -440,11 +440,11 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
440
440
  item.referencedIn = referencedInExport.get(id);
441
441
  if (shouldCountRefs(ignoreExportsUsedInFile, item.type) ||
442
442
  (item.symbol?.valueDeclaration && ts.isBindingElement(item.symbol.valueDeclaration))) {
443
- item.hasRefsInFile = hasRefsInFile(item, sourceFile, typeChecker);
443
+ item.hasRefsInFile = _hasRefsInFile(item, sourceFile, typeChecker);
444
444
  }
445
445
  for (const member of item.members) {
446
446
  if (item.type === 'enum' || shouldCountRefs(ignoreExportsUsedInFile, member.type)) {
447
- member.hasRefsInFile = hasRefsInFile(member, sourceFile, typeChecker);
447
+ member.hasRefsInFile = _hasRefsInFile(member, sourceFile, typeChecker);
448
448
  }
449
449
  delete member.symbol;
450
450
  }
@@ -455,7 +455,7 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
455
455
  exports,
456
456
  duplicates: [...aliasedExports.values()],
457
457
  scripts,
458
- imported: undefined,
458
+ importedBy: undefined,
459
459
  internalImportCache: undefined,
460
460
  };
461
461
  };
@@ -380,6 +380,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
380
380
  entry?: string | string[] | undefined;
381
381
  project?: string | string[] | undefined;
382
382
  } | undefined;
383
+ parcel?: string | boolean | string[] | {
384
+ config?: string | string[] | undefined;
385
+ entry?: string | string[] | undefined;
386
+ project?: string | string[] | undefined;
387
+ } | undefined;
383
388
  playwright?: string | boolean | string[] | {
384
389
  config?: string | string[] | undefined;
385
390
  entry?: string | string[] | undefined;
@@ -1011,6 +1016,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
1011
1016
  entry?: string | string[] | undefined;
1012
1017
  project?: string | string[] | undefined;
1013
1018
  } | undefined;
1019
+ parcel?: string | boolean | string[] | {
1020
+ config?: string | string[] | undefined;
1021
+ entry?: string | string[] | undefined;
1022
+ project?: string | string[] | undefined;
1023
+ } | undefined;
1014
1024
  playwright?: string | boolean | string[] | {
1015
1025
  config?: string | string[] | undefined;
1016
1026
  entry?: string | string[] | undefined;
@@ -1,31 +1,31 @@
1
1
  const updateImportMaps = (fromImportMaps, toImportMaps) => {
2
2
  for (const id of fromImportMaps.refs)
3
3
  toImportMaps.refs.add(id);
4
- for (const [id, v] of fromImportMaps.imported)
5
- addValues(toImportMaps.imported, id, v);
6
- for (const [id, v] of fromImportMaps.importedAs)
7
- addNsValues(toImportMaps.importedAs, id, v);
8
- for (const [id, v] of fromImportMaps.importedNs)
9
- addValues(toImportMaps.importedNs, id, v);
10
- for (const [id, v] of fromImportMaps.reExported)
11
- addValues(toImportMaps.reExported, id, v);
12
- for (const [id, v] of fromImportMaps.reExportedAs)
13
- addNsValues(toImportMaps.reExportedAs, id, v);
14
- for (const [id, v] of fromImportMaps.reExportedNs)
15
- addValues(toImportMaps.reExportedNs, id, v);
4
+ for (const [id, v] of fromImportMaps.import)
5
+ addValues(toImportMaps.import, id, v);
6
+ for (const [id, v] of fromImportMaps.importAs)
7
+ addNsValues(toImportMaps.importAs, id, v);
8
+ for (const [id, v] of fromImportMaps.importNs)
9
+ addValues(toImportMaps.importNs, id, v);
10
+ for (const [id, v] of fromImportMaps.reExport)
11
+ addValues(toImportMaps.reExport, id, v);
12
+ for (const [id, v] of fromImportMaps.reExportAs)
13
+ addNsValues(toImportMaps.reExportAs, id, v);
14
+ for (const [id, v] of fromImportMaps.reExportNs)
15
+ addValues(toImportMaps.reExportNs, id, v);
16
16
  };
17
17
  export const updateImportMap = (file, importMap, graph) => {
18
- for (const [importedFilePath, fileImportMaps] of importMap) {
19
- const importMaps = file.imports.internal.get(importedFilePath);
18
+ for (const [importedByFilePath, fileImportMaps] of importMap) {
19
+ const importMaps = file.imports.internal.get(importedByFilePath);
20
20
  if (!importMaps)
21
- file.imports.internal.set(importedFilePath, fileImportMaps);
21
+ file.imports.internal.set(importedByFilePath, fileImportMaps);
22
22
  else
23
23
  updateImportMaps(fileImportMaps, importMaps);
24
- const importedFile = graph.get(importedFilePath) ?? createFileNode();
25
- if (!importedFile.imported)
26
- importedFile.imported = createImports();
27
- updateImportMaps(fileImportMaps, importedFile.imported);
28
- graph.set(importedFilePath, importedFile);
24
+ const importedByFile = graph.get(importedByFilePath) ?? createFileNode();
25
+ if (!importedByFile.importedBy)
26
+ importedByFile.importedBy = createImports();
27
+ updateImportMaps(fileImportMaps, importedByFile.importedBy);
28
+ graph.set(importedByFilePath, importedByFile);
29
29
  }
30
30
  };
31
31
  export const createFileNode = () => ({
@@ -41,17 +41,17 @@ export const createFileNode = () => ({
41
41
  exports: new Map(),
42
42
  duplicates: new Set(),
43
43
  scripts: new Set(),
44
- imported: undefined,
44
+ importedBy: undefined,
45
45
  internalImportCache: undefined,
46
46
  });
47
47
  export const createImports = () => ({
48
48
  refs: new Set(),
49
- imported: new Map(),
50
- importedAs: new Map(),
51
- importedNs: new Map(),
52
- reExported: new Map(),
53
- reExportedAs: new Map(),
54
- reExportedNs: new Map(),
49
+ import: new Map(),
50
+ importAs: new Map(),
51
+ importNs: new Map(),
52
+ reExport: new Map(),
53
+ reExportAs: new Map(),
54
+ reExportNs: new Map(),
55
55
  });
56
56
  export const addValue = (map, id, value) => {
57
57
  if (map.has(id))
@@ -8,7 +8,7 @@ export const formatTrace = (node, toRelative, isReferenced) => {
8
8
  const ok = pc.green;
9
9
  const fail = pc.red;
10
10
  const dim = pc.dim;
11
- const entryMarker = node.isEntry ? dim(' ') : '';
11
+ const entryMarker = node.isEntry ? dim(' ') : '';
12
12
  lines.push(`${file(toRelative(node.filePath))}${dim(':')}${id(node.identifier)}${entryMarker}`);
13
13
  const formatVia = (child) => {
14
14
  if (!child.via)
@@ -22,7 +22,7 @@ export const formatTrace = (node, toRelative, isReferenced) => {
22
22
  const formatChild = (child, prefix, isLast) => {
23
23
  const connector = isLast ? '└── ' : '├── ';
24
24
  const childPrefix = isLast ? ' ' : '│ ';
25
- const entryMarker = child.isEntry ? dim(' ') : '';
25
+ const entryMarker = child.isEntry ? dim(' ') : '';
26
26
  const isLeaf = child.children.length === 0;
27
27
  const leafMarker = isLeaf && !child.via?.startsWith('reExport') ? (isReferenced ? ok(' ✓') : fail(' ✗')) : '';
28
28
  lines.push(`${dim(prefix)}${dim(connector)}${file(toRelative(child.filePath))}${dim(':')}${formatVia(child)}${entryMarker}${leafMarker}`);
@@ -71,7 +71,7 @@ export const getSessionHandler = async (options, { analyzedFiles, analyzeSourceF
71
71
  else {
72
72
  for (const [filePath, file] of graph) {
73
73
  if (filePaths.includes(filePath)) {
74
- file.imported = undefined;
74
+ file.importedBy = undefined;
75
75
  }
76
76
  else {
77
77
  graph.delete(filePath);
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.79.0";
1
+ export declare const version = "5.80.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.79.0';
1
+ export const version = '5.80.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.79.0",
3
+ "version": "5.80.0",
4
4
  "description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://knip.dev",
6
6
  "repository": {