knip 6.44.1 → 6.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ConfigurationChief.d.ts +23 -1033
- package/dist/ConfigurationChief.js +71 -15
- package/dist/DependencyDeputy.d.ts +10 -6
- package/dist/DependencyDeputy.js +51 -27
- package/dist/IssueCollector.d.ts +14 -11
- package/dist/IssueCollector.js +25 -20
- package/dist/IssueFixer.js +1 -1
- package/dist/PackagePeeker.d.ts +6 -0
- package/dist/PackagePeeker.js +43 -14
- package/dist/ProjectPrincipal.d.ts +6 -3
- package/dist/ProjectPrincipal.js +83 -32
- package/dist/WorkspaceWorker.d.ts +5 -1
- package/dist/WorkspaceWorker.js +39 -22
- package/dist/binaries/bash-parser.js +1 -7
- package/dist/binaries/command.d.ts +3 -3
- package/dist/binaries/command.js +6 -2
- package/dist/binaries/fallback.js +1 -1
- package/dist/binaries/plugins.d.ts +4 -1
- package/dist/binaries/plugins.js +66 -18
- package/dist/binaries/resolvers/bun.js +2 -2
- package/dist/binaries/resolvers/index.d.ts +1 -0
- package/dist/binaries/resolvers/index.js +2 -0
- package/dist/binaries/resolvers/npm.js +7 -5
- package/dist/binaries/resolvers/npx.js +15 -12
- package/dist/binaries/resolvers/nub.js +2 -2
- package/dist/binaries/resolvers/vp.d.ts +2 -0
- package/dist/binaries/resolvers/vp.js +52 -0
- package/dist/binaries/util.d.ts +13 -1
- package/dist/binaries/util.js +35 -1
- package/dist/cli.js +10 -84
- package/dist/compilers/scss.js +2 -1
- package/dist/configuration-hints.d.ts +16 -0
- package/dist/configuration-hints.js +64 -0
- package/dist/constants.d.ts +2 -1
- package/dist/constants.js +37 -0
- package/dist/graph/SubpathReferences.d.ts +33 -0
- package/dist/graph/SubpathReferences.js +114 -0
- package/dist/graph/analyze.d.ts +4 -1
- package/dist/graph/analyze.js +16 -5
- package/dist/graph/build.d.ts +3 -1
- package/dist/graph/build.js +47 -23
- package/dist/graph-explorer/operations/resolve-export-origins.js +1 -1
- package/dist/plugins/angular/index.js +10 -17
- package/dist/plugins/aws-cdk/index.d.ts +3 -0
- package/dist/plugins/aws-cdk/index.js +32 -0
- package/dist/plugins/aws-cdk/types.d.ts +5 -0
- package/dist/plugins/aws-cdk/types.js +1 -0
- package/dist/plugins/babel/index.d.ts +1 -1
- package/dist/plugins/babel/index.js +25 -6
- package/dist/plugins/babel/types.d.ts +1 -0
- package/dist/plugins/bun/index.js +8 -7
- package/dist/plugins/c8/index.js +17 -4
- package/dist/plugins/changesets/index.js +3 -2
- package/dist/plugins/commitizen/index.js +6 -3
- package/dist/plugins/commitlint/index.js +10 -11
- package/dist/plugins/cypress/index.js +4 -2
- package/dist/plugins/danger/index.js +1 -1
- package/dist/plugins/docusaurus/helpers.js +6 -6
- package/dist/plugins/docusaurus/index.js +2 -2
- package/dist/plugins/electron-forge/index.js +2 -2
- package/dist/plugins/electron-vite/index.js +2 -2
- package/dist/plugins/eleventy/index.js +3 -2
- package/dist/plugins/eslint/helpers.js +4 -3
- package/dist/plugins/eslint/resolveFromAST.js +2 -2
- package/dist/plugins/evalite/index.d.ts +3 -0
- package/dist/plugins/evalite/index.js +26 -0
- package/dist/plugins/flue/index.js +2 -2
- package/dist/plugins/gatsby/index.js +1 -1
- package/dist/plugins/github-action/index.js +2 -2
- package/dist/plugins/github-actions/index.js +2 -2
- package/dist/plugins/graphql-codegen/index.js +13 -9
- package/dist/plugins/index.d.ts +5 -0
- package/dist/plugins/index.js +10 -0
- package/dist/plugins/jest/index.js +5 -5
- package/dist/plugins/knex/index.js +2 -2
- package/dist/plugins/laravel-vite-plugin/resolveFromAST.js +2 -2
- package/dist/plugins/lunaria/index.js +5 -2
- package/dist/plugins/markdownlint/index.js +8 -2
- package/dist/plugins/marko/index.js +2 -2
- package/dist/plugins/marko/taglibs.d.ts +1 -1
- package/dist/plugins/marko/taglibs.js +4 -28
- package/dist/plugins/mdx/index.d.ts +2 -1
- package/dist/plugins/mdx/index.js +7 -4
- package/dist/plugins/mdxlint/index.js +18 -15
- package/dist/plugins/mikro-orm/index.d.ts +3 -0
- package/dist/plugins/mikro-orm/index.js +77 -0
- package/dist/plugins/mikro-orm/types.d.ts +21 -0
- package/dist/plugins/mikro-orm/types.js +1 -0
- package/dist/plugins/msw/index.js +6 -3
- package/dist/plugins/msw/types.d.ts +1 -1
- package/dist/plugins/netlify/index.js +7 -3
- package/dist/plugins/next/index.js +63 -9
- package/dist/plugins/next/types.d.ts +5 -0
- package/dist/plugins/next-mdx/resolveFromAST.js +15 -10
- package/dist/plugins/nitro/index.js +5 -6
- package/dist/plugins/node/index.js +4 -4
- package/dist/plugins/npm-package-json-lint/index.js +10 -3
- package/dist/plugins/nuxt/index.js +18 -10
- package/dist/plugins/nuxt/types.d.ts +4 -0
- package/dist/plugins/nx/index.js +6 -3
- package/dist/plugins/openclaw/index.js +11 -11
- package/dist/plugins/oxlint/index.js +2 -2
- package/dist/plugins/payload/index.js +1 -1
- package/dist/plugins/playwright/index.js +3 -3
- package/dist/plugins/pm2/index.js +7 -7
- package/dist/plugins/prettier/index.js +2 -1
- package/dist/plugins/prisma/index.js +2 -2
- package/dist/plugins/quasar/resolveFromAST.js +14 -9
- package/dist/plugins/react-router/index.js +12 -15
- package/dist/plugins/release-it/index.js +6 -2
- package/dist/plugins/remix/index.js +3 -3
- package/dist/plugins/retry-cli/index.d.ts +3 -0
- package/dist/plugins/retry-cli/index.js +14 -0
- package/dist/plugins/rollup/index.js +1 -4
- package/dist/plugins/rstest/index.js +3 -3
- package/dist/plugins/semantic-release/index.js +3 -3
- package/dist/plugins/serverless-framework/index.js +10 -8
- package/dist/plugins/solidjs-vite-plugin/resolveFromAST.js +2 -2
- package/dist/plugins/stencil/resolveFromAST.js +5 -5
- package/dist/plugins/storybook/index.js +9 -3
- package/dist/plugins/stryker/index.js +2 -2
- package/dist/plugins/stylelint/index.js +2 -2
- package/dist/plugins/swc/index.js +4 -3
- package/dist/plugins/tailwind/index.js +2 -2
- package/dist/plugins/tanstack-router/index.js +2 -2
- package/dist/plugins/ts-node/index.js +6 -1
- package/dist/plugins/turbo/index.js +3 -3
- package/dist/plugins/typedoc/index.js +2 -2
- package/dist/plugins/typescript/content-mappers.d.ts +1 -1
- package/dist/plugins/typescript/index.js +6 -9
- package/dist/plugins/unocss/index.js +3 -0
- package/dist/plugins/varlock/scan.js +1 -1
- package/dist/plugins/vite/helpers.d.ts +1 -0
- package/dist/plugins/vite/helpers.js +13 -3
- package/dist/plugins/vite/index.js +5 -2
- package/dist/plugins/vite-plugin-pwa/resolveFromAST.js +2 -2
- package/dist/plugins/vitest/index.js +26 -18
- package/dist/plugins/vitest/types.d.ts +1 -0
- package/dist/plugins/vue/index.js +1 -1
- package/dist/plugins/web-test-runner/index.d.ts +3 -0
- package/dist/plugins/web-test-runner/index.js +86 -0
- package/dist/plugins/wrangler/index.js +3 -3
- package/dist/plugins/yarn/index.js +5 -5
- package/dist/plugins.js +2 -5
- package/dist/reporters/github-actions.js +3 -7
- package/dist/reporters/json.d.ts +1 -0
- package/dist/reporters/json.js +1 -0
- package/dist/reporters/util/configuration-hints.d.ts +3 -1
- package/dist/reporters/util/configuration-hints.js +40 -21
- package/dist/reporters/util/util.d.ts +1 -1
- package/dist/run-cli.d.ts +2 -0
- package/dist/run-cli.js +82 -0
- package/dist/run.js +12 -0
- package/dist/session/incremental.d.ts +1 -0
- package/dist/session/incremental.js +1 -0
- package/dist/session/watch.js +2 -1
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +5 -0
- package/dist/types/args.d.ts +3 -1
- package/dist/types/config.d.ts +17 -10
- package/dist/types/configuration.d.ts +45 -0
- package/dist/types/configuration.js +1 -0
- package/dist/types/issues.d.ts +4 -0
- package/dist/types/module-graph.d.ts +1 -0
- package/dist/types/options.d.ts +1 -0
- package/dist/types/package-json.d.ts +3 -8
- package/dist/types/workspace.d.ts +1 -0
- package/dist/typescript/get-imports-and-exports.js +18 -6
- package/dist/typescript/resolve-module-names.js +7 -45
- package/dist/typescript/visitors/calls.d.ts +1 -1
- package/dist/typescript/visitors/calls.js +14 -10
- package/dist/typescript/visitors/exports.js +16 -26
- package/dist/typescript/visitors/imports.d.ts +2 -1
- package/dist/typescript/visitors/imports.js +41 -24
- package/dist/typescript/visitors/members.d.ts +1 -1
- package/dist/typescript/visitors/members.js +38 -24
- package/dist/typescript/visitors/shadow.d.ts +2 -0
- package/dist/typescript/visitors/shadow.js +25 -0
- package/dist/typescript/visitors/walk.d.ts +20 -12
- package/dist/typescript/visitors/walk.js +78 -48
- package/dist/util/Performance.d.ts +25 -3
- package/dist/util/Performance.js +51 -27
- package/dist/util/cli-arguments.d.ts +2 -1
- package/dist/util/cli-arguments.js +5 -3
- package/dist/util/create-input-handler.js +138 -119
- package/dist/util/create-options.d.ts +4 -2071
- package/dist/util/create-options.js +6 -4
- package/dist/util/create-workspace-graph.js +2 -1
- package/dist/util/errors.d.ts +5 -2
- package/dist/util/errors.js +11 -18
- package/dist/util/fs.js +4 -2
- package/dist/util/input.d.ts +2 -2
- package/dist/util/input.js +2 -2
- package/dist/util/is-plugin-name.d.ts +2 -0
- package/dist/util/is-plugin-name.js +3 -0
- package/dist/util/jiti.d.ts +2 -1
- package/dist/util/jiti.js +11 -3
- package/dist/util/load-config.d.ts +1 -1
- package/dist/util/load-config.js +3 -2
- package/dist/util/loader.js +3 -2
- package/dist/util/map-workspaces.js +23 -1
- package/dist/util/module-graph.js +1 -0
- package/dist/util/modules.d.ts +2 -0
- package/dist/util/modules.js +78 -0
- package/dist/util/package-json.d.ts +12 -5
- package/dist/util/package-json.js +54 -26
- package/dist/util/parse-and-convert-gitignores.d.ts +2 -2
- package/dist/util/parse-and-convert-gitignores.js +5 -5
- package/dist/util/parse-configuration.d.ts +2 -0
- package/dist/util/parse-configuration.js +66 -0
- package/dist/util/plugin.js +8 -12
- package/dist/util/resolve.d.ts +1 -0
- package/dist/util/resolve.js +3 -2
- package/dist/util/scripts.d.ts +0 -5
- package/dist/util/scripts.js +1 -32
- package/dist/util/to-source-path.d.ts +4 -1
- package/dist/util/to-source-path.js +2 -2
- package/dist/util/unhandled-rejection.d.ts +8 -0
- package/dist/util/unhandled-rejection.js +29 -0
- package/dist/util/validation.d.ts +11 -0
- package/dist/util/validation.js +68 -0
- package/dist/util/watch.d.ts +3 -1
- package/dist/util/watch.js +5 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +9 -10
- package/schema.json +34 -0
- package/dist/schema/configuration.d.ts +0 -3103
- package/dist/schema/configuration.js +0 -94
- package/dist/schema/plugins.d.ts +0 -1019
- package/dist/schema/plugins.js +0 -215
package/dist/plugins/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const Plugins: {
|
|
|
5
5
|
'astro-markdoc': import("../types/config.ts").Plugin;
|
|
6
6
|
'astro-og-canvas': import("../types/config.ts").Plugin;
|
|
7
7
|
ava: import("../types/config.ts").Plugin;
|
|
8
|
+
'aws-cdk': import("../types/config.ts").Plugin;
|
|
8
9
|
babel: import("../types/config.ts").Plugin;
|
|
9
10
|
biome: import("../types/config.ts").Plugin;
|
|
10
11
|
borp: import("../types/config.ts").Plugin;
|
|
@@ -34,6 +35,7 @@ export declare const Plugins: {
|
|
|
34
35
|
eleventy: import("../types/config.ts").Plugin;
|
|
35
36
|
esbuild: import("../types/config.ts").Plugin;
|
|
36
37
|
eslint: import("../types/config.ts").Plugin;
|
|
38
|
+
evalite: import("../types/config.ts").Plugin;
|
|
37
39
|
eve: import("../types/config.ts").Plugin;
|
|
38
40
|
execa: import("../types/config.ts").Plugin;
|
|
39
41
|
expo: import("../types/config.ts").Plugin;
|
|
@@ -78,6 +80,7 @@ export declare const Plugins: {
|
|
|
78
80
|
mdx: import("../types/config.ts").Plugin;
|
|
79
81
|
mdxlint: import("../types/config.ts").Plugin;
|
|
80
82
|
metro: import("../types/config.ts").Plugin;
|
|
83
|
+
'mikro-orm': import("../types/config.ts").Plugin;
|
|
81
84
|
mise: import("../types/config.ts").Plugin;
|
|
82
85
|
mocha: import("../types/config.ts").Plugin;
|
|
83
86
|
moonrepo: import("../types/config.ts").Plugin;
|
|
@@ -133,6 +136,7 @@ export declare const Plugins: {
|
|
|
133
136
|
'release-it': import("../types/config.ts").Plugin;
|
|
134
137
|
remark: import("../types/config.ts").Plugin;
|
|
135
138
|
remix: import("../types/config.ts").Plugin;
|
|
139
|
+
'retry-cli': import("../types/config.ts").Plugin;
|
|
136
140
|
rolldown: import("../types/config.ts").Plugin;
|
|
137
141
|
rollup: import("../types/config.ts").Plugin;
|
|
138
142
|
rsbuild: import("../types/config.ts").Plugin;
|
|
@@ -197,6 +201,7 @@ export declare const Plugins: {
|
|
|
197
201
|
vitepress: import("../types/config.ts").Plugin;
|
|
198
202
|
vitest: import("../types/config.ts").Plugin;
|
|
199
203
|
vue: import("../types/config.ts").Plugin;
|
|
204
|
+
'web-test-runner': import("../types/config.ts").Plugin;
|
|
200
205
|
'webdriver-io': import("../types/config.ts").Plugin;
|
|
201
206
|
webpack: import("../types/config.ts").Plugin;
|
|
202
207
|
wireit: import("../types/config.ts").Plugin;
|
package/dist/plugins/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { default as astroDb } from './astro-db/index.js';
|
|
|
4
4
|
import { default as astroMarkdoc } from './astro-markdoc/index.js';
|
|
5
5
|
import { default as astroOgCanvas } from './astro-og-canvas/index.js';
|
|
6
6
|
import { default as ava } from './ava/index.js';
|
|
7
|
+
import { default as awsCdk } from './aws-cdk/index.js';
|
|
7
8
|
import { default as babel } from './babel/index.js';
|
|
8
9
|
import { default as biome } from './biome/index.js';
|
|
9
10
|
import { default as borp } from './borp/index.js';
|
|
@@ -33,6 +34,7 @@ import { default as electronVite } from './electron-vite/index.js';
|
|
|
33
34
|
import { default as eleventy } from './eleventy/index.js';
|
|
34
35
|
import { default as esbuild } from './esbuild/index.js';
|
|
35
36
|
import { default as eslint } from './eslint/index.js';
|
|
37
|
+
import { default as evalite } from './evalite/index.js';
|
|
36
38
|
import { default as eve } from './eve/index.js';
|
|
37
39
|
import { default as execa } from './execa/index.js';
|
|
38
40
|
import { default as expo } from './expo/index.js';
|
|
@@ -72,6 +74,7 @@ import { default as mcp } from './mcp/index.js';
|
|
|
72
74
|
import { default as mdx } from './mdx/index.js';
|
|
73
75
|
import { default as mdxlint } from './mdxlint/index.js';
|
|
74
76
|
import { default as metro } from './metro/index.js';
|
|
77
|
+
import { default as mikroOrm } from './mikro-orm/index.js';
|
|
75
78
|
import { default as mise } from './mise/index.js';
|
|
76
79
|
import { default as mocha } from './mocha/index.js';
|
|
77
80
|
import { default as moonrepo } from './moonrepo/index.js';
|
|
@@ -127,6 +130,7 @@ import { default as relay } from './relay/index.js';
|
|
|
127
130
|
import { default as releaseIt } from './release-it/index.js';
|
|
128
131
|
import { default as remark } from './remark/index.js';
|
|
129
132
|
import { default as remix } from './remix/index.js';
|
|
133
|
+
import { default as retryCli } from './retry-cli/index.js';
|
|
130
134
|
import { default as rolldown } from './rolldown/index.js';
|
|
131
135
|
import { default as rollup } from './rollup/index.js';
|
|
132
136
|
import { default as rsbuild } from './rsbuild/index.js';
|
|
@@ -191,6 +195,7 @@ import { default as vitePwaAssetsGenerator } from './vite-pwa-assets-generator/i
|
|
|
191
195
|
import { default as vitepress } from './vitepress/index.js';
|
|
192
196
|
import { default as vitest } from './vitest/index.js';
|
|
193
197
|
import { default as vue } from './vue/index.js';
|
|
198
|
+
import { default as webTestRunner } from './web-test-runner/index.js';
|
|
194
199
|
import { default as webdriverIo } from './webdriver-io/index.js';
|
|
195
200
|
import { default as webpack } from './webpack/index.js';
|
|
196
201
|
import { default as wireit } from './wireit/index.js';
|
|
@@ -207,6 +212,7 @@ export const Plugins = {
|
|
|
207
212
|
'astro-markdoc': astroMarkdoc,
|
|
208
213
|
'astro-og-canvas': astroOgCanvas,
|
|
209
214
|
ava,
|
|
215
|
+
'aws-cdk': awsCdk,
|
|
210
216
|
babel,
|
|
211
217
|
biome,
|
|
212
218
|
borp,
|
|
@@ -236,6 +242,7 @@ export const Plugins = {
|
|
|
236
242
|
eleventy,
|
|
237
243
|
esbuild,
|
|
238
244
|
eslint,
|
|
245
|
+
evalite,
|
|
239
246
|
eve,
|
|
240
247
|
execa,
|
|
241
248
|
expo,
|
|
@@ -275,6 +282,7 @@ export const Plugins = {
|
|
|
275
282
|
mdx,
|
|
276
283
|
mdxlint,
|
|
277
284
|
metro,
|
|
285
|
+
'mikro-orm': mikroOrm,
|
|
278
286
|
mise,
|
|
279
287
|
mocha,
|
|
280
288
|
moonrepo,
|
|
@@ -330,6 +338,7 @@ export const Plugins = {
|
|
|
330
338
|
'release-it': releaseIt,
|
|
331
339
|
remark,
|
|
332
340
|
remix,
|
|
341
|
+
'retry-cli': retryCli,
|
|
333
342
|
rolldown,
|
|
334
343
|
rollup,
|
|
335
344
|
rsbuild,
|
|
@@ -394,6 +403,7 @@ export const Plugins = {
|
|
|
394
403
|
vitepress,
|
|
395
404
|
vitest,
|
|
396
405
|
vue,
|
|
406
|
+
'web-test-runner': webTestRunner,
|
|
397
407
|
'webdriver-io': webdriverIo,
|
|
398
408
|
webpack,
|
|
399
409
|
wireit,
|
|
@@ -51,11 +51,11 @@ const resolveDependencies = async (config, rootDir, options) => {
|
|
|
51
51
|
if (config.testEnvironment === 'node') {
|
|
52
52
|
environments.push(toDependency('jest-environment-node', { optional: true }));
|
|
53
53
|
}
|
|
54
|
+
else if (config.testEnvironment === 'jsdom') {
|
|
55
|
+
environments.push(toDependency('jest-environment-jsdom'));
|
|
56
|
+
}
|
|
54
57
|
else if (config.testEnvironment) {
|
|
55
|
-
|
|
56
|
-
? 'jest-environment-jsdom'
|
|
57
|
-
: resolveWithPrefix('jest-environment-', config.testEnvironment, rootDir);
|
|
58
|
-
environments.push(toDeferResolve(environment));
|
|
58
|
+
environments.push(toDeferResolve(resolveWithPrefix('jest-environment-', config.testEnvironment, rootDir)));
|
|
59
59
|
}
|
|
60
60
|
const resolvers = config.resolver ? [config.resolver] : [];
|
|
61
61
|
const reporters = getReportersDependencies(config, options);
|
|
@@ -68,7 +68,7 @@ const resolveDependencies = async (config, rootDir, options) => {
|
|
|
68
68
|
else {
|
|
69
69
|
transform.push(transformer[0]);
|
|
70
70
|
if (isBabelJest(transformer)) {
|
|
71
|
-
transform.push(...getDependenciesFromConfig(transformer[1]));
|
|
71
|
+
transform.push(...getDependenciesFromConfig(transformer[1], false));
|
|
72
72
|
const { configFile } = transformer[1];
|
|
73
73
|
if (typeof configFile === 'string')
|
|
74
74
|
transform.push(toConfig('babel', rootDirRe.test(configFile) ? configFile : toAbsolute(configFile, options.cwd)));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toEntry, toProductionDependency } from '../../util/input.js';
|
|
2
2
|
import { hasDependency } from '../../util/plugin.js';
|
|
3
3
|
import { clientToPackages } from './helpers.js';
|
|
4
4
|
import { createKnexClientVisitor } from './visitors/clientCall.js';
|
|
@@ -10,7 +10,7 @@ const processKnexConfig = (config) => {
|
|
|
10
10
|
const inputs = [];
|
|
11
11
|
if (config.client) {
|
|
12
12
|
const packages = clientToPackages(config.client);
|
|
13
|
-
inputs.push(...packages.map(pkg =>
|
|
13
|
+
inputs.push(...packages.map(pkg => toProductionDependency(pkg, { optional: true })));
|
|
14
14
|
}
|
|
15
15
|
if (config.migrations?.directory) {
|
|
16
16
|
const dirs = Array.isArray(config.migrations.directory)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { findImportedCalls, findProperty, getStringValues } from '../../typescript/ast-helpers.js';
|
|
2
2
|
import { getStringValue } from '../../typescript/ast-nodes.js';
|
|
3
|
-
import {
|
|
3
|
+
import { toDeferResolveProductionEntry } from '../../util/input.js';
|
|
4
4
|
import { join } from '../../util/path.js';
|
|
5
5
|
const enablers = ['laravel-vite-plugin'];
|
|
6
6
|
const addStringOrArray = (values, node) => {
|
|
@@ -21,7 +21,7 @@ export const resolveFromAST = (program, options) => {
|
|
|
21
21
|
addStringOrArray(specifiers, findProperty(arg, 'input'));
|
|
22
22
|
addStringOrArray(specifiers, findProperty(arg, 'ssr'));
|
|
23
23
|
for (const id of specifiers)
|
|
24
|
-
inputs.push(
|
|
24
|
+
inputs.push(toDeferResolveProductionEntry(join(options.configFileDir, id)));
|
|
25
25
|
}
|
|
26
26
|
return inputs;
|
|
27
27
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { toAbsolute } from '../../util/path.js';
|
|
2
|
-
import { toProductionEntry } from '../../util/input.js';
|
|
2
|
+
import { toDeferResolveProductionEntry, toProductionEntry } from '../../util/input.js';
|
|
3
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
4
|
const title = 'Lunaria';
|
|
5
5
|
const enablers = ['@lunariajs/core', '@lunariajs/starlight'];
|
|
@@ -13,7 +13,10 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
13
13
|
const customCss = localConfig.dashboard?.customCss ?? [];
|
|
14
14
|
const favicon = localConfig.dashboard?.favicon?.inline ? [localConfig.dashboard.favicon.inline] : [];
|
|
15
15
|
const baseDir = options.configFileDir;
|
|
16
|
-
return [
|
|
16
|
+
return [
|
|
17
|
+
...files.map(id => toProductionEntry(toAbsolute(id, baseDir))),
|
|
18
|
+
...[...renderer, ...customCss, ...favicon].map(id => toDeferResolveProductionEntry(toAbsolute(id, baseDir))),
|
|
19
|
+
];
|
|
17
20
|
};
|
|
18
21
|
const args = {
|
|
19
22
|
binaries: ['lunaria'],
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { toDependency } from '../../util/input.js';
|
|
1
|
+
import { toDeferResolve, toDependency } from '../../util/input.js';
|
|
2
|
+
import { isInternal } from '../../util/path.js';
|
|
2
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
3
4
|
import { getArgumentValues } from './helpers.js';
|
|
4
5
|
const title = 'markdownlint';
|
|
@@ -35,7 +36,12 @@ const resolveConfig = (config, options) => {
|
|
|
35
36
|
const uses = scripts
|
|
36
37
|
.filter(script => script.includes('markdownlint ') || script.includes('markdownlint-cli2 '))
|
|
37
38
|
.flatMap(script => getArgumentValues(script, / (--rules|-r)[ =]([^ ]+)/g));
|
|
38
|
-
return [
|
|
39
|
+
return [
|
|
40
|
+
...dependencies.filter(id => !isBundled(id)).map(id => (isInternal(id) ? toDeferResolve(id) : toDependency(id))),
|
|
41
|
+
...uses
|
|
42
|
+
.filter(id => !isBundled(id))
|
|
43
|
+
.map(id => (isInternal(id) ? toDeferResolve(id, { dir: options.cwd }) : toDependency(id))),
|
|
44
|
+
];
|
|
39
45
|
};
|
|
40
46
|
const plugin = {
|
|
41
47
|
title,
|
|
@@ -44,9 +44,9 @@ const resolveConfig = (localConfig, options) => {
|
|
|
44
44
|
}
|
|
45
45
|
return inputs;
|
|
46
46
|
};
|
|
47
|
-
const registerCompilers = async ({ cwd, registerCompiler, hasDependency }) => {
|
|
47
|
+
const registerCompilers = async ({ cwd, dependencies, registerCompiler, hasDependency }) => {
|
|
48
48
|
if (hasDependency('marko')) {
|
|
49
|
-
const { tagDependencies, fallbackDependencies } = await getTaglibDependencies(cwd);
|
|
49
|
+
const { tagDependencies, fallbackDependencies } = await getTaglibDependencies(cwd, dependencies);
|
|
50
50
|
registerCompiler({ extension: '.marko', compiler: createCompiler(tagDependencies, fallbackDependencies) });
|
|
51
51
|
}
|
|
52
52
|
};
|
|
@@ -1,33 +1,9 @@
|
|
|
1
1
|
import { readdirSync } from 'node:fs';
|
|
2
2
|
import { isFile, loadJSON } from '../../util/fs.js';
|
|
3
3
|
import { basename, dirname, join } from '../../util/path.js';
|
|
4
|
-
|
|
4
|
+
import { resolvePackageFilePath } from '../../util/resolve.js';
|
|
5
5
|
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
6
|
-
const
|
|
7
|
-
const manifest = await loadJSON(join(cwd, 'package.json'));
|
|
8
|
-
const dependencies = new Set();
|
|
9
|
-
if (!isRecord(manifest))
|
|
10
|
-
return dependencies;
|
|
11
|
-
for (const field of dependencyFields) {
|
|
12
|
-
const values = manifest[field];
|
|
13
|
-
if (isRecord(values))
|
|
14
|
-
for (const packageName in values)
|
|
15
|
-
dependencies.add(packageName);
|
|
16
|
-
}
|
|
17
|
-
return dependencies;
|
|
18
|
-
};
|
|
19
|
-
const findConfig = (cwd, packageName) => {
|
|
20
|
-
let dir = cwd;
|
|
21
|
-
while (true) {
|
|
22
|
-
const filePath = join(dir, 'node_modules', packageName, 'marko.json');
|
|
23
|
-
if (isFile(filePath))
|
|
24
|
-
return filePath;
|
|
25
|
-
const parent = dirname(dir);
|
|
26
|
-
if (parent === dir)
|
|
27
|
-
return;
|
|
28
|
-
dir = parent;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
6
|
+
const findConfig = (cwd, packageName) => resolvePackageFilePath(`${packageName}/marko.json`, cwd);
|
|
31
7
|
const readDir = (dir) => {
|
|
32
8
|
try {
|
|
33
9
|
return readdirSync(dir, { withFileTypes: true });
|
|
@@ -71,10 +47,10 @@ const getTags = (dir) => {
|
|
|
71
47
|
}
|
|
72
48
|
return tags;
|
|
73
49
|
};
|
|
74
|
-
export const getTaglibDependencies = async (cwd) => {
|
|
50
|
+
export const getTaglibDependencies = async (cwd, dependencies) => {
|
|
75
51
|
const tagDependencies = new Map();
|
|
76
52
|
const fallbackDependencies = [];
|
|
77
|
-
for (const packageName of
|
|
53
|
+
for (const packageName of dependencies) {
|
|
78
54
|
const configPath = findConfig(cwd, packageName);
|
|
79
55
|
if (!configPath)
|
|
80
56
|
continue;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Plugin } from '../../types/config.ts';
|
|
2
2
|
import { type Input } from '../../util/input.ts';
|
|
3
3
|
export declare const contentMappers: string[];
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const toProviderInput: (provider: string, dir: string) => Input;
|
|
5
|
+
export declare const resolveContentMapperOptions: (options: Record<string, unknown>, dir: string) => Input[];
|
|
5
6
|
declare const plugin: Plugin;
|
|
6
7
|
export default plugin;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toDeferResolveProductionEntry, toDependency } from '../../util/input.js';
|
|
1
|
+
import { toDeferResolve, toDeferResolveProductionEntry, toDependency } from '../../util/input.js';
|
|
2
2
|
import { isInternal } from '../../util/path.js';
|
|
3
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
4
|
const title = 'MDX';
|
|
@@ -19,11 +19,14 @@ const takeDependencies = (plugins) => {
|
|
|
19
19
|
};
|
|
20
20
|
export const contentMappers = ['mdx-content-mapper', '@mdx-js/content-mapper'];
|
|
21
21
|
const bundledPlugins = ['remark-mdx-frontmatter'];
|
|
22
|
-
export const
|
|
22
|
+
export const toProviderInput = (provider, dir) => isInternal(provider) || provider.startsWith('#')
|
|
23
|
+
? toDeferResolveProductionEntry(provider)
|
|
24
|
+
: toDeferResolve(provider, { dir, production: true });
|
|
25
|
+
export const resolveContentMapperOptions = (options, dir) => {
|
|
23
26
|
const inputs = takeDependencies(options.remarkPlugins).filter(input => !bundledPlugins.includes(input.specifier));
|
|
24
27
|
const provider = options.providerImportSource;
|
|
25
|
-
if (typeof provider === 'string'
|
|
26
|
-
inputs.push(
|
|
28
|
+
if (typeof provider === 'string')
|
|
29
|
+
inputs.push(toProviderInput(provider, dir));
|
|
27
30
|
return inputs;
|
|
28
31
|
};
|
|
29
32
|
const resolveConfig = async (config, options) => {
|
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
import { toDeferResolve } from '../../util/input.js';
|
|
1
|
+
import { toDeferResolve, toDependency } from '../../util/input.js';
|
|
2
2
|
import { isInternal } from '../../util/path.js';
|
|
3
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
4
|
const title = 'mdxlint';
|
|
5
5
|
const enablers = ['mdxlint'];
|
|
6
6
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
7
7
|
const config = ['.mdxlintrc', '.mdxlintrc.{json,js,cjs,mjs,yml,yaml}', 'package.json'];
|
|
8
|
+
const isPrefixed = (name) => name.startsWith('remark-') || name.startsWith('mdxlint-');
|
|
9
|
+
const toPluginName = (plugin) => {
|
|
10
|
+
const slash = plugin.startsWith('@') ? plugin.indexOf('/') + 1 : 0;
|
|
11
|
+
const name = plugin.slice(slash);
|
|
12
|
+
return isPrefixed(name) ? plugin : `${plugin.slice(0, slash)}remark-${name}`;
|
|
13
|
+
};
|
|
8
14
|
const resolveConfig = config => {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
? plugin
|
|
21
|
-
: `remark-${plugin}`) ?? [];
|
|
22
|
-
return plugins.map(id => toDeferResolve(id));
|
|
15
|
+
const inputs = [];
|
|
16
|
+
for (const plugin of config.plugins ?? []) {
|
|
17
|
+
const id = typeof plugin === 'string' ? plugin : Array.isArray(plugin) ? plugin[0] : undefined;
|
|
18
|
+
if (typeof id !== 'string')
|
|
19
|
+
continue;
|
|
20
|
+
if (isInternal(id))
|
|
21
|
+
inputs.push(toDeferResolve(id));
|
|
22
|
+
else
|
|
23
|
+
inputs.push(toDependency(toPluginName(id)));
|
|
24
|
+
}
|
|
25
|
+
return inputs;
|
|
23
26
|
};
|
|
24
27
|
const plugin = {
|
|
25
28
|
title,
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { toConfig, toProductionEntry } from '../../util/input.js';
|
|
2
|
+
import { join, toAbsolute } from '../../util/path.js';
|
|
3
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
4
|
+
const title = 'MikroORM';
|
|
5
|
+
const enablers = [/^@mikro-orm\//];
|
|
6
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
7
|
+
const config = [
|
|
8
|
+
'src/mikro-orm.config.{ts,js}',
|
|
9
|
+
'mikro-orm.config.{ts,js}',
|
|
10
|
+
'dist/mikro-orm.config.js',
|
|
11
|
+
'build/mikro-orm.config.js',
|
|
12
|
+
'package.json',
|
|
13
|
+
];
|
|
14
|
+
const DEFAULT_MIGRATIONS_GLOB = '!(*.d).{js,ts,cjs}';
|
|
15
|
+
const DEFAULT_SEEDER_GLOB = '!(*.d).{js,ts}';
|
|
16
|
+
const ENTITY_EXTENSIONS = 'js,cjs,mjs,ts,cts,mts';
|
|
17
|
+
const toStrings = (value) => (Array.isArray(value) ? value : [value]).filter((item) => typeof item === 'string');
|
|
18
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
19
|
+
const isMikroOrmOptions = (value) => isRecord(value);
|
|
20
|
+
const isMikroOrmPackageJson = (value) => isRecord(value) &&
|
|
21
|
+
'configPaths' in value &&
|
|
22
|
+
(typeof value.configPaths === 'string' || Array.isArray(value.configPaths));
|
|
23
|
+
const isMikroOrmConfigFactory = (value) => typeof value === 'function';
|
|
24
|
+
const isMikroOrmConfigItem = (value) => isMikroOrmOptions(value) || isMikroOrmConfigFactory(value);
|
|
25
|
+
const entitySpecialRegex = /[*?{}[]/u;
|
|
26
|
+
const entityFileExtensionRegex = /\.(?:[cm]?[jt]s)$/u;
|
|
27
|
+
const toEntityEntry = (specifier, extensions, baseDir) => {
|
|
28
|
+
const hasPattern = entitySpecialRegex.test(specifier);
|
|
29
|
+
const hasExtension = entityFileExtensionRegex.test(specifier);
|
|
30
|
+
const pattern = hasPattern || hasExtension ? specifier : join(specifier, `**/*.{${extensions}}`);
|
|
31
|
+
return toProductionEntry(toAbsolute(pattern, baseDir));
|
|
32
|
+
};
|
|
33
|
+
const toFolderEntries = (paths, glob, baseDir) => paths.map(path => toProductionEntry(toAbsolute(join(path, glob), baseDir)));
|
|
34
|
+
const resolveConfig = async (config, options) => {
|
|
35
|
+
if (options.configFileName === 'package.json') {
|
|
36
|
+
if (!isMikroOrmPackageJson(config))
|
|
37
|
+
return [];
|
|
38
|
+
const configPaths = toStrings(config.configPaths);
|
|
39
|
+
return configPaths.map(path => toConfig('mikro-orm', path, { dir: options.cwd }));
|
|
40
|
+
}
|
|
41
|
+
const configItems = (Array.isArray(config) ? config : [config]).filter(isMikroOrmConfigItem);
|
|
42
|
+
const resolvedConfigs = await Promise.all(configItems.map(async (configItem) => isMikroOrmConfigFactory(configItem) ? await configItem('default') : configItem));
|
|
43
|
+
const configs = resolvedConfigs
|
|
44
|
+
.flatMap(config => (Array.isArray(config) ? config : [config]))
|
|
45
|
+
.filter(isMikroOrmOptions);
|
|
46
|
+
return configs.flatMap(config => {
|
|
47
|
+
const baseDir = typeof config.baseDir === 'string' ? toAbsolute(config.baseDir, options.cwd) : options.cwd;
|
|
48
|
+
const inputs = [];
|
|
49
|
+
const entities = [...toStrings(config.entities), ...toStrings(config.entitiesTs)];
|
|
50
|
+
inputs.push(...entities.map(path => toEntityEntry(path, ENTITY_EXTENSIONS, baseDir)));
|
|
51
|
+
if (config.migrations?.migrationsList === undefined) {
|
|
52
|
+
const migrationsTs = toStrings(config.migrations?.pathTs);
|
|
53
|
+
const migrations = migrationsTs.length > 0 ? migrationsTs : toStrings(config.migrations?.path);
|
|
54
|
+
const paths = migrations.length > 0 ? migrations : ['./migrations'];
|
|
55
|
+
inputs.push(...toFolderEntries(paths, config.migrations?.glob ?? DEFAULT_MIGRATIONS_GLOB, baseDir));
|
|
56
|
+
}
|
|
57
|
+
const seedersTs = toStrings(config.seeder?.pathTs);
|
|
58
|
+
const seeders = seedersTs.length > 0 ? seedersTs : toStrings(config.seeder?.path);
|
|
59
|
+
const seederPaths = seeders.length > 0 ? seeders : ['./seeders'];
|
|
60
|
+
inputs.push(...toFolderEntries(seederPaths, config.seeder?.glob ?? DEFAULT_SEEDER_GLOB, baseDir));
|
|
61
|
+
return inputs;
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const args = {
|
|
65
|
+
binaries: ['mikro-orm'],
|
|
66
|
+
config: true,
|
|
67
|
+
string: ['contextName'],
|
|
68
|
+
};
|
|
69
|
+
const plugin = {
|
|
70
|
+
title,
|
|
71
|
+
enablers,
|
|
72
|
+
isEnabled,
|
|
73
|
+
config,
|
|
74
|
+
args,
|
|
75
|
+
resolveConfig,
|
|
76
|
+
};
|
|
77
|
+
export default plugin;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
type MikroOrmDirectoryConfig = {
|
|
2
|
+
path?: string;
|
|
3
|
+
pathTs?: string;
|
|
4
|
+
glob?: string;
|
|
5
|
+
};
|
|
6
|
+
export type MikroOrmOptions = {
|
|
7
|
+
baseDir?: string;
|
|
8
|
+
entities?: unknown;
|
|
9
|
+
entitiesTs?: unknown;
|
|
10
|
+
migrations?: MikroOrmDirectoryConfig & {
|
|
11
|
+
migrationsList?: unknown;
|
|
12
|
+
};
|
|
13
|
+
seeder?: MikroOrmDirectoryConfig;
|
|
14
|
+
};
|
|
15
|
+
export type MikroOrmPackageJson = {
|
|
16
|
+
configPaths?: string | string[];
|
|
17
|
+
};
|
|
18
|
+
export type MikroOrmConfigFactory = (contextName: string) => MikroOrmOptions | MikroOrmOptions[] | Promise<MikroOrmOptions | MikroOrmOptions[]>;
|
|
19
|
+
export type MikroOrmConfigItem = MikroOrmOptions | MikroOrmConfigFactory;
|
|
20
|
+
export type MikroOrmConfig = MikroOrmConfigItem | MikroOrmConfigItem[] | MikroOrmPackageJson;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -7,9 +7,12 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
|
7
7
|
const config = ['package.json'];
|
|
8
8
|
const entry = ['mockServiceWorker.js'];
|
|
9
9
|
const resolveConfig = async (localConfig) => {
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
10
|
+
const dirs = localConfig?.workerDirectory ? [localConfig.workerDirectory].flat() : ['.'];
|
|
11
|
+
const inputs = [];
|
|
12
|
+
for (const dir of dirs)
|
|
13
|
+
for (const pattern of entry)
|
|
14
|
+
inputs.push(toEntry(join(dir, pattern)));
|
|
15
|
+
return inputs;
|
|
13
16
|
};
|
|
14
17
|
const plugin = {
|
|
15
18
|
title,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { toDependency, toProductionEntry } from '../../util/input.js';
|
|
2
|
-
import { join } from '../../util/path.js';
|
|
1
|
+
import { toDeferResolve, toDependency, toProductionEntry } from '../../util/input.js';
|
|
2
|
+
import { isInternal, join } from '../../util/path.js';
|
|
3
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
4
|
import { extractFunctionsConfigProperty } from './helpers.js';
|
|
5
5
|
const title = 'Netlify';
|
|
@@ -9,6 +9,10 @@ const config = ['netlify.toml'];
|
|
|
9
9
|
const NETLIFY_FUNCTIONS_DIR = 'netlify/functions';
|
|
10
10
|
const NETLIFY_FUNCTIONS_EXTS = 'js,mjs,cjs,ts,mts,cts';
|
|
11
11
|
const production = [`${NETLIFY_FUNCTIONS_DIR}/**/*.{${NETLIFY_FUNCTIONS_EXTS}}`];
|
|
12
|
+
const toPluginInput = (id) => {
|
|
13
|
+
const specifier = id.startsWith('/') ? `.${id}` : id;
|
|
14
|
+
return isInternal(specifier) ? toDeferResolve(specifier) : toDependency(id);
|
|
15
|
+
};
|
|
12
16
|
const resolveConfig = async (localConfig) => {
|
|
13
17
|
return [
|
|
14
18
|
...extractFunctionsConfigProperty(localConfig.functions || {}, 'included_files'),
|
|
@@ -17,7 +21,7 @@ const resolveConfig = async (localConfig) => {
|
|
|
17
21
|
.filter(file => !file.startsWith('!'))
|
|
18
22
|
.map(id => toProductionEntry(id))
|
|
19
23
|
.concat([
|
|
20
|
-
...(localConfig?.plugins?.map(plugin => plugin.package) ?? []).map(
|
|
24
|
+
...(localConfig?.plugins?.map(plugin => plugin.package) ?? []).map(toPluginInput),
|
|
21
25
|
...extractFunctionsConfigProperty(localConfig.functions || {}, 'external_node_modules').map(id => toDependency(id)),
|
|
22
26
|
]);
|
|
23
27
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Visitor } from 'oxc-parser';
|
|
2
|
-
import { findProperty, getPropertyValues } from '../../typescript/ast-helpers.js';
|
|
1
|
+
import { Visitor, } from 'oxc-parser';
|
|
2
|
+
import { findProperty, getPropertyValues, resolveObjectArg } from '../../typescript/ast-helpers.js';
|
|
3
3
|
import { getStringValue } from '../../typescript/ast-nodes.js';
|
|
4
4
|
import { isDirectory } from '../../util/fs.js';
|
|
5
|
-
import { toConfig, toDeferResolve, toProductionEntry } from '../../util/input.js';
|
|
6
|
-
import { isInNodeModules, join } from '../../util/path.js';
|
|
5
|
+
import { toConfig, toDeferResolve, toDeferResolveProductionEntry, toProductionEntry } from '../../util/input.js';
|
|
6
|
+
import { isInNodeModules, join, toAbsolute } from '../../util/path.js';
|
|
7
7
|
import { hasDependency } from '../../util/plugin.js';
|
|
8
8
|
const title = 'Next.js';
|
|
9
9
|
const enablers = ['next'];
|
|
@@ -39,14 +39,16 @@ const getEntryFilePatterns = (pageExtensions = defaultPageExtensions, cwd) => {
|
|
|
39
39
|
];
|
|
40
40
|
};
|
|
41
41
|
const production = getEntryFilePatterns();
|
|
42
|
-
const getInputs = (pageExtensions, loaders, aliasTargets, configFileDir) => {
|
|
42
|
+
const getInputs = (pageExtensions, loaders, aliasTargets, files, configFileDir) => {
|
|
43
43
|
const extensions = pageExtensions.length > 0 ? pageExtensions : defaultPageExtensions;
|
|
44
44
|
const patterns = [...getEntryFilePatterns(extensions, configFileDir), 'next-env.d.ts'];
|
|
45
45
|
const inputs = patterns.map(id => toProductionEntry(join(configFileDir, id)));
|
|
46
46
|
for (const loader of loaders)
|
|
47
47
|
inputs.push(toDeferResolve(loader));
|
|
48
48
|
for (const target of aliasTargets)
|
|
49
|
-
inputs.push(
|
|
49
|
+
inputs.push(toDeferResolve(target, { dir: configFileDir, production: true }));
|
|
50
|
+
for (const file of files)
|
|
51
|
+
inputs.push(toDeferResolveProductionEntry(toAbsolute(file, configFileDir)));
|
|
50
52
|
return inputs;
|
|
51
53
|
};
|
|
52
54
|
const isObject = (value) => typeof value === 'object' && value !== null;
|
|
@@ -87,12 +89,63 @@ const resolveConfig = async (localConfig, { configFileDir }) => {
|
|
|
87
89
|
const aliasTargets = new Set();
|
|
88
90
|
for (const target of Object.values(config?.turbopack?.resolveAlias ?? {}))
|
|
89
91
|
collectAliasTargetValues(target, aliasTargets);
|
|
90
|
-
|
|
92
|
+
const files = new Set();
|
|
93
|
+
addSpecifier(files, config?.images?.loaderFile);
|
|
94
|
+
addSpecifier(files, config?.cacheHandler);
|
|
95
|
+
for (const handler of Object.values(config?.cacheHandlers ?? {}))
|
|
96
|
+
addSpecifier(files, handler);
|
|
97
|
+
return getInputs(pageExtensions, loaders, aliasTargets, files, configFileDir);
|
|
98
|
+
};
|
|
99
|
+
const isModuleExports = (node) => node.type === 'MemberExpression' &&
|
|
100
|
+
node.object.type === 'Identifier' &&
|
|
101
|
+
node.object.name === 'module' &&
|
|
102
|
+
node.property.type === 'Identifier' &&
|
|
103
|
+
node.property.name === 'exports';
|
|
104
|
+
const getConfigObject = (program) => {
|
|
105
|
+
const declarations = new Map();
|
|
106
|
+
let node;
|
|
107
|
+
for (const statement of program.body) {
|
|
108
|
+
if (statement.type === 'VariableDeclaration') {
|
|
109
|
+
for (const declaration of statement.declarations) {
|
|
110
|
+
if (declaration.id.type === 'Identifier' && declaration.init)
|
|
111
|
+
declarations.set(declaration.id.name, declaration.init);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else if (statement.type === 'ExportDefaultDeclaration') {
|
|
115
|
+
node = statement.declaration;
|
|
116
|
+
}
|
|
117
|
+
else if (statement.type === 'ExpressionStatement' &&
|
|
118
|
+
statement.expression.type === 'AssignmentExpression' &&
|
|
119
|
+
isModuleExports(statement.expression.left)) {
|
|
120
|
+
node = statement.expression.right;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
while (node) {
|
|
124
|
+
if (node.type === 'TSSatisfiesExpression' ||
|
|
125
|
+
node.type === 'TSAsExpression' ||
|
|
126
|
+
node.type === 'ParenthesizedExpression')
|
|
127
|
+
node = node.expression;
|
|
128
|
+
else if (node.type === 'CallExpression')
|
|
129
|
+
node = node.arguments[0];
|
|
130
|
+
else if (node.type === 'Identifier') {
|
|
131
|
+
const init = declarations.get(node.name);
|
|
132
|
+
declarations.delete(node.name);
|
|
133
|
+
node = init;
|
|
134
|
+
}
|
|
135
|
+
else
|
|
136
|
+
return resolveObjectArg(node);
|
|
137
|
+
}
|
|
91
138
|
};
|
|
92
139
|
const resolveFromAST = (program, { configFileDir }) => {
|
|
93
140
|
const pageExtensions = new Set();
|
|
94
141
|
const loaders = new Set();
|
|
95
142
|
const aliasTargets = new Set();
|
|
143
|
+
const files = new Set();
|
|
144
|
+
const config = getConfigObject(program);
|
|
145
|
+
addSpecifier(files, getStringValue(findProperty(findProperty(config, 'images'), 'loaderFile')));
|
|
146
|
+
addSpecifier(files, getStringValue(findProperty(config, 'cacheHandler')));
|
|
147
|
+
for (const handler of getPropertyValues(config, 'cacheHandlers'))
|
|
148
|
+
addSpecifier(files, handler);
|
|
96
149
|
const collectAliasTargets = (node) => {
|
|
97
150
|
const target = getStringValue(node);
|
|
98
151
|
if (target)
|
|
@@ -150,7 +203,7 @@ const resolveFromAST = (program, { configFileDir }) => {
|
|
|
150
203
|
},
|
|
151
204
|
});
|
|
152
205
|
visitor.visit(program);
|
|
153
|
-
return getInputs([...pageExtensions], loaders, aliasTargets, configFileDir);
|
|
206
|
+
return getInputs([...pageExtensions], loaders, aliasTargets, files, configFileDir);
|
|
154
207
|
};
|
|
155
208
|
const commands = new Set(['dev', 'build', 'start']);
|
|
156
209
|
const args = {
|
|
@@ -162,7 +215,8 @@ const args = {
|
|
|
162
215
|
return [toConfig('next', join(dir, 'next.config'))];
|
|
163
216
|
},
|
|
164
217
|
};
|
|
165
|
-
const note = `Knip loads \`next.config.*\` to read Turbopack loaders and alias targets
|
|
218
|
+
const note = `Knip loads \`next.config.*\` to read Turbopack loaders and alias targets, the custom image loader
|
|
219
|
+
(\`images.loaderFile\`) and cache handlers (\`cacheHandler\`, \`cacheHandlers\`) from the composed configuration,
|
|
166
220
|
including values a shared configuration factory adds. A configuration file that fails to load is analyzed statically.`;
|
|
167
221
|
export const docs = { note };
|
|
168
222
|
const plugin = {
|