knip 5.71.0 → 5.73.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 (64) hide show
  1. package/dist/ConfigurationChief.d.ts +18 -0
  2. package/dist/ConsoleStreamer.js +1 -1
  3. package/dist/compilers/index.d.ts +30 -0
  4. package/dist/compilers/index.js +3 -0
  5. package/dist/compilers/scss.d.ts +6 -0
  6. package/dist/compilers/scss.js +14 -0
  7. package/dist/constants.js +1 -0
  8. package/dist/graph/analyze.js +19 -8
  9. package/dist/graph-explorer/explorer.d.ts +1 -1
  10. package/dist/graph-explorer/explorer.js +1 -1
  11. package/dist/graph-explorer/operations/{build-trace-tree.d.ts → build-exports-tree.d.ts} +4 -1
  12. package/dist/graph-explorer/operations/build-exports-tree.js +96 -0
  13. package/dist/graph-explorer/operations/is-referenced.js +4 -4
  14. package/dist/graph-explorer/utils.d.ts +1 -2
  15. package/dist/graph-explorer/utils.js +0 -15
  16. package/dist/graph-explorer/walk-down.d.ts +2 -1
  17. package/dist/graph-explorer/walk-down.js +7 -10
  18. package/dist/plugins/index.d.ts +3 -0
  19. package/dist/plugins/index.js +6 -0
  20. package/dist/plugins/next/index.js +3 -5
  21. package/dist/plugins/next/resolveFromAST.d.ts +0 -1
  22. package/dist/plugins/next/resolveFromAST.js +1 -42
  23. package/dist/plugins/next-intl/index.d.ts +3 -0
  24. package/dist/plugins/next-intl/index.js +12 -0
  25. package/dist/plugins/next-mdx/index.d.ts +3 -0
  26. package/dist/plugins/next-mdx/index.js +21 -0
  27. package/dist/plugins/next-mdx/resolveFromAST.d.ts +2 -0
  28. package/dist/plugins/next-mdx/resolveFromAST.js +43 -0
  29. package/dist/plugins/rsbuild/index.js +8 -0
  30. package/dist/plugins/rsbuild/types.d.ts +1 -0
  31. package/dist/plugins/storybook/index.js +12 -4
  32. package/dist/plugins/storybook/types.d.ts +5 -0
  33. package/dist/plugins/svgo/index.js +1 -1
  34. package/dist/plugins/svgr/index.d.ts +3 -0
  35. package/dist/plugins/svgr/index.js +24 -0
  36. package/dist/plugins/svgr/types.d.ts +3 -0
  37. package/dist/plugins/svgr/types.js +1 -0
  38. package/dist/plugins/vite/index.js +4 -0
  39. package/dist/plugins/vitest/index.js +1 -1
  40. package/dist/schema/configuration.d.ts +30 -0
  41. package/dist/schema/plugins.d.ts +15 -0
  42. package/dist/schema/plugins.js +3 -0
  43. package/dist/types/PluginNames.d.ts +2 -2
  44. package/dist/types/PluginNames.js +3 -0
  45. package/dist/types/module-graph.d.ts +2 -3
  46. package/dist/typescript/ast-helpers.d.ts +1 -1
  47. package/dist/typescript/ast-helpers.js +0 -3
  48. package/dist/typescript/get-imports-and-exports.js +74 -11
  49. package/dist/typescript/resolve-module-names.js +5 -4
  50. package/dist/typescript/visitors/dynamic-imports/requireCall.js +2 -1
  51. package/dist/util/Performance.js +4 -2
  52. package/dist/util/create-options.d.ts +30 -0
  53. package/dist/util/create-options.js +7 -3
  54. package/dist/util/module-graph.js +0 -1
  55. package/dist/util/modules.js +8 -4
  56. package/dist/util/resolve.d.ts +3 -2
  57. package/dist/util/resolve.js +25 -2
  58. package/dist/util/trace.d.ts +2 -10
  59. package/dist/util/trace.js +42 -36
  60. package/dist/version.d.ts +1 -1
  61. package/dist/version.js +1 -1
  62. package/package.json +7 -7
  63. package/schema.json +12 -0
  64. package/dist/graph-explorer/operations/build-trace-tree.js +0 -51
@@ -327,6 +327,16 @@ export declare class ConfigurationChief {
327
327
  entry?: string | string[] | undefined;
328
328
  project?: string | string[] | undefined;
329
329
  } | undefined;
330
+ 'next-intl'?: string | boolean | string[] | {
331
+ config?: string | string[] | undefined;
332
+ entry?: string | string[] | undefined;
333
+ project?: string | string[] | undefined;
334
+ } | undefined;
335
+ 'next-mdx'?: string | boolean | string[] | {
336
+ config?: string | string[] | undefined;
337
+ entry?: string | string[] | undefined;
338
+ project?: string | string[] | undefined;
339
+ } | undefined;
330
340
  node?: string | boolean | string[] | {
331
341
  config?: string | string[] | undefined;
332
342
  entry?: string | string[] | undefined;
@@ -527,6 +537,11 @@ export declare class ConfigurationChief {
527
537
  entry?: string | string[] | undefined;
528
538
  project?: string | string[] | undefined;
529
539
  } | undefined;
540
+ svgr?: string | boolean | string[] | {
541
+ config?: string | string[] | undefined;
542
+ entry?: string | string[] | undefined;
543
+ project?: string | string[] | undefined;
544
+ } | undefined;
530
545
  syncpack?: string | boolean | string[] | {
531
546
  config?: string | string[] | undefined;
532
547
  entry?: string | string[] | undefined;
@@ -723,6 +738,8 @@ export declare class ConfigurationChief {
723
738
  nest?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
724
739
  netlify?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
725
740
  next?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
741
+ "next-intl"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
742
+ "next-mdx"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
726
743
  "node-modules-inspector"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
727
744
  nodemon?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
728
745
  "npm-package-json-lint"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
@@ -761,6 +778,7 @@ export declare class ConfigurationChief {
761
778
  stylelint?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
762
779
  svelte?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
763
780
  svgo?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
781
+ svgr?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
764
782
  syncpack?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
765
783
  tailwind?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
766
784
  taskfile?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
@@ -3,7 +3,7 @@ export class ConsoleStreamer {
3
3
  isWatch = false;
4
4
  lines = 0;
5
5
  constructor(options) {
6
- this.isEnabled = options.isShowProgress && !options.isDebug;
6
+ this.isEnabled = options.isShowProgress;
7
7
  this.isWatch = options.isWatch;
8
8
  }
9
9
  clearLines(count) {
@@ -279,6 +279,16 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
279
279
  entry?: string | string[] | undefined;
280
280
  project?: string | string[] | undefined;
281
281
  } | undefined;
282
+ 'next-intl'?: string | boolean | string[] | {
283
+ config?: string | string[] | undefined;
284
+ entry?: string | string[] | undefined;
285
+ project?: string | string[] | undefined;
286
+ } | undefined;
287
+ 'next-mdx'?: string | boolean | string[] | {
288
+ config?: string | string[] | undefined;
289
+ entry?: string | string[] | undefined;
290
+ project?: string | string[] | undefined;
291
+ } | undefined;
282
292
  node?: string | boolean | string[] | {
283
293
  config?: string | string[] | undefined;
284
294
  entry?: string | string[] | undefined;
@@ -479,6 +489,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
479
489
  entry?: string | string[] | undefined;
480
490
  project?: string | string[] | undefined;
481
491
  } | undefined;
492
+ svgr?: string | boolean | string[] | {
493
+ config?: string | string[] | undefined;
494
+ entry?: string | string[] | undefined;
495
+ project?: string | string[] | undefined;
496
+ } | undefined;
482
497
  syncpack?: string | boolean | string[] | {
483
498
  config?: string | string[] | undefined;
484
499
  entry?: string | string[] | undefined;
@@ -875,6 +890,16 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
875
890
  entry?: string | string[] | undefined;
876
891
  project?: string | string[] | undefined;
877
892
  } | undefined;
893
+ 'next-intl'?: string | boolean | string[] | {
894
+ config?: string | string[] | undefined;
895
+ entry?: string | string[] | undefined;
896
+ project?: string | string[] | undefined;
897
+ } | undefined;
898
+ 'next-mdx'?: string | boolean | string[] | {
899
+ config?: string | string[] | undefined;
900
+ entry?: string | string[] | undefined;
901
+ project?: string | string[] | undefined;
902
+ } | undefined;
878
903
  node?: string | boolean | string[] | {
879
904
  config?: string | string[] | undefined;
880
905
  entry?: string | string[] | undefined;
@@ -1075,6 +1100,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
1075
1100
  entry?: string | string[] | undefined;
1076
1101
  project?: string | string[] | undefined;
1077
1102
  } | undefined;
1103
+ svgr?: string | boolean | string[] | {
1104
+ config?: string | string[] | undefined;
1105
+ entry?: string | string[] | undefined;
1106
+ project?: string | string[] | undefined;
1107
+ } | undefined;
1078
1108
  syncpack?: string | boolean | string[] | {
1079
1109
  config?: string | string[] | undefined;
1080
1110
  entry?: string | string[] | undefined;
@@ -2,6 +2,7 @@ import Astro from './astro.js';
2
2
  import AstroMDX from './astro-mdx.js';
3
3
  import MDX from './mdx.js';
4
4
  import Prisma from './prisma.js';
5
+ import SCSS from './scss.js';
5
6
  import Svelte from './svelte.js';
6
7
  import CSS from './tailwind.js';
7
8
  import Vue from './vue.js';
@@ -33,6 +34,8 @@ const compilers = new Map([
33
34
  ['.css', CSS],
34
35
  ['.mdx', MDX],
35
36
  ['.prisma', Prisma],
37
+ ['.sass', SCSS],
38
+ ['.scss', SCSS],
36
39
  ['.svelte', Svelte],
37
40
  ['.vue', Vue],
38
41
  ]);
@@ -0,0 +1,6 @@
1
+ import type { HasDependency } from './types.js';
2
+ declare const _default: {
3
+ condition: (hasDependency: HasDependency) => boolean;
4
+ compiler: (text: string) => string;
5
+ };
6
+ export default _default;
@@ -0,0 +1,14 @@
1
+ const condition = (hasDependency) => hasDependency('sass') || hasDependency('sass-embedded') || hasDependency('node-sass');
2
+ 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])
10
+ imports.push(`import _$${index++} from '${match[1] ? match[2] : toRelative(match[2])}';`);
11
+ }
12
+ return imports.join('\n');
13
+ };
14
+ export default { condition, compiler };
package/dist/constants.js CHANGED
@@ -34,6 +34,7 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
34
34
  'chmod',
35
35
  'chown',
36
36
  'cksum',
37
+ 'clear',
37
38
  'cmd',
38
39
  'comm',
39
40
  'command',
@@ -1,16 +1,17 @@
1
1
  import { createGraphExplorer } from '../graph-explorer/explorer.js';
2
2
  import { getIssueType, hasStrictlyEnumReferences } from '../graph-explorer/utils.js';
3
3
  import { getPackageNameFromModuleSpecifier } from '../util/modules.js';
4
+ import { toRelative } from '../util/path.js';
4
5
  import { findMatch } from '../util/regex.js';
5
6
  import { getShouldIgnoreHandler, getShouldIgnoreTagHandler } from '../util/tag.js';
6
- import { printTraceNode } from '../util/trace.js';
7
+ import { formatTrace } from '../util/trace.js';
7
8
  export const analyze = async ({ analyzedFiles, counselor, chief, collector, deputy, entryPaths, factory, graph, streamer, unreferencedFiles, options, }) => {
8
9
  const shouldIgnore = getShouldIgnoreHandler(options.isProduction);
9
10
  const shouldIgnoreTags = getShouldIgnoreTagHandler(options.tags);
10
11
  const explorer = createGraphExplorer(graph, entryPaths);
11
12
  const ignoreExportsUsedInFile = chief.config.ignoreExportsUsedInFile;
12
- const isExportedItemReferenced = (exportedItem) => exportedItem.refs[1] ||
13
- (exportedItem.refs[0] > 0 &&
13
+ const isExportReferencedInFile = (exportedItem) => exportedItem.self[1] ||
14
+ (exportedItem.self[0] > 0 &&
14
15
  (typeof ignoreExportsUsedInFile === 'object'
15
16
  ? exportedItem.type !== 'unknown' && !!ignoreExportsUsedInFile[exportedItem.type]
16
17
  : ignoreExportsUsedInFile));
@@ -38,7 +39,7 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
38
39
  const [isReferenced, reExportingEntryFile] = explorer.isReferenced(filePath, identifier, {
39
40
  includeEntryExports: isIncludeEntryExports,
40
41
  });
41
- if ((isReferenced || exportedItem.refs[1]) && isIgnored) {
42
+ if ((isReferenced || exportedItem.self[1]) && isIgnored) {
42
43
  for (const tagName of exportedItem.jsDocTags) {
43
44
  if (options.tags[1].includes(tagName.replace(/^@/, ''))) {
44
45
  collector.addTagHint({ type: 'tag', filePath, identifier, tagName });
@@ -47,7 +48,7 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
47
48
  }
48
49
  if (isIgnored)
49
50
  continue;
50
- if (reExportingEntryFile) {
51
+ if (reExportingEntryFile && !isReferenced) {
51
52
  if (!isIncludeEntryExports) {
52
53
  continue;
53
54
  }
@@ -66,7 +67,7 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
66
67
  continue;
67
68
  if (shouldIgnore(member.jsDocTags))
68
69
  continue;
69
- if (member.refs[0] === 0) {
70
+ if (member.self[0] === 0) {
70
71
  const id = `${identifier}.${member.identifier}`;
71
72
  const [isMemberReferenced] = explorer.isReferenced(filePath, id, {
72
73
  includeEntryExports: true,
@@ -130,7 +131,7 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
130
131
  if (hasStrictlyNsRefs &&
131
132
  ((!options.includedIssueTypes.nsTypes && isType) || !(options.includedIssueTypes.nsExports || isType)))
132
133
  continue;
133
- if (!isExportedItemReferenced(exportedItem)) {
134
+ if (!isExportReferencedInFile(exportedItem)) {
134
135
  if (isIgnored)
135
136
  continue;
136
137
  if (!options.isSkipLibs && principal?.hasExternalReferences(filePath, exportedItem))
@@ -229,8 +230,18 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
229
230
  await analyzeGraph();
230
231
  if (options.isTrace) {
231
232
  const nodes = explorer.buildExportsTree({ filePath: options.traceFile, identifier: options.traceExport });
233
+ nodes.sort((a, b) => a.filePath.localeCompare(b.filePath) || a.identifier.localeCompare(b.identifier));
234
+ const toRel = (path) => toRelative(path, options.cwd);
235
+ const isReferenced = (node) => {
236
+ if (explorer.isReferenced(node.filePath, node.identifier, { includeEntryExports: false })[0])
237
+ return true;
238
+ if (explorer.hasStrictlyNsReferences(node.filePath, node.identifier)[0])
239
+ return true;
240
+ const exportItem = graph.get(node.filePath)?.exports.get(node.identifier);
241
+ return exportItem ? isExportReferencedInFile(exportItem) : false;
242
+ };
232
243
  for (const node of nodes)
233
- printTraceNode(node, options);
244
+ console.log(formatTrace(node, toRel, isReferenced(node)));
234
245
  }
235
246
  return analyzeGraph;
236
247
  };
@@ -7,5 +7,5 @@ export declare const createGraphExplorer: (graph: ModuleGraph, entryPaths: Set<s
7
7
  buildExportsTree: (options: {
8
8
  filePath?: string;
9
9
  identifier?: string;
10
- }) => import("./operations/build-trace-tree.js").TreeNode[];
10
+ }) => import("./operations/build-exports-tree.js").TreeNode[];
11
11
  };
@@ -1,4 +1,4 @@
1
- import { buildExportsTree } from './operations/build-trace-tree.js';
1
+ import { buildExportsTree } from './operations/build-exports-tree.js';
2
2
  import { hasStrictlyNsReferences } from './operations/has-strictly-ns-references.js';
3
3
  import { isReferenced } from './operations/is-referenced.js';
4
4
  export const createGraphExplorer = (graph, entryPaths) => {
@@ -1,8 +1,11 @@
1
1
  import type { Identifier, ModuleGraph } from '../../types/module-graph.js';
2
+ import type { Via } from '../walk-down.js';
2
3
  export interface TreeNode {
3
4
  filePath: string;
4
5
  identifier: string;
5
- hasRef: boolean;
6
+ originalId: string | undefined;
7
+ via: Via | undefined;
8
+ refs: string[];
6
9
  isEntry: boolean;
7
10
  children: TreeNode[];
8
11
  }
@@ -0,0 +1,96 @@
1
+ import { CONTINUE } from '../constants.js';
2
+ import { walkDown } from '../walk-down.js';
3
+ export const buildExportsTree = (graph, entryPaths, options) => {
4
+ const traces = [];
5
+ const processFile = (filePath, file) => {
6
+ for (const exportId of options.identifier ? [options.identifier] : file.exports.keys()) {
7
+ if (!options.identifier || file.exports.has(exportId)) {
8
+ const trace = buildExportTree(graph, entryPaths, filePath, exportId);
9
+ if (trace)
10
+ traces.push(trace);
11
+ }
12
+ }
13
+ };
14
+ if (options.filePath) {
15
+ const file = graph.get(options.filePath);
16
+ if (file)
17
+ processFile(options.filePath, file);
18
+ }
19
+ else {
20
+ for (const [filePath, file] of graph)
21
+ processFile(filePath, file);
22
+ }
23
+ return traces;
24
+ };
25
+ const buildExportTree = (graph, entryPaths, filePath, identifier) => {
26
+ const file = graph.get(filePath);
27
+ const rootNode = {
28
+ filePath,
29
+ identifier,
30
+ refs: filterRefs(file?.imported?.refs, identifier),
31
+ isEntry: entryPaths.has(filePath),
32
+ children: [],
33
+ originalId: undefined,
34
+ via: undefined,
35
+ };
36
+ const nodeMap = new Map();
37
+ nodeMap.set(`${filePath}:${identifier}`, rootNode);
38
+ walkDown(graph, filePath, identifier, (sourceFile, sourceId, importingFile, id, isEntry, via) => {
39
+ const importMaps = graph.get(importingFile)?.imports.internal.get(sourceFile);
40
+ const importRefs = importMaps?.refs;
41
+ const ns = id.split('.')[0];
42
+ if (via === 'importNS' && !hasRelevantRef(importRefs, id) && !isNsReExported(importMaps, ns))
43
+ return CONTINUE;
44
+ const key = `${importingFile}:${id}`;
45
+ const isRenamed = via.endsWith('As') && sourceId !== ns;
46
+ const refs = filterRefs(importRefs, id);
47
+ const childNode = nodeMap.get(key) ?? {
48
+ filePath: importingFile,
49
+ identifier: id,
50
+ originalId: isRenamed ? sourceId : undefined,
51
+ via,
52
+ refs,
53
+ isEntry,
54
+ children: [],
55
+ };
56
+ nodeMap.set(key, childNode);
57
+ let parentNode = nodeMap.get(`${sourceFile}:${sourceId}`);
58
+ if (!parentNode) {
59
+ for (const [k, v] of nodeMap) {
60
+ if (k.startsWith(`${sourceFile}:${sourceId}.`) || k === `${sourceFile}:${sourceId}`) {
61
+ parentNode = v;
62
+ break;
63
+ }
64
+ }
65
+ }
66
+ (parentNode ?? rootNode).children.push(childNode);
67
+ return CONTINUE;
68
+ }, entryPaths);
69
+ pruneReExportStarOnlyBranches(rootNode);
70
+ return rootNode;
71
+ };
72
+ const filterRefs = (refs, id) => {
73
+ if (!refs)
74
+ return [];
75
+ return Array.from(refs).filter(ref => id === ref || id.startsWith(`${ref}.`) || ref.startsWith(`${id}.`));
76
+ };
77
+ const hasRelevantRef = (refs, id) => {
78
+ if (!refs || refs.size === 0)
79
+ return false;
80
+ return Array.from(refs).some(ref => ref === id || ref.startsWith(`${id}.`));
81
+ };
82
+ const isNsReExported = (importMaps, ns) => {
83
+ if (!importMaps)
84
+ return false;
85
+ return importMaps.reExportedAs.has(ns) || importMaps.reExportedNs.has(ns);
86
+ };
87
+ const hasNonReExportStar = (node) => {
88
+ if (node.via && node.via !== 'reExportStar')
89
+ return true;
90
+ return node.children.some(child => hasNonReExportStar(child));
91
+ };
92
+ const pruneReExportStarOnlyBranches = (node) => {
93
+ node.children = node.children.filter(child => hasNonReExportStar(child));
94
+ for (const child of node.children)
95
+ pruneReExportStarOnlyBranches(child);
96
+ };
@@ -5,8 +5,6 @@ export const isReferenced = (graph, entryPaths, filePath, id, options) => {
5
5
  const check = (currentPath, currentId) => {
6
6
  const isEntryFile = entryPaths.has(currentPath);
7
7
  let reExportingEntryFile = isEntryFile ? currentPath : undefined;
8
- if (isEntryFile && !options.includeEntryExports)
9
- return [false, reExportingEntryFile];
10
8
  if (seen.has(currentPath))
11
9
  return [false, reExportingEntryFile];
12
10
  seen.add(currentPath);
@@ -16,8 +14,6 @@ export const isReferenced = (graph, entryPaths, filePath, id, options) => {
16
14
  if (!identifier || !file) {
17
15
  return [false, reExportingEntryFile];
18
16
  }
19
- const directSources = getPassThroughReExportSources(file, identifier);
20
- const starSources = getStarReExportSources(file);
21
17
  const followSources = (sources, nextId) => {
22
18
  for (const byFilePath of sources) {
23
19
  if (seen.has(byFilePath))
@@ -62,6 +58,8 @@ export const isReferenced = (graph, entryPaths, filePath, id, options) => {
62
58
  return [true, reExportingEntryFile];
63
59
  }
64
60
  }
61
+ if (isEntryFile && !options.includeEntryExports)
62
+ return [false, reExportingEntryFile];
65
63
  const aliasMap = getAliasReExportMap(file, identifier);
66
64
  if (aliasMap) {
67
65
  for (const [alias, sources] of aliasMap) {
@@ -70,6 +68,8 @@ export const isReferenced = (graph, entryPaths, filePath, id, options) => {
70
68
  return [true, reExportingEntryFile];
71
69
  }
72
70
  }
71
+ const directSources = getPassThroughReExportSources(file, identifier);
72
+ const starSources = getStarReExportSources(file);
73
73
  if (directSources) {
74
74
  if (followSources(directSources, currentId))
75
75
  return [true, reExportingEntryFile];
@@ -1,4 +1,3 @@
1
- import type { ImportMaps, ModuleGraph } from '../types/module-graph.js';
2
- export declare const hasNamespaceMemberReference: (graph: ModuleGraph, importingFile: string, importedFile: string, namespace: string, member: string) => boolean | null;
1
+ import type { ImportMaps } from '../types/module-graph.js';
3
2
  export declare const hasStrictlyEnumReferences: (importsForExport: ImportMaps | undefined, identifier: string) => boolean;
4
3
  export declare const getIssueType: (hasOnlyNsReference: boolean, isType: boolean) => "exports" | "nsExports" | "types" | "nsTypes";
@@ -1,18 +1,3 @@
1
- import { OPAQUE } from '../constants.js';
2
- export const hasNamespaceMemberReference = (graph, importingFile, importedFile, namespace, member) => {
3
- const importerNode = graph.get(importingFile);
4
- if (!importerNode)
5
- return null;
6
- const importMap = importerNode.imports.internal.get(importedFile);
7
- if (!importMap)
8
- return null;
9
- if (importMap.imported.get(OPAQUE))
10
- return true;
11
- if (importMap.refs.size === 0)
12
- return false;
13
- const refKey = member ? `${namespace}.${member}` : namespace;
14
- return refKey ? importMap.refs.has(refKey) : null;
15
- };
16
1
  export const hasStrictlyEnumReferences = (importsForExport, identifier) => {
17
2
  if (!importsForExport || !importsForExport.refs.has(identifier))
18
3
  return false;
@@ -1,4 +1,5 @@
1
1
  import type { ModuleGraph } from '../types/module-graph.js';
2
- type Visitor = (sourceFile: string, identifier: string, importingFile: string, identifierPath: string, isEntry: boolean, isReExport: boolean) => 'continue' | 'stop' | undefined;
2
+ export type Via = 'import' | 'importAs' | 'importNS' | 'reExport' | 'reExportAs' | 'reExportNS' | 'reExportStar';
3
+ type Visitor = (sourceFile: string, identifier: string, importingFile: string, identifierPath: string, isEntry: boolean, via: Via) => 'continue' | 'stop' | undefined;
3
4
  export declare const walkDown: (graph: ModuleGraph, filePath: string, identifier: string, visitor: Visitor, entryPaths: Set<string>, visited?: Set<string>) => boolean;
4
5
  export {};
@@ -1,5 +1,4 @@
1
1
  import { STOP } from './constants.js';
2
- import { hasNamespaceMemberReference } from './utils.js';
3
2
  import { getAliasReExportMap, getPassThroughReExportSources, getStarReExportSources } from './visitors.js';
4
3
  export const walkDown = (graph, filePath, identifier, visitor, entryPaths, visited = new Set()) => {
5
4
  const key = `${filePath}:${identifier}`;
@@ -18,7 +17,7 @@ export const walkDown = (graph, filePath, identifier, visitor, entryPaths, visit
18
17
  if (importedByFiles) {
19
18
  for (const importingFile of importedByFiles) {
20
19
  const isEntry = entryPaths.has(importingFile);
21
- if (visitor(filePath, id, importingFile, id, isEntry, false) === STOP)
20
+ if (visitor(filePath, id, importingFile, id, isEntry, 'import') === STOP)
22
21
  return true;
23
22
  }
24
23
  }
@@ -27,17 +26,15 @@ export const walkDown = (graph, filePath, identifier, visitor, entryPaths, visit
27
26
  for (const [alias, byFilePaths] of importedAsAliases) {
28
27
  for (const importingFile of byFilePaths) {
29
28
  const isEntry = entryPaths.has(importingFile);
30
- if (visitor(filePath, id, importingFile, alias, isEntry, false) === STOP)
29
+ if (visitor(filePath, id, importingFile, alias, isEntry, 'importAs') === STOP)
31
30
  return true;
32
31
  }
33
32
  }
34
33
  }
35
34
  for (const [namespace, byFilePaths] of imported.importedNs) {
36
35
  for (const importingFile of byFilePaths) {
37
- if (hasNamespaceMemberReference(graph, importingFile, filePath, namespace, identifier) === false)
38
- continue;
39
36
  const isEntry = entryPaths.has(importingFile);
40
- if (visitor(filePath, identifier, importingFile, `${namespace}.${identifier}`, isEntry, false) === STOP) {
37
+ if (visitor(filePath, identifier, importingFile, `${namespace}.${identifier}`, isEntry, 'importNS') === STOP) {
41
38
  return true;
42
39
  }
43
40
  }
@@ -48,7 +45,7 @@ export const walkDown = (graph, filePath, identifier, visitor, entryPaths, visit
48
45
  if (passThroughSources) {
49
46
  for (const reExportingFile of passThroughSources) {
50
47
  const isEntry = entryPaths.has(reExportingFile);
51
- if (visitor(filePath, id, reExportingFile, id, isEntry, true) === STOP) {
48
+ if (visitor(filePath, id, reExportingFile, id, isEntry, 'reExport') === STOP) {
52
49
  done = true;
53
50
  break;
54
51
  }
@@ -65,7 +62,7 @@ export const walkDown = (graph, filePath, identifier, visitor, entryPaths, visit
65
62
  for (const [alias, sources] of aliasReExportMap) {
66
63
  for (const reExportingFile of sources) {
67
64
  const isEntry = entryPaths.has(reExportingFile);
68
- if (visitor(filePath, id, reExportingFile, alias, isEntry, true) === STOP) {
65
+ if (visitor(filePath, id, reExportingFile, alias, isEntry, 'reExportAs') === STOP) {
69
66
  done = true;
70
67
  break;
71
68
  }
@@ -86,7 +83,7 @@ export const walkDown = (graph, filePath, identifier, visitor, entryPaths, visit
86
83
  for (const [namespace, sources] of imported.reExportedNs) {
87
84
  for (const reExportingFile of sources) {
88
85
  const isEntry = entryPaths.has(reExportingFile);
89
- if (visitor(filePath, identifier, reExportingFile, `${namespace}.${identifier}`, isEntry, true) === STOP) {
86
+ if (visitor(filePath, identifier, reExportingFile, `${namespace}.${identifier}`, isEntry, 'reExportNS') === STOP) {
90
87
  done = true;
91
88
  break;
92
89
  }
@@ -104,7 +101,7 @@ export const walkDown = (graph, filePath, identifier, visitor, entryPaths, visit
104
101
  if (starSources) {
105
102
  for (const reExportingFile of starSources) {
106
103
  const isEntry = entryPaths.has(reExportingFile);
107
- if (visitor(filePath, id, reExportingFile, id, isEntry, true) === STOP) {
104
+ if (visitor(filePath, id, reExportingFile, id, isEntry, 'reExportStar') === STOP) {
108
105
  done = true;
109
106
  break;
110
107
  }
@@ -54,6 +54,8 @@ export declare const Plugins: {
54
54
  nest: import("../types/config.js").Plugin;
55
55
  netlify: import("../types/config.js").Plugin;
56
56
  next: import("../types/config.js").Plugin;
57
+ 'next-intl': import("../types/config.js").Plugin;
58
+ 'next-mdx': import("../types/config.js").Plugin;
57
59
  node: import("../types/config.js").Plugin;
58
60
  'node-modules-inspector': import("../types/config.js").Plugin;
59
61
  nodemon: import("../types/config.js").Plugin;
@@ -94,6 +96,7 @@ export declare const Plugins: {
94
96
  stylelint: import("../types/config.js").Plugin;
95
97
  svelte: import("../types/config.js").Plugin;
96
98
  svgo: import("../types/config.js").Plugin;
99
+ svgr: import("../types/config.js").Plugin;
97
100
  syncpack: import("../types/config.js").Plugin;
98
101
  tailwind: import("../types/config.js").Plugin;
99
102
  taskfile: import("../types/config.js").Plugin;
@@ -53,6 +53,8 @@ import { default as nanoStaged } from './nano-staged/index.js';
53
53
  import { default as nest } from './nest/index.js';
54
54
  import { default as netlify } from './netlify/index.js';
55
55
  import { default as next } from './next/index.js';
56
+ import { default as nextIntl } from './next-intl/index.js';
57
+ import { default as nextMdx } from './next-mdx/index.js';
56
58
  import { default as node } from './node/index.js';
57
59
  import { default as nodeModulesInspector } from './node-modules-inspector/index.js';
58
60
  import { default as nodemon } from './nodemon/index.js';
@@ -93,6 +95,7 @@ import { default as stryker } from './stryker/index.js';
93
95
  import { default as stylelint } from './stylelint/index.js';
94
96
  import { default as svelte } from './svelte/index.js';
95
97
  import { default as svgo } from './svgo/index.js';
98
+ import { default as svgr } from './svgr/index.js';
96
99
  import { default as syncpack } from './syncpack/index.js';
97
100
  import { default as tailwind } from './tailwind/index.js';
98
101
  import { default as taskfile } from './taskfile/index.js';
@@ -173,6 +176,8 @@ export const Plugins = {
173
176
  nest,
174
177
  netlify,
175
178
  next,
179
+ 'next-intl': nextIntl,
180
+ 'next-mdx': nextMdx,
176
181
  node,
177
182
  'node-modules-inspector': nodeModulesInspector,
178
183
  nodemon,
@@ -213,6 +218,7 @@ export const Plugins = {
213
218
  stylelint,
214
219
  svelte,
215
220
  svgo,
221
+ svgr,
216
222
  syncpack,
217
223
  tailwind,
218
224
  taskfile,
@@ -1,6 +1,6 @@
1
- import { toDependency, toProductionEntry } from '../../util/input.js';
1
+ import { toProductionEntry } from '../../util/input.js';
2
2
  import { hasDependency } from '../../util/plugin.js';
3
- import { getMdxPlugins, getPageExtensions } from './resolveFromAST.js';
3
+ import { getPageExtensions } from './resolveFromAST.js';
4
4
  const title = 'Next.js';
5
5
  const enablers = ['next'];
6
6
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
@@ -12,7 +12,6 @@ const productionEntryFilePatterns = [
12
12
  'app/**/sitemap.{js,ts}',
13
13
  'app/**/{icon,apple-icon}.{js,jsx,ts,tsx}',
14
14
  'app/**/{opengraph,twitter}-image.{js,jsx,ts,tsx}',
15
- 'mdx-components.{js,jsx,ts,tsx}',
16
15
  ];
17
16
  const getEntryFilePatterns = (pageExtensions = defaultPageExtensions) => {
18
17
  const patterns = [...productionEntryFilePatterns];
@@ -26,8 +25,7 @@ const resolveFromAST = sourceFile => {
26
25
  const pageExtensions = getPageExtensions(sourceFile);
27
26
  const extensions = pageExtensions.length > 0 ? pageExtensions : defaultPageExtensions;
28
27
  const patterns = getEntryFilePatterns(extensions);
29
- const mdxPlugins = getMdxPlugins(sourceFile);
30
- return [...patterns.map(id => toProductionEntry(id)), ...Array.from(mdxPlugins).map(id => toDependency(id))];
28
+ return patterns.map(id => toProductionEntry(id));
31
29
  };
32
30
  const plugin = {
33
31
  title,
@@ -1,3 +1,2 @@
1
1
  import ts from 'typescript';
2
2
  export declare const getPageExtensions: (sourceFile: ts.SourceFile) => string[];
3
- export declare const getMdxPlugins: (sourceFile: ts.SourceFile) => Set<string>;
@@ -1,5 +1,5 @@
1
1
  import ts from 'typescript';
2
- import { getDefaultImportName, getImportMap, getPropertyValues, stripQuotes } from '../../typescript/ast-helpers.js';
2
+ import { getPropertyValues } from '../../typescript/ast-helpers.js';
3
3
  export const getPageExtensions = (sourceFile) => {
4
4
  const pageExtensions = new Set();
5
5
  function visit(node) {
@@ -13,44 +13,3 @@ export const getPageExtensions = (sourceFile) => {
13
13
  visit(sourceFile);
14
14
  return Array.from(pageExtensions);
15
15
  };
16
- const isNamedProp = (prop, name) => ts.isPropertyAssignment(prop) && prop.name.getText() === name;
17
- export const getMdxPlugins = (sourceFile) => {
18
- const plugins = new Set();
19
- const importMap = getImportMap(sourceFile);
20
- const mdxImportName = getDefaultImportName(importMap, '@next/mdx');
21
- if (!mdxImportName)
22
- return plugins;
23
- function visit(node) {
24
- if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === mdxImportName) {
25
- if (node.arguments.length > 0 && ts.isObjectLiteralExpression(node.arguments[0])) {
26
- const options = node.arguments[0]?.properties.find(prop => isNamedProp(prop, 'options'));
27
- if (options && ts.isPropertyAssignment(options)) {
28
- if (ts.isObjectLiteralExpression(options.initializer)) {
29
- for (const pluginType of ['remarkPlugins', 'rehypePlugins', 'recmaPlugins']) {
30
- const props = options.initializer.properties.find(prop => isNamedProp(prop, pluginType));
31
- if (props && ts.isPropertyAssignment(props)) {
32
- if (ts.isArrayLiteralExpression(props.initializer)) {
33
- for (const element of props.initializer.elements) {
34
- if (ts.isStringLiteral(element)) {
35
- plugins.add(stripQuotes(element.text));
36
- }
37
- else if (ts.isArrayLiteralExpression(element) && element.elements.length > 0) {
38
- const firstElement = element.elements[0];
39
- if (ts.isStringLiteral(firstElement)) {
40
- plugins.add(stripQuotes(firstElement.text));
41
- }
42
- }
43
- }
44
- }
45
- }
46
- }
47
- }
48
- }
49
- }
50
- return true;
51
- }
52
- return ts.forEachChild(node, visit) ?? false;
53
- }
54
- visit(sourceFile);
55
- return plugins;
56
- };
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.js';
2
+ declare const plugin: Plugin;
3
+ export default plugin;