knip 5.79.0 → 5.80.1

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 (51) hide show
  1. package/dist/ConfigurationChief.d.ts +6 -0
  2. package/dist/ProjectPrincipal.js +1 -1
  3. package/dist/cli.js +5 -2
  4. package/dist/compilers/index.d.ts +10 -0
  5. package/dist/compilers/scss.d.ts +2 -2
  6. package/dist/compilers/scss.js +16 -10
  7. package/dist/graph/analyze.js +1 -1
  8. package/dist/graph/build.js +1 -1
  9. package/dist/graph-explorer/explorer.js +1 -1
  10. package/dist/graph-explorer/operations/build-exports-tree.js +2 -2
  11. package/dist/graph-explorer/operations/get-contention.js +4 -4
  12. package/dist/graph-explorer/operations/has-strictly-ns-references.d.ts +1 -1
  13. package/dist/graph-explorer/operations/has-strictly-ns-references.js +73 -88
  14. package/dist/graph-explorer/operations/is-referenced.js +23 -24
  15. package/dist/graph-explorer/visitors.js +7 -7
  16. package/dist/graph-explorer/walk-down.js +8 -8
  17. package/dist/plugins/bun/index.js +1 -1
  18. package/dist/plugins/index.d.ts +1 -0
  19. package/dist/plugins/index.js +2 -0
  20. package/dist/plugins/node/index.js +1 -1
  21. package/dist/plugins/nx/index.js +24 -2
  22. package/dist/plugins/nx/types.d.ts +5 -0
  23. package/dist/plugins/parcel/index.d.ts +3 -0
  24. package/dist/plugins/parcel/index.js +54 -0
  25. package/dist/plugins/parcel/types.d.ts +13 -0
  26. package/dist/plugins/parcel/types.js +1 -0
  27. package/dist/plugins/react-router/index.js +3 -3
  28. package/dist/plugins/size-limit/index.js +2 -5
  29. package/dist/plugins/tanstack-router/index.js +13 -2
  30. package/dist/plugins/tanstack-router/types.d.ts +22 -0
  31. package/dist/plugins/tanstack-router/types.js +1 -0
  32. package/dist/schema/configuration.d.ts +15 -0
  33. package/dist/schema/plugins.d.ts +5 -0
  34. package/dist/schema/plugins.js +1 -0
  35. package/dist/session/build-maps.js +4 -4
  36. package/dist/types/PluginNames.d.ts +2 -2
  37. package/dist/types/PluginNames.js +1 -0
  38. package/dist/types/module-graph.d.ts +7 -7
  39. package/dist/typescript/find-internal-references.d.ts +1 -1
  40. package/dist/typescript/find-internal-references.js +3 -1
  41. package/dist/typescript/get-imports-and-exports.js +16 -16
  42. package/dist/util/create-options.d.ts +10 -0
  43. package/dist/util/errors.d.ts +1 -0
  44. package/dist/util/errors.js +1 -0
  45. package/dist/util/map-workspaces.js +1 -1
  46. package/dist/util/module-graph.js +27 -27
  47. package/dist/util/trace.js +2 -2
  48. package/dist/util/watch.js +1 -1
  49. package/dist/version.d.ts +1 -1
  50. package/dist/version.js +1 -1
  51. 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
  }
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@ import { fix } from './IssueFixer.js';
2
2
  import { run } from './run.js';
3
3
  import parseArgs, { helpText } from './util/cli-arguments.js';
4
4
  import { createOptions } from './util/create-options.js';
5
- import { getKnownErrors, hasErrorCause, isConfigurationError, isKnownError } from './util/errors.js';
5
+ import { getKnownErrors, hasErrorCause, isConfigurationError, isKnownError, isModuleNotFoundError, } from './util/errors.js';
6
6
  import { logError, logWarning } from './util/log.js';
7
7
  import { perfObserver } from './util/Performance.js';
8
8
  import { runPreprocessors, runReporters } from './util/reporter.js';
@@ -88,8 +88,11 @@ const main = async () => {
88
88
  const knownErrors = getKnownErrors(error);
89
89
  for (const knownError of knownErrors)
90
90
  logError('ERROR', knownError.message);
91
- if (hasErrorCause(knownErrors[0]))
91
+ if (hasErrorCause(knownErrors[0])) {
92
92
  console.error('Reason:', knownErrors[0].cause.message);
93
+ if (isModuleNotFoundError(knownErrors[0].cause))
94
+ console.log('Module load error? Visit https://knip.dev/reference/known-issues');
95
+ }
93
96
  if (isConfigurationError(knownErrors[0]))
94
97
  console.log('\nRun `knip --help` or visit https://knip.dev for help');
95
98
  process.exit(2);
@@ -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;
@@ -1,6 +1,6 @@
1
- import type { HasDependency } from './types.js';
1
+ import type { HasDependency, SyncCompilerFn } from './types.js';
2
2
  declare const _default: {
3
3
  condition: (hasDependency: HasDependency) => boolean;
4
- compiler: (text: string) => string;
4
+ compiler: SyncCompilerFn;
5
5
  };
6
6
  export default _default;
@@ -1,14 +1,20 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { basename, dirname, join } from '../util/path.js';
1
3
  const condition = (hasDependency) => hasDependency('sass') || hasDependency('sass-embedded') || hasDependency('node-sass');
2
4
  const importMatcher = /@(?:use|import|forward)\s+['"](pkg:)?([^'"]+)['"]/g;
3
- const toRelative = (specifier) => (specifier.startsWith('.') ? specifier : `./${specifier}`);
4
- const compiler = (text) => {
5
- const imports = [];
6
- let match;
7
- let index = 0;
8
- while ((match = importMatcher.exec(text))) {
9
- if (match[2] && !match[2].startsWith('sass:'))
10
- imports.push(`import _$${index++} from '${match[1] ? match[2] : toRelative(match[2])}';`);
11
- }
12
- return imports.join('\n');
5
+ const resolvePartial = (specifier, containingFile) => {
6
+ const rel = specifier.startsWith('.') ? specifier : `./${specifier}`;
7
+ const name = basename(rel);
8
+ if (name.startsWith('_'))
9
+ return rel;
10
+ const dir = dirname(rel);
11
+ const partial = name.endsWith('.scss') ? `_${name}` : `_${name}.scss`;
12
+ if (existsSync(join(dirname(containingFile), dir, partial)))
13
+ return `${dir}/_${name}`;
14
+ return rel;
13
15
  };
16
+ const compiler = (text, filePath) => [...text.matchAll(importMatcher)]
17
+ .filter(match => match[2] && !match[2].startsWith('sass:'))
18
+ .map((match, i) => `import _$${i} from '${match[1] ? match[2] : resolvePartial(match[2], filePath)}';`)
19
+ .join('\n');
14
20
  export default { condition, compiler };
@@ -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) {
@@ -5,7 +5,7 @@ const enablers = ['bun'];
5
5
  const hasBunTest = (scripts) => scripts && Object.values(scripts).some(script => /(?<=^|\s)bun test/.test(script));
6
6
  const isEnabled = ({ manifest }) => !!hasBunTest(manifest.scripts);
7
7
  const patterns = ['**/*.{test,spec}.{js,jsx,ts,tsx}', '**/*_{test,spec}.{js,jsx,ts,tsx}'];
8
- const resolve = (options) => {
8
+ const resolve = options => {
9
9
  const scripts = { ...options.rootManifest?.scripts, ...options.manifest.scripts };
10
10
  for (const script of Object.values(scripts)) {
11
11
  if (/(?<=^|\s)bun test/.test(script)) {
@@ -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,
@@ -9,7 +9,7 @@ const patterns = [
9
9
  ];
10
10
  const hasNodeTest = (scripts) => scripts && Object.values(scripts).some(script => /(?<=^|\s)node\s(.*)--test/.test(script));
11
11
  const entry = ['server.js'];
12
- const resolve = (options) => {
12
+ const resolve = options => {
13
13
  const entries = entry.map(id => toProductionEntry(id));
14
14
  if (hasNodeTest(options.manifest.scripts) || hasNodeTest(options.rootManifest?.scripts)) {
15
15
  entries.push(...patterns.map(toEntry));