knip 6.25.0 → 6.27.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 +108 -0
- package/dist/DependencyDeputy.d.ts +1 -1
- package/dist/DependencyDeputy.js +2 -2
- package/dist/ProjectPrincipal.d.ts +3 -3
- package/dist/ProjectPrincipal.js +4 -4
- package/dist/binaries/fallback.js +5 -1
- package/dist/binaries/resolvers/bun.js +13 -5
- package/dist/binaries/resolvers/npm.js +4 -2
- package/dist/binaries/resolvers/pnpm.js +11 -1
- package/dist/binaries/resolvers/yarn.js +10 -4
- package/dist/binaries/util.d.ts +4 -0
- package/dist/binaries/util.js +14 -0
- package/dist/compilers/index.d.ts +180 -0
- package/dist/compilers/less.js +1 -1
- package/dist/compilers/scss.js +1 -1
- package/dist/compilers/stylus.js +1 -1
- package/dist/constants.js +19 -0
- package/dist/graph/analyze.js +1 -1
- package/dist/graph/build.js +24 -7
- package/dist/plugins/_vue/auto-import.d.ts +12 -0
- package/dist/plugins/_vue/auto-import.js +332 -0
- package/dist/plugins/_vue/types.d.ts +45 -0
- package/dist/plugins/_vue/types.js +1 -0
- package/dist/plugins/astro/index.js +2 -37
- package/dist/plugins/astro/resolveFromAST.d.ts +4 -4
- package/dist/plugins/astro/resolveFromAST.js +34 -7
- package/dist/plugins/electron-vite/index.d.ts +3 -0
- package/dist/plugins/electron-vite/index.js +51 -0
- package/dist/plugins/electron-vite/types.d.ts +23 -0
- package/dist/plugins/electron-vite/types.js +1 -0
- package/dist/plugins/esbuild/index.d.ts +3 -0
- package/dist/plugins/esbuild/index.js +17 -0
- package/dist/plugins/eslint/resolveFromAST.js +18 -21
- package/dist/plugins/index.d.ts +18 -0
- package/dist/plugins/index.js +36 -0
- package/dist/plugins/laravel-vite-plugin/index.d.ts +3 -0
- package/dist/plugins/laravel-vite-plugin/index.js +14 -0
- package/dist/plugins/laravel-vite-plugin/resolveFromAST.d.ts +2 -0
- package/dist/plugins/laravel-vite-plugin/resolveFromAST.js +27 -0
- package/dist/plugins/next/index.js +2 -2
- package/dist/plugins/next-mdx/index.js +2 -8
- package/dist/plugins/next-mdx/resolveFromAST.d.ts +3 -2
- package/dist/plugins/next-mdx/resolveFromAST.js +17 -21
- package/dist/plugins/nuxt/index.js +5 -68
- package/dist/plugins/nuxt/types.d.ts +0 -34
- package/dist/plugins/nuxtjs-i18n/index.d.ts +3 -0
- package/dist/plugins/nuxtjs-i18n/index.js +12 -0
- package/dist/plugins/oclif/index.js +10 -5
- package/dist/plugins/orval/index.js +1 -3
- package/dist/plugins/orval/resolveFromAST.d.ts +2 -2
- package/dist/plugins/orval/resolveFromAST.js +4 -7
- package/dist/plugins/oxlint/index.js +23 -2
- package/dist/plugins/pnpm/index.js +2 -1
- package/dist/plugins/pnpm/types.d.ts +2 -4
- package/dist/plugins/quasar/index.d.ts +3 -0
- package/dist/plugins/quasar/index.js +15 -0
- package/dist/plugins/quasar/resolveFromAST.d.ts +3 -0
- package/dist/plugins/quasar/resolveFromAST.js +63 -0
- package/dist/plugins/qwik/index.js +1 -25
- package/dist/plugins/qwik/resolveFromAST.d.ts +5 -3
- package/dist/plugins/qwik/resolveFromAST.js +28 -9
- package/dist/plugins/react-email/index.js +1 -0
- package/dist/plugins/rolldown/index.js +2 -5
- package/dist/plugins/rollup/index.js +2 -5
- package/dist/plugins/rslib/index.js +2 -5
- package/dist/plugins/sst/index.js +1 -5
- package/dist/plugins/sst/resolveFromAST.d.ts +1 -1
- package/dist/plugins/sst/resolveFromAST.js +1 -1
- package/dist/plugins/starlight/index.js +1 -19
- package/dist/plugins/starlight/resolveFromAST.d.ts +2 -2
- package/dist/plugins/starlight/resolveFromAST.js +12 -8
- package/dist/plugins/stencil/index.js +2 -37
- package/dist/plugins/stencil/resolveFromAST.d.ts +3 -0
- package/dist/plugins/stencil/resolveFromAST.js +36 -0
- package/dist/plugins/storybook/index.js +3 -0
- package/dist/plugins/sveltekit/index.js +1 -48
- package/dist/plugins/sveltekit/resolveFromAST.d.ts +2 -0
- package/dist/plugins/sveltekit/resolveFromAST.js +45 -0
- package/dist/plugins/tailwind/compiler.js +9 -4
- package/dist/plugins/tanstack-router/index.js +3 -1
- package/dist/plugins/tauri/index.d.ts +3 -0
- package/dist/plugins/tauri/index.js +42 -0
- package/dist/plugins/tauri/types.d.ts +16 -0
- package/dist/plugins/tauri/types.js +1 -0
- package/dist/plugins/temporal/index.d.ts +3 -0
- package/dist/plugins/temporal/index.js +12 -0
- package/dist/plugins/tsdown/index.js +16 -7
- package/dist/plugins/tsdown/types.d.ts +4 -1
- package/dist/plugins/tsup/index.js +2 -5
- package/dist/plugins/unplugin-auto-import/index.d.ts +3 -0
- package/dist/plugins/unplugin-auto-import/index.js +18 -0
- package/dist/plugins/unplugin-icons/index.d.ts +3 -0
- package/dist/plugins/unplugin-icons/index.js +17 -0
- package/dist/plugins/unplugin-vue-components/index.d.ts +3 -0
- package/dist/plugins/unplugin-vue-components/index.js +16 -0
- package/dist/plugins/unplugin-vue-i18n/index.d.ts +3 -0
- package/dist/plugins/unplugin-vue-i18n/index.js +10 -0
- package/dist/plugins/unplugin-vue-markdown/index.d.ts +3 -0
- package/dist/plugins/unplugin-vue-markdown/index.js +16 -0
- package/dist/plugins/unplugin-vue-router/index.d.ts +3 -0
- package/dist/plugins/unplugin-vue-router/index.js +14 -0
- package/dist/plugins/vite/helpers.d.ts +2 -0
- package/dist/plugins/vite/helpers.js +46 -31
- package/dist/plugins/vite/index.js +1 -1
- package/dist/plugins/vite-plugin-pages/index.d.ts +3 -0
- package/dist/plugins/vite-plugin-pages/index.js +26 -0
- package/dist/plugins/vite-plugin-pwa/index.d.ts +3 -0
- package/dist/plugins/vite-plugin-pwa/index.js +17 -0
- package/dist/plugins/vite-plugin-pwa/resolveFromAST.d.ts +4 -0
- package/dist/plugins/vite-plugin-pwa/resolveFromAST.js +37 -0
- package/dist/plugins/vite-plugin-vue-layouts-next/index.d.ts +3 -0
- package/dist/plugins/vite-plugin-vue-layouts-next/index.js +23 -0
- package/dist/plugins/vite-plus/index.d.ts +3 -0
- package/dist/plugins/vite-plus/index.js +14 -0
- package/dist/plugins/vite-plus/resolveFromAST.d.ts +2 -0
- package/dist/plugins/vite-plus/resolveFromAST.js +37 -0
- package/dist/plugins/vite-pwa-assets-generator/index.d.ts +3 -0
- package/dist/plugins/vite-pwa-assets-generator/index.js +12 -0
- package/dist/plugins/vitepress/index.js +5 -1
- package/dist/plugins/vitest/index.js +19 -0
- package/dist/plugins/vitest/types.d.ts +8 -0
- package/dist/plugins/vue/index.js +5 -3
- package/dist/plugins/yarn/index.js +2 -1
- package/dist/plugins/yarn/types.d.ts +2 -4
- package/dist/run.js +3 -3
- package/dist/schema/configuration.d.ts +270 -0
- package/dist/schema/plugins.d.ts +90 -0
- package/dist/schema/plugins.js +18 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +18 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/package-json.d.ts +8 -4
- package/dist/typescript/ast-helpers.d.ts +7 -2
- package/dist/typescript/ast-helpers.js +36 -8
- package/dist/typescript/ast-nodes.d.ts +2 -0
- package/dist/typescript/ast-nodes.js +8 -0
- package/dist/typescript/get-imports-and-exports.js +8 -5
- package/dist/typescript/resolve-module-names.d.ts +2 -2
- package/dist/typescript/resolve-module-names.js +97 -18
- package/dist/typescript/visitors/walk.d.ts +2 -1
- package/dist/typescript/visitors/walk.js +13 -2
- package/dist/util/cli-arguments.d.ts +1 -1
- package/dist/util/cli-arguments.js +1 -1
- package/dist/util/create-input-handler.js +8 -1
- package/dist/util/create-options.d.ts +180 -0
- package/dist/util/package-json.d.ts +7 -0
- package/dist/util/package-json.js +37 -0
- package/dist/util/resolve.d.ts +1 -0
- package/dist/util/resolve.js +5 -2
- package/dist/util/to-source-path.d.ts +4 -3
- package/dist/util/to-source-path.js +23 -6
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schema.json +72 -0
- package/dist/plugins/next/resolveFromAST.d.ts +0 -2
- package/dist/plugins/next/resolveFromAST.js +0 -2
- package/dist/plugins/nuxt/helpers.d.ts +0 -15
- package/dist/plugins/nuxt/helpers.js +0 -133
- package/dist/plugins/rolldown/resolveFromAST.d.ts +0 -2
- package/dist/plugins/rolldown/resolveFromAST.js +0 -4
- package/dist/plugins/rollup/resolveFromAST.d.ts +0 -2
- package/dist/plugins/rollup/resolveFromAST.js +0 -4
- package/dist/plugins/rslib/resolveFromAST.d.ts +0 -2
- package/dist/plugins/rslib/resolveFromAST.js +0 -4
- package/dist/plugins/tsdown/resolveFromAST.d.ts +0 -2
- package/dist/plugins/tsdown/resolveFromAST.js +0 -4
- package/dist/plugins/tsup/resolveFromAST.d.ts +0 -2
- package/dist/plugins/tsup/resolveFromAST.js +0 -4
- package/dist/plugins/vue/compiler.d.ts +0 -3
- package/dist/plugins/vue/compiler.js +0 -10
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type BeforeCommand = string | {
|
|
2
|
+
script?: string;
|
|
3
|
+
cwd?: string;
|
|
4
|
+
wait?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export interface TauriConfig {
|
|
7
|
+
build?: {
|
|
8
|
+
beforeDevCommand?: BeforeCommand;
|
|
9
|
+
beforeBuildCommand?: BeforeCommand;
|
|
10
|
+
beforeBundleCommand?: BeforeCommand;
|
|
11
|
+
'before-dev-command'?: BeforeCommand;
|
|
12
|
+
'before-build-command'?: BeforeCommand;
|
|
13
|
+
'before-bundle-command'?: BeforeCommand;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
2
|
+
const title = 'Temporal.io';
|
|
3
|
+
const enablers = ['@temporalio/worker'];
|
|
4
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
5
|
+
const production = ['src/workflows{,/index}.{js,cjs,mjs,ts,cts,mts}'];
|
|
6
|
+
const plugin = {
|
|
7
|
+
title,
|
|
8
|
+
enablers,
|
|
9
|
+
isEnabled,
|
|
10
|
+
production,
|
|
11
|
+
};
|
|
12
|
+
export default plugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { collectPropertyValues } from '../../typescript/ast-helpers.js';
|
|
2
|
+
import { toDependency, toProductionEntry } from '../../util/input.js';
|
|
2
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
3
|
-
import { getEntryFromAST } from './resolveFromAST.js';
|
|
4
4
|
const title = 'tsdown';
|
|
5
5
|
const enablers = ['tsdown'];
|
|
6
6
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
@@ -17,6 +17,11 @@ const normalizeEntry = (entry) => {
|
|
|
17
17
|
}
|
|
18
18
|
return Object.values(entry).flatMap(value => (Array.isArray(value) ? value : [value]));
|
|
19
19
|
};
|
|
20
|
+
const getExternalDependencies = (options) => {
|
|
21
|
+
const neverBundle = options.deps?.neverBundle;
|
|
22
|
+
const values = Array.isArray(neverBundle) ? neverBundle : [neverBundle];
|
|
23
|
+
return values.filter(value => typeof value === 'string');
|
|
24
|
+
};
|
|
20
25
|
const resolveConfig = async (config) => {
|
|
21
26
|
if (typeof config === 'function')
|
|
22
27
|
config = await config({});
|
|
@@ -24,12 +29,16 @@ const resolveConfig = async (config) => {
|
|
|
24
29
|
.flat()
|
|
25
30
|
.flatMap(config => normalizeEntry(config.entry))
|
|
26
31
|
.map(id => toProductionEntry(id, { allowIncludeExports: true }));
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return [...
|
|
32
|
+
const externalDependencies = [config]
|
|
33
|
+
.flat()
|
|
34
|
+
.flatMap(getExternalDependencies)
|
|
35
|
+
.map(id => toDependency(id, { optional: true }));
|
|
36
|
+
return [...entryPatterns, ...externalDependencies];
|
|
32
37
|
};
|
|
38
|
+
const resolveFromAST = program => [
|
|
39
|
+
...[...collectPropertyValues(program, 'entry')].map(id => toProductionEntry(id, { allowIncludeExports: true })),
|
|
40
|
+
...[...collectPropertyValues(program, 'neverBundle')].map(id => toDependency(id, { optional: true })),
|
|
41
|
+
];
|
|
33
42
|
const args = {
|
|
34
43
|
config: true,
|
|
35
44
|
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export type Entry = (string | Record<string, string[] | string>)[] | string | Record<string, string[] | string>;
|
|
2
|
-
type Options = {
|
|
2
|
+
export type Options = {
|
|
3
3
|
entry?: Entry;
|
|
4
|
+
deps?: {
|
|
5
|
+
neverBundle?: unknown;
|
|
6
|
+
};
|
|
4
7
|
};
|
|
5
8
|
type MaybePromise<T> = T | Promise<T>;
|
|
6
9
|
export type TsdownConfig = Options | Options[] | ((overrideOptions: Options) => MaybePromise<Options | Options[]>);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { collectPropertyValues } from '../../typescript/ast-helpers.js';
|
|
1
2
|
import { toProductionEntry } from '../../util/input.js';
|
|
2
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
3
|
-
import { getEntryFromAST } from './resolveFromAST.js';
|
|
4
4
|
const title = 'tsup';
|
|
5
5
|
const enablers = ['tsup'];
|
|
6
6
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
@@ -21,10 +21,7 @@ const resolveConfig = async (config) => {
|
|
|
21
21
|
.map(id => toProductionEntry(id, { allowIncludeExports: true }));
|
|
22
22
|
return entryPatterns;
|
|
23
23
|
};
|
|
24
|
-
const resolveFromAST = program => {
|
|
25
|
-
const entries = getEntryFromAST(program);
|
|
26
|
-
return [...entries].map(id => toProductionEntry(id, { allowIncludeExports: true }));
|
|
27
|
-
};
|
|
24
|
+
const resolveFromAST = program => [...collectPropertyValues(program, 'entry')].map(id => toProductionEntry(id, { allowIncludeExports: true }));
|
|
28
25
|
const args = {
|
|
29
26
|
config: true,
|
|
30
27
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
2
|
+
import { tsAutoImportCompiler, vueAutoImportCompiler } from '../_vue/auto-import.js';
|
|
3
|
+
const title = 'unplugin-auto-import';
|
|
4
|
+
const enablers = ['unplugin-auto-import'];
|
|
5
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
+
const registerCompilers = ({ hasDependency, registerCompiler }) => {
|
|
7
|
+
if (hasDependency('unplugin-auto-import')) {
|
|
8
|
+
registerCompiler({ extension: '.vue', compiler: vueAutoImportCompiler });
|
|
9
|
+
registerCompiler({ extension: '.ts', compiler: tsAutoImportCompiler });
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
const plugin = {
|
|
13
|
+
title,
|
|
14
|
+
enablers,
|
|
15
|
+
isEnabled,
|
|
16
|
+
registerCompilers,
|
|
17
|
+
};
|
|
18
|
+
export default plugin;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { toIgnore } from '../../util/input.js';
|
|
2
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
3
|
+
const title = 'unplugin-icons';
|
|
4
|
+
const enablers = ['unplugin-icons'];
|
|
5
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
+
const resolve = () => [
|
|
7
|
+
toIgnore('~icons/.*', 'unresolved'),
|
|
8
|
+
toIgnore('@iconify-json/.*', 'dependencies'),
|
|
9
|
+
toIgnore('@iconify/json', 'dependencies'),
|
|
10
|
+
];
|
|
11
|
+
const plugin = {
|
|
12
|
+
title,
|
|
13
|
+
enablers,
|
|
14
|
+
isEnabled,
|
|
15
|
+
resolve,
|
|
16
|
+
};
|
|
17
|
+
export default plugin;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
2
|
+
import { vueAutoImportCompiler } from '../_vue/auto-import.js';
|
|
3
|
+
const title = 'unplugin-vue-components';
|
|
4
|
+
const enablers = ['unplugin-vue-components'];
|
|
5
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
+
const registerCompilers = ({ hasDependency, registerCompiler }) => {
|
|
7
|
+
if (hasDependency('unplugin-vue-components'))
|
|
8
|
+
registerCompiler({ extension: '.vue', compiler: vueAutoImportCompiler });
|
|
9
|
+
};
|
|
10
|
+
const plugin = {
|
|
11
|
+
title,
|
|
12
|
+
enablers,
|
|
13
|
+
isEnabled,
|
|
14
|
+
registerCompilers,
|
|
15
|
+
};
|
|
16
|
+
export default plugin;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
2
|
+
const title = '@intlify/unplugin-vue-i18n';
|
|
3
|
+
const enablers = ['@intlify/unplugin-vue-i18n'];
|
|
4
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
5
|
+
const plugin = {
|
|
6
|
+
title,
|
|
7
|
+
enablers,
|
|
8
|
+
isEnabled,
|
|
9
|
+
};
|
|
10
|
+
export default plugin;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
2
|
+
import { markdownAutoImportCompiler } from '../_vue/auto-import.js';
|
|
3
|
+
const title = 'unplugin-vue-markdown';
|
|
4
|
+
const enablers = ['unplugin-vue-markdown'];
|
|
5
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
+
const registerCompilers = ({ hasDependency, registerCompiler }) => {
|
|
7
|
+
if (hasDependency('unplugin-vue-markdown'))
|
|
8
|
+
registerCompiler({ extension: '.md', compiler: markdownAutoImportCompiler });
|
|
9
|
+
};
|
|
10
|
+
const plugin = {
|
|
11
|
+
title,
|
|
12
|
+
enablers,
|
|
13
|
+
isEnabled,
|
|
14
|
+
registerCompilers,
|
|
15
|
+
};
|
|
16
|
+
export default plugin;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
2
|
+
import { findGeneratedDts } from '../_vue/auto-import.js';
|
|
3
|
+
const title = 'unplugin-vue-router';
|
|
4
|
+
const enablers = ['unplugin-vue-router', 'vue-router'];
|
|
5
|
+
const isEnabled = ({ cwd, dependencies }) => hasDependency(dependencies, ['unplugin-vue-router']) ||
|
|
6
|
+
(hasDependency(dependencies, ['vue-router']) && findGeneratedDts(cwd, 'Generated by vue-router').length > 0);
|
|
7
|
+
const production = ['src/pages/**/*.{vue,md}'];
|
|
8
|
+
const plugin = {
|
|
9
|
+
title,
|
|
10
|
+
enablers,
|
|
11
|
+
isEnabled,
|
|
12
|
+
production,
|
|
13
|
+
};
|
|
14
|
+
export default plugin;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Program } from 'oxc-parser';
|
|
2
2
|
import { type Input } from '../../util/input.ts';
|
|
3
3
|
export declare const getBabelInputs: (program: Program) => Input[];
|
|
4
|
+
export declare const getHtmlScriptEntries: (htmlPath: string) => Promise<Input[]>;
|
|
4
5
|
export declare const getIndexHtmlEntries: (rootDir: string) => Promise<Input[]>;
|
|
6
|
+
export declare const getVitePluginDirs: (program: Program, specifiers: string[], key: string) => string[] | undefined;
|
|
@@ -1,36 +1,24 @@
|
|
|
1
|
-
import { Visitor } from 'oxc-parser';
|
|
2
1
|
import { blockCommentMatcher, lineCommentMatcher, scriptExtractor } from '../../compilers/compilers.js';
|
|
3
|
-
import {
|
|
2
|
+
import { findImportedCalls, findProperty, getStringValues } from '../../typescript/ast-helpers.js';
|
|
3
|
+
import { getStringValue } from '../../typescript/ast-nodes.js';
|
|
4
4
|
import { isFile, loadFile } from '../../util/fs.js';
|
|
5
5
|
import { toProductionEntry } from '../../util/input.js';
|
|
6
|
-
import { join } from '../../util/path.js';
|
|
6
|
+
import { dirname, join } from '../../util/path.js';
|
|
7
7
|
import { getDependenciesFromConfig } from '../babel/index.js';
|
|
8
8
|
const babelPluginSources = ['@rolldown/plugin-babel', '@vitejs/plugin-react', 'vite-plugin-babel'];
|
|
9
9
|
const isBabelWrappingPlugin = (path) => babelPluginSources.some(source => path === source || path.startsWith(`${source}/`));
|
|
10
10
|
export const getBabelInputs = (program) => {
|
|
11
|
-
const pluginNames = new Set();
|
|
12
|
-
for (const [name, path] of getImportMap(program)) {
|
|
13
|
-
if (isBabelWrappingPlugin(path))
|
|
14
|
-
pluginNames.add(name);
|
|
15
|
-
}
|
|
16
|
-
if (pluginNames.size === 0)
|
|
17
|
-
return [];
|
|
18
11
|
const inputs = [];
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
inputs.push(...getDependenciesFromConfig({ plugins, presets }));
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
visitor.visit(program);
|
|
12
|
+
for (const call of findImportedCalls(program, isBabelWrappingPlugin)) {
|
|
13
|
+
const options = call.arguments?.[0];
|
|
14
|
+
const plugins = [];
|
|
15
|
+
const presets = [];
|
|
16
|
+
for (const config of [options, findProperty(options, 'babel'), findProperty(options, 'babelConfig')]) {
|
|
17
|
+
plugins.push(...getStringValues(findProperty(config, 'plugins')));
|
|
18
|
+
presets.push(...getStringValues(findProperty(config, 'presets')));
|
|
19
|
+
}
|
|
20
|
+
inputs.push(...getDependenciesFromConfig({ plugins, presets }));
|
|
21
|
+
}
|
|
34
22
|
return inputs;
|
|
35
23
|
};
|
|
36
24
|
const moduleTypePattern = /\btype\s*=\s*["']?module["']?/i;
|
|
@@ -61,11 +49,38 @@ const getModuleScriptSources = (html) => {
|
|
|
61
49
|
}
|
|
62
50
|
return sources;
|
|
63
51
|
};
|
|
64
|
-
export const
|
|
65
|
-
|
|
66
|
-
if (!isFile(indexPath))
|
|
52
|
+
export const getHtmlScriptEntries = async (htmlPath) => {
|
|
53
|
+
if (!isFile(htmlPath))
|
|
67
54
|
return [];
|
|
68
|
-
const html = await loadFile(
|
|
69
|
-
const
|
|
70
|
-
return
|
|
55
|
+
const html = await loadFile(htmlPath);
|
|
56
|
+
const dir = dirname(htmlPath);
|
|
57
|
+
return getModuleScriptSources(html).map(src => toProductionEntry(join(dir, src)));
|
|
58
|
+
};
|
|
59
|
+
export const getIndexHtmlEntries = (rootDir) => getHtmlScriptEntries(join(rootDir, 'index.html'));
|
|
60
|
+
export const getVitePluginDirs = (program, specifiers, key) => {
|
|
61
|
+
let dirs;
|
|
62
|
+
for (const call of findImportedCalls(program, specifiers)) {
|
|
63
|
+
const value = findProperty(call.arguments?.[0], key);
|
|
64
|
+
if (!value)
|
|
65
|
+
continue;
|
|
66
|
+
const collected = [];
|
|
67
|
+
const single = getStringValue(value);
|
|
68
|
+
if (single !== undefined)
|
|
69
|
+
collected.push(single);
|
|
70
|
+
else if (value.type === 'ArrayExpression') {
|
|
71
|
+
for (const element of value.elements ?? []) {
|
|
72
|
+
const str = getStringValue(element);
|
|
73
|
+
if (str !== undefined)
|
|
74
|
+
collected.push(str);
|
|
75
|
+
else if (element?.type === 'ObjectExpression') {
|
|
76
|
+
const dir = getStringValue(findProperty(element, 'dir'));
|
|
77
|
+
if (dir !== undefined)
|
|
78
|
+
collected.push(dir);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (collected.length > 0)
|
|
83
|
+
dirs = collected;
|
|
84
|
+
}
|
|
85
|
+
return dirs;
|
|
71
86
|
};
|
|
@@ -6,7 +6,7 @@ const title = 'Vite';
|
|
|
6
6
|
const enablers = ['vite', 'vitest', 'vite-plus'];
|
|
7
7
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
8
8
|
export const config = ['vite.config.{js,mjs,ts,cjs,mts,cts}'];
|
|
9
|
-
const resolveFromAST =
|
|
9
|
+
const resolveFromAST = getBabelInputs;
|
|
10
10
|
const registerVisitors = ({ ctx, registerVisitor }) => {
|
|
11
11
|
registerVisitor(createImportMetaGlobVisitor(ctx));
|
|
12
12
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { toIgnore, toProductionEntry } from '../../util/input.js';
|
|
2
|
+
import { join } from '../../util/path.js';
|
|
3
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
4
|
+
import { getVitePluginDirs } from '../vite/helpers.js';
|
|
5
|
+
const title = 'vite-plugin-pages';
|
|
6
|
+
const enablers = ['vite-plugin-pages'];
|
|
7
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
8
|
+
const config = ['vite.config.{js,mjs,ts,cjs,mts,cts}'];
|
|
9
|
+
const extensions = 'vue,jsx,tsx,md,mdx';
|
|
10
|
+
const defaultDir = 'src/pages';
|
|
11
|
+
const production = [`${defaultDir}/**/*.{${extensions}}`];
|
|
12
|
+
const resolveFromAST = (program, options) => {
|
|
13
|
+
const dirs = getVitePluginDirs(program, enablers, 'dirs') ?? [defaultDir];
|
|
14
|
+
return dirs.map(dir => toProductionEntry(join(options.configFileDir, `${dir}/**/*.{${extensions}}`)));
|
|
15
|
+
};
|
|
16
|
+
const resolve = () => ['~pages', '~react-pages', '~solid-pages'].map(specifier => toIgnore(specifier, 'unresolved'));
|
|
17
|
+
const plugin = {
|
|
18
|
+
title,
|
|
19
|
+
enablers,
|
|
20
|
+
isEnabled,
|
|
21
|
+
config,
|
|
22
|
+
production,
|
|
23
|
+
resolveFromAST,
|
|
24
|
+
resolve,
|
|
25
|
+
};
|
|
26
|
+
export default plugin;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { join } from '../../util/path.js';
|
|
2
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
3
|
+
import { defaultFilename, defaultSrcDir, resolveFromAST } from './resolveFromAST.js';
|
|
4
|
+
const title = 'vite-plugin-pwa';
|
|
5
|
+
const enablers = ['vite-plugin-pwa', '@vite-pwa/nuxt'];
|
|
6
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
7
|
+
const config = ['vite.config.{js,mjs,ts,cjs,mts,cts}', 'nuxt.config.{js,cjs,mjs,ts,cts,mts}'];
|
|
8
|
+
const production = [join(defaultSrcDir, defaultFilename)];
|
|
9
|
+
const plugin = {
|
|
10
|
+
title,
|
|
11
|
+
enablers,
|
|
12
|
+
isEnabled,
|
|
13
|
+
config,
|
|
14
|
+
production,
|
|
15
|
+
resolveFromAST,
|
|
16
|
+
};
|
|
17
|
+
export default plugin;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Visitor } from 'oxc-parser';
|
|
2
|
+
import { findImportedCalls, findProperty, getFirstPropertyValue, getPropertyValues, } from '../../typescript/ast-helpers.js';
|
|
3
|
+
import { toProductionEntry } from '../../util/input.js';
|
|
4
|
+
import { join } from '../../util/path.js';
|
|
5
|
+
export const defaultSrcDir = 'public';
|
|
6
|
+
export const defaultFilename = 'sw.js';
|
|
7
|
+
const isNuxtConfig = (configFileName) => configFileName.startsWith('nuxt.config.');
|
|
8
|
+
const getInjectManifestEntry = (options, configFileDir) => {
|
|
9
|
+
if (!getPropertyValues(options, 'strategies').has('injectManifest'))
|
|
10
|
+
return;
|
|
11
|
+
const srcDir = getFirstPropertyValue(options, 'srcDir') ?? defaultSrcDir;
|
|
12
|
+
const filename = getFirstPropertyValue(options, 'filename') ?? defaultFilename;
|
|
13
|
+
return toProductionEntry(join(configFileDir, srcDir, filename));
|
|
14
|
+
};
|
|
15
|
+
export const resolveFromAST = (program, options) => {
|
|
16
|
+
const inputs = [];
|
|
17
|
+
if (isNuxtConfig(options.configFileName)) {
|
|
18
|
+
const visitor = new Visitor({
|
|
19
|
+
ObjectExpression(node) {
|
|
20
|
+
const pwa = findProperty(node, 'pwa');
|
|
21
|
+
if (pwa?.type !== 'ObjectExpression')
|
|
22
|
+
return;
|
|
23
|
+
const entry = getInjectManifestEntry(pwa, options.configFileDir);
|
|
24
|
+
if (entry)
|
|
25
|
+
inputs.push(entry);
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
visitor.visit(program);
|
|
29
|
+
return inputs;
|
|
30
|
+
}
|
|
31
|
+
for (const call of findImportedCalls(program, 'vite-plugin-pwa')) {
|
|
32
|
+
const entry = getInjectManifestEntry(call.arguments?.[0], options.configFileDir);
|
|
33
|
+
if (entry)
|
|
34
|
+
inputs.push(entry);
|
|
35
|
+
}
|
|
36
|
+
return inputs;
|
|
37
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { toProductionEntry } from '../../util/input.js';
|
|
2
|
+
import { join } from '../../util/path.js';
|
|
3
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
4
|
+
import { getVitePluginDirs } from '../vite/helpers.js';
|
|
5
|
+
const title = 'vite-plugin-vue-layouts-next';
|
|
6
|
+
const enablers = ['vite-plugin-vue-layouts-next', 'vite-plugin-vue-layouts', 'vite-plugin-vue-meta-layouts'];
|
|
7
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
8
|
+
const config = ['vite.config.{js,mjs,ts,cjs,mts,cts}'];
|
|
9
|
+
const defaultDir = 'src/layouts';
|
|
10
|
+
const production = [`${defaultDir}/**/*.vue`];
|
|
11
|
+
const resolveFromAST = (program, options) => {
|
|
12
|
+
const dirs = getVitePluginDirs(program, enablers, 'layoutsDirs') ?? [defaultDir];
|
|
13
|
+
return dirs.map(dir => toProductionEntry(join(options.configFileDir, `${dir}/**/*.vue`)));
|
|
14
|
+
};
|
|
15
|
+
const plugin = {
|
|
16
|
+
title,
|
|
17
|
+
enablers,
|
|
18
|
+
isEnabled,
|
|
19
|
+
config,
|
|
20
|
+
production,
|
|
21
|
+
resolveFromAST,
|
|
22
|
+
};
|
|
23
|
+
export default plugin;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
2
|
+
import { resolveFromAST } from './resolveFromAST.js';
|
|
3
|
+
const title = 'vite-plus';
|
|
4
|
+
const enablers = ['vite-plus'];
|
|
5
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
+
const config = ['vite.config.{js,mjs,ts,cjs,mts,cts}'];
|
|
7
|
+
const plugin = {
|
|
8
|
+
title,
|
|
9
|
+
enablers,
|
|
10
|
+
isEnabled,
|
|
11
|
+
config,
|
|
12
|
+
resolveFromAST,
|
|
13
|
+
};
|
|
14
|
+
export default plugin;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Visitor } from 'oxc-parser';
|
|
2
|
+
import { findProperty, getPropertyValues } from '../../typescript/ast-helpers.js';
|
|
3
|
+
import { getStringValue } from '../../typescript/ast-nodes.js';
|
|
4
|
+
export const resolveFromAST = (program, options) => {
|
|
5
|
+
const commands = [];
|
|
6
|
+
const visitor = new Visitor({
|
|
7
|
+
ObjectExpression(node) {
|
|
8
|
+
const run = findProperty(node, 'run');
|
|
9
|
+
const tasks = run?.type === 'ObjectExpression' ? findProperty(run, 'tasks') : undefined;
|
|
10
|
+
if (tasks?.type === 'ObjectExpression') {
|
|
11
|
+
for (const task of tasks.properties ?? []) {
|
|
12
|
+
if (task.type === 'Property' && task.value?.type === 'ObjectExpression') {
|
|
13
|
+
for (const command of getPropertyValues(task.value, 'command'))
|
|
14
|
+
commands.push(command);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const staged = findProperty(node, 'staged');
|
|
19
|
+
if (staged?.type === 'ObjectExpression') {
|
|
20
|
+
for (const prop of staged.properties ?? []) {
|
|
21
|
+
if (prop.type === 'Property') {
|
|
22
|
+
const command = getStringValue(prop.value);
|
|
23
|
+
if (command)
|
|
24
|
+
commands.push(command);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
visitor.visit(program);
|
|
31
|
+
const inputs = [];
|
|
32
|
+
for (const command of commands) {
|
|
33
|
+
for (const input of options.getInputsFromScripts(command, { knownBinsOnly: true }))
|
|
34
|
+
inputs.push(input);
|
|
35
|
+
}
|
|
36
|
+
return inputs;
|
|
37
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
2
|
+
const title = '@vite-pwa/assets-generator';
|
|
3
|
+
const enablers = ['@vite-pwa/assets-generator'];
|
|
4
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
5
|
+
const config = ['pwa-assets.config.{js,cjs,mjs,ts,cts,mts}'];
|
|
6
|
+
const plugin = {
|
|
7
|
+
title,
|
|
8
|
+
enablers,
|
|
9
|
+
isEnabled,
|
|
10
|
+
config,
|
|
11
|
+
};
|
|
12
|
+
export default plugin;
|
|
@@ -2,7 +2,11 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
2
2
|
const title = 'VitePress';
|
|
3
3
|
const enablers = ['vitepress'];
|
|
4
4
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
5
|
-
const entry = [
|
|
5
|
+
const entry = [
|
|
6
|
+
'.vitepress/config.{js,ts,mjs,mts,cjs,cts}',
|
|
7
|
+
'.vitepress/config/index.{js,ts,mjs,mts,cjs,cts}',
|
|
8
|
+
'.vitepress/theme/index.{js,ts,mjs,mts}',
|
|
9
|
+
];
|
|
6
10
|
const plugin = {
|
|
7
11
|
title,
|
|
8
12
|
enablers,
|