knip 6.26.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 +6 -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 +10 -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 +6 -0
- package/dist/graph/analyze.js +1 -1
- package/dist/graph/build.js +16 -4
- package/dist/plugins/_vue/auto-import.js +64 -4
- package/dist/plugins/_vue/types.d.ts +18 -11
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +2 -0
- package/dist/plugins/react-email/index.js +1 -0
- package/dist/plugins/tailwind/compiler.js +9 -4
- package/dist/plugins/tanstack-router/index.js +3 -1
- package/dist/plugins/temporal/index.d.ts +3 -0
- package/dist/plugins/temporal/index.js +12 -0
- package/dist/plugins/tsdown/index.js +15 -3
- package/dist/plugins/tsdown/types.d.ts +4 -1
- package/dist/plugins/vitest/index.js +15 -0
- package/dist/plugins/vitest/types.d.ts +5 -0
- package/dist/run.js +3 -3
- package/dist/schema/configuration.d.ts +15 -0
- package/dist/schema/plugins.d.ts +5 -0
- package/dist/schema/plugins.js +1 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +1 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/typescript/ast-nodes.d.ts +1 -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/create-input-handler.js +8 -1
- package/dist/util/create-options.d.ts +10 -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 +1 -1
- package/dist/util/to-source-path.d.ts +4 -3
- package/dist/util/to-source-path.js +22 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schema.json +4 -0
|
@@ -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,5 +1,5 @@
|
|
|
1
1
|
import { collectPropertyValues } from '../../typescript/ast-helpers.js';
|
|
2
|
-
import { toProductionEntry } from '../../util/input.js';
|
|
2
|
+
import { toDependency, toProductionEntry } from '../../util/input.js';
|
|
3
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
4
|
const title = 'tsdown';
|
|
5
5
|
const enablers = ['tsdown'];
|
|
@@ -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,9 +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
|
-
|
|
32
|
+
const externalDependencies = [config]
|
|
33
|
+
.flat()
|
|
34
|
+
.flatMap(getExternalDependencies)
|
|
35
|
+
.map(id => toDependency(id, { optional: true }));
|
|
36
|
+
return [...entryPatterns, ...externalDependencies];
|
|
28
37
|
};
|
|
29
|
-
const resolveFromAST = program => [
|
|
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
|
+
];
|
|
30
42
|
const args = {
|
|
31
43
|
config: true,
|
|
32
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[]>);
|
|
@@ -30,6 +30,10 @@ const findConfigDependencies = (localConfig, options, vitestRoot) => {
|
|
|
30
30
|
const setupFiles = [testConfig.setupFiles ?? []]
|
|
31
31
|
.flat()
|
|
32
32
|
.map(specifier => ({ ...toDeferResolve(specifier), dir: vitestRoot }));
|
|
33
|
+
const snapshotSerializers = (testConfig.snapshotSerializers ?? []).map(specifier => ({
|
|
34
|
+
...toDeferResolve(specifier),
|
|
35
|
+
dir: vitestRoot,
|
|
36
|
+
}));
|
|
33
37
|
const globalSetup = [testConfig.globalSetup ?? []].flat().map(specifier => ({ ...toDeferResolve(specifier), dir }));
|
|
34
38
|
const workspaceDependencies = [];
|
|
35
39
|
if (testConfig.workspace !== undefined) {
|
|
@@ -50,6 +54,7 @@ const findConfigDependencies = (localConfig, options, vitestRoot) => {
|
|
|
50
54
|
...reporters.map(id => toDependency(id)),
|
|
51
55
|
...coverage.map(id => toDependency(id)),
|
|
52
56
|
...setupFiles,
|
|
57
|
+
...snapshotSerializers,
|
|
53
58
|
...globalSetup,
|
|
54
59
|
...workspaceDependencies,
|
|
55
60
|
...projectsDependencies,
|
|
@@ -110,6 +115,9 @@ export const resolveConfig = async (localConfig, options) => {
|
|
|
110
115
|
inputs.add(toConfig('vitest', projectFile, { containingFilePath: options.configFilePath }));
|
|
111
116
|
}
|
|
112
117
|
}
|
|
118
|
+
else if (typeof project.extends === 'string') {
|
|
119
|
+
inputs.add(toConfig('vitest', project.extends, { containingFilePath: options.configFilePath }));
|
|
120
|
+
}
|
|
113
121
|
}
|
|
114
122
|
}
|
|
115
123
|
}
|
|
@@ -153,6 +161,13 @@ export const resolveConfig = async (localConfig, options) => {
|
|
|
153
161
|
if (packageName)
|
|
154
162
|
inputs.add(toDependency(packageName, { optional: true }));
|
|
155
163
|
}
|
|
164
|
+
const ssrExternal = cfg.ssr?.external;
|
|
165
|
+
if (Array.isArray(ssrExternal)) {
|
|
166
|
+
for (const dependency of ssrExternal) {
|
|
167
|
+
if (typeof dependency === 'string')
|
|
168
|
+
inputs.add(toDependency(dependency, { optional: true }));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
156
171
|
if (cfg.resolve?.extensions) {
|
|
157
172
|
const customExtensions = cfg.resolve.extensions.filter(ext => ext.startsWith('.') && !DEFAULT_EXTENSIONS.has(ext));
|
|
158
173
|
for (const ext of customExtensions) {
|
|
@@ -21,6 +21,7 @@ interface VitestConfig {
|
|
|
21
21
|
globalSetup?: string | string[];
|
|
22
22
|
reporters?: (string | [string, unknown] | unknown)[];
|
|
23
23
|
setupFiles?: string | string[];
|
|
24
|
+
snapshotSerializers?: string[];
|
|
24
25
|
workspace?: (ViteConfig & {
|
|
25
26
|
test: VitestConfig['test'] & {
|
|
26
27
|
workspace: never;
|
|
@@ -35,6 +36,7 @@ interface VitestConfig {
|
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
38
|
export interface ViteConfig extends VitestConfig {
|
|
39
|
+
extends?: string | true;
|
|
38
40
|
root?: string;
|
|
39
41
|
plugins?: unknown[];
|
|
40
42
|
build?: {
|
|
@@ -47,6 +49,9 @@ export interface ViteConfig extends VitestConfig {
|
|
|
47
49
|
optimizeDeps?: {
|
|
48
50
|
include?: string[];
|
|
49
51
|
};
|
|
52
|
+
ssr?: {
|
|
53
|
+
external?: (string | RegExp)[] | true;
|
|
54
|
+
};
|
|
50
55
|
resolve?: {
|
|
51
56
|
alias?: AliasOptions;
|
|
52
57
|
dedupe?: string[];
|
package/dist/run.js
CHANGED
|
@@ -12,7 +12,7 @@ import { debugLogObject } from './util/debug.js';
|
|
|
12
12
|
import { flushGitignoreCache, initGitignoreCache } from './util/gitignore-cache.js';
|
|
13
13
|
import { flushGlobCache, initGlobCache } from './util/glob-cache.js';
|
|
14
14
|
import { getGitIgnoredHandler } from './util/glob-core.js';
|
|
15
|
-
import { getModuleSourcePathHandler,
|
|
15
|
+
import { getModuleSourcePathHandler, getWorkspacePackageTargetHandler } from './util/to-source-path.js';
|
|
16
16
|
import { getSessionHandler } from './util/watch.js';
|
|
17
17
|
export const run = async (options) => {
|
|
18
18
|
debugLogObject('*', 'Unresolved configuration', options);
|
|
@@ -30,8 +30,8 @@ export const run = async (options) => {
|
|
|
30
30
|
const workspaces = await chief.getWorkspaces();
|
|
31
31
|
const isGitIgnored = await getGitIgnoredHandler(options, new Set(workspaces.map(w => w.dir)));
|
|
32
32
|
const toSourceFilePath = getModuleSourcePathHandler(chief);
|
|
33
|
-
const
|
|
34
|
-
const principal = new ProjectPrincipal(options, toSourceFilePath,
|
|
33
|
+
const findWorkspacePackageTarget = getWorkspacePackageTargetHandler(chief);
|
|
34
|
+
const principal = new ProjectPrincipal(options, toSourceFilePath, findWorkspacePackageTarget);
|
|
35
35
|
collector.setWorkspaceFilter(chief.workspaceFilePathFilter);
|
|
36
36
|
collector.setSelectedWorkspaces(chief.selectedWorkspaces);
|
|
37
37
|
collector.setIgnoreIssues(chief.getIgnoreIssues());
|
|
@@ -701,6 +701,11 @@ export declare const workspaceConfigurationSchema: z.ZodMiniObject<{
|
|
|
701
701
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
702
702
|
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
703
703
|
}, z.core.$strip>]>>;
|
|
704
|
+
temporal: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
705
|
+
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
706
|
+
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
707
|
+
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
708
|
+
}, z.core.$strip>]>>;
|
|
704
709
|
travis: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
705
710
|
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
706
711
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
@@ -1597,6 +1602,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
|
|
|
1597
1602
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1598
1603
|
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1599
1604
|
}, z.core.$strip>]>>;
|
|
1605
|
+
temporal: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
1606
|
+
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1607
|
+
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1608
|
+
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1609
|
+
}, z.core.$strip>]>>;
|
|
1600
1610
|
travis: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
1601
1611
|
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
1602
1612
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
@@ -2511,6 +2521,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
|
|
|
2511
2521
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
2512
2522
|
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
2513
2523
|
}, z.core.$strip>]>>;
|
|
2524
|
+
temporal: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
2525
|
+
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
2526
|
+
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
2527
|
+
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
2528
|
+
}, z.core.$strip>]>>;
|
|
2514
2529
|
travis: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
2515
2530
|
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
2516
2531
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
package/dist/schema/plugins.d.ts
CHANGED
|
@@ -706,6 +706,11 @@ export declare const pluginsSchema: z.ZodMiniObject<{
|
|
|
706
706
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
707
707
|
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
708
708
|
}, z.core.$strip>]>;
|
|
709
|
+
temporal: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
710
|
+
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
711
|
+
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
712
|
+
project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
713
|
+
}, z.core.$strip>]>;
|
|
709
714
|
travis: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
|
|
710
715
|
config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
|
711
716
|
entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
|
package/dist/schema/plugins.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type PluginName = 'angular' | 'astro' | 'astro-db' | 'astro-markdoc' | 'astro-og-canvas' | 'ava' | 'babel' | 'biome' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'catalyst' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'electron-vite' | 'eleventy' | 'esbuild' | 'eslint' | 'eve' | 'execa' | 'expo' | 'expressive-code' | 'fast' | 'fumadocs' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jest' | 'karma' | 'knex' | 'ladle' | 'laravel-vite-plugin' | 'lefthook' | 'lint-staged' | 'linthtml' | 'lit' | 'lockfile-lint' | 'lost-pixel' | 'lunaria' | 'markdownlint' | 'mdx' | 'mdxlint' | 'metro' | 'mocha' | 'moonrepo' | 'msw' | 'nano-spawn' | 'nano-staged' | 'nest' | 'netlify' | 'next' | 'next-intl' | 'next-mdx' | 'nitro' | 'node' | 'node-modules-inspector' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nuxtjs-i18n' | 'nx' | 'nyc' | 'oclif' | 'openapi-ts' | 'orval' | 'oxfmt' | 'oxlint' | 'panda-css' | 'parcel' | 'payload' | 'pino' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pm2' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'quasar' | 'qwik' | 'raycast' | 'react-cosmos' | 'react-email' | 'react-native' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rolldown' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'sanity' | 'semantic-release' | 'sentry' | 'serverless-framework' | 'simple-git-hooks' | 'size-limit' | 'sst' | 'starlight' | 'stencil' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'sveltejs-package' | 'sveltekit' | 'svgo' | 'svgr' | 'swc' | 'syncpack' | 'tailwind' | 'tanstack-router' | 'taskfile' | 'tauri' | 'travis' | 'ts-node' | 'tsdown' | 'tsup' | 'tsx' | 'typedoc' | 'typescript' | 'unbuild' | 'unocss' | 'unplugin-auto-import' | 'unplugin-icons' | 'unplugin-vue-components' | 'unplugin-vue-i18n' | 'unplugin-vue-markdown' | 'unplugin-vue-router' | 'vercel' | 'vercel-og' | 'vike' | 'vite' | 'vite-plugin-pages' | 'vite-plugin-pwa' | 'vite-plugin-vue-layouts-next' | 'vite-plus' | 'vite-pwa-assets-generator' | 'vitepress' | 'vitest' | 'vue' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'wxt' | 'xo' | 'yarn' | 'yorkie' | 'zx';
|
|
2
|
-
export declare const pluginNames: readonly ['angular', 'astro', 'astro-db', 'astro-markdoc', 'astro-og-canvas', 'ava', 'babel', 'biome', 'bumpp', 'bun', 'c8', 'capacitor', 'catalyst', 'changelogen', 'changelogithub', 'changesets', 'commitizen', 'commitlint', 'convex', 'create-typescript-app', 'cspell', 'cucumber', 'cypress', 'danger', 'dependency-cruiser', 'docusaurus', 'dotenv', 'drizzle', 'electron-vite', 'eleventy', 'esbuild', 'eslint', 'eve', 'execa', 'expo', 'expressive-code', 'fast', 'fumadocs', 'gatsby', 'github-action', 'github-actions', 'glob', 'graphql-codegen', 'hardhat', 'husky', 'i18next-parser', 'jest', 'karma', 'knex', 'ladle', 'laravel-vite-plugin', 'lefthook', 'lint-staged', 'linthtml', 'lit', 'lockfile-lint', 'lost-pixel', 'lunaria', 'markdownlint', 'mdx', 'mdxlint', 'metro', 'mocha', 'moonrepo', 'msw', 'nano-spawn', 'nano-staged', 'nest', 'netlify', 'next', 'next-intl', 'next-mdx', 'nitro', 'node', 'node-modules-inspector', 'nodemon', 'npm-package-json-lint', 'nuxt', 'nuxtjs-i18n', 'nx', 'nyc', 'oclif', 'openapi-ts', 'orval', 'oxfmt', 'oxlint', 'panda-css', 'parcel', 'payload', 'pino', 'playwright', 'playwright-ct', 'playwright-test', 'plop', 'pm2', 'pnpm', 'postcss', 'preconstruct', 'prettier', 'prisma', 'quasar', 'qwik', 'raycast', 'react-cosmos', 'react-email', 'react-native', 'react-router', 'relay', 'release-it', 'remark', 'remix', 'rolldown', 'rollup', 'rsbuild', 'rslib', 'rspack', 'rstest', 'sanity', 'semantic-release', 'sentry', 'serverless-framework', 'simple-git-hooks', 'size-limit', 'sst', 'starlight', 'stencil', 'storybook', 'stryker', 'stylelint', 'svelte', 'sveltejs-package', 'sveltekit', 'svgo', 'svgr', 'swc', 'syncpack', 'tailwind', 'tanstack-router', 'taskfile', 'tauri', 'travis', 'ts-node', 'tsdown', 'tsup', 'tsx', 'typedoc', 'typescript', 'unbuild', 'unocss', 'unplugin-auto-import', 'unplugin-icons', 'unplugin-vue-components', 'unplugin-vue-i18n', 'unplugin-vue-markdown', 'unplugin-vue-router', 'vercel', 'vercel-og', 'vike', 'vite', 'vite-plugin-pages', 'vite-plugin-pwa', 'vite-plugin-vue-layouts-next', 'vite-plus', 'vite-pwa-assets-generator', 'vitepress', 'vitest', 'vue', 'webdriver-io', 'webpack', 'wireit', 'wrangler', 'wxt', 'xo', 'yarn', 'yorkie', 'zx'];
|
|
1
|
+
export type PluginName = 'angular' | 'astro' | 'astro-db' | 'astro-markdoc' | 'astro-og-canvas' | 'ava' | 'babel' | 'biome' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'catalyst' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'electron-vite' | 'eleventy' | 'esbuild' | 'eslint' | 'eve' | 'execa' | 'expo' | 'expressive-code' | 'fast' | 'fumadocs' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jest' | 'karma' | 'knex' | 'ladle' | 'laravel-vite-plugin' | 'lefthook' | 'lint-staged' | 'linthtml' | 'lit' | 'lockfile-lint' | 'lost-pixel' | 'lunaria' | 'markdownlint' | 'mdx' | 'mdxlint' | 'metro' | 'mocha' | 'moonrepo' | 'msw' | 'nano-spawn' | 'nano-staged' | 'nest' | 'netlify' | 'next' | 'next-intl' | 'next-mdx' | 'nitro' | 'node' | 'node-modules-inspector' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nuxtjs-i18n' | 'nx' | 'nyc' | 'oclif' | 'openapi-ts' | 'orval' | 'oxfmt' | 'oxlint' | 'panda-css' | 'parcel' | 'payload' | 'pino' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pm2' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'quasar' | 'qwik' | 'raycast' | 'react-cosmos' | 'react-email' | 'react-native' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rolldown' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'sanity' | 'semantic-release' | 'sentry' | 'serverless-framework' | 'simple-git-hooks' | 'size-limit' | 'sst' | 'starlight' | 'stencil' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'sveltejs-package' | 'sveltekit' | 'svgo' | 'svgr' | 'swc' | 'syncpack' | 'tailwind' | 'tanstack-router' | 'taskfile' | 'tauri' | 'temporal' | 'travis' | 'ts-node' | 'tsdown' | 'tsup' | 'tsx' | 'typedoc' | 'typescript' | 'unbuild' | 'unocss' | 'unplugin-auto-import' | 'unplugin-icons' | 'unplugin-vue-components' | 'unplugin-vue-i18n' | 'unplugin-vue-markdown' | 'unplugin-vue-router' | 'vercel' | 'vercel-og' | 'vike' | 'vite' | 'vite-plugin-pages' | 'vite-plugin-pwa' | 'vite-plugin-vue-layouts-next' | 'vite-plus' | 'vite-pwa-assets-generator' | 'vitepress' | 'vitest' | 'vue' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'wxt' | 'xo' | 'yarn' | 'yorkie' | 'zx';
|
|
2
|
+
export declare const pluginNames: readonly ['angular', 'astro', 'astro-db', 'astro-markdoc', 'astro-og-canvas', 'ava', 'babel', 'biome', 'bumpp', 'bun', 'c8', 'capacitor', 'catalyst', 'changelogen', 'changelogithub', 'changesets', 'commitizen', 'commitlint', 'convex', 'create-typescript-app', 'cspell', 'cucumber', 'cypress', 'danger', 'dependency-cruiser', 'docusaurus', 'dotenv', 'drizzle', 'electron-vite', 'eleventy', 'esbuild', 'eslint', 'eve', 'execa', 'expo', 'expressive-code', 'fast', 'fumadocs', 'gatsby', 'github-action', 'github-actions', 'glob', 'graphql-codegen', 'hardhat', 'husky', 'i18next-parser', 'jest', 'karma', 'knex', 'ladle', 'laravel-vite-plugin', 'lefthook', 'lint-staged', 'linthtml', 'lit', 'lockfile-lint', 'lost-pixel', 'lunaria', 'markdownlint', 'mdx', 'mdxlint', 'metro', 'mocha', 'moonrepo', 'msw', 'nano-spawn', 'nano-staged', 'nest', 'netlify', 'next', 'next-intl', 'next-mdx', 'nitro', 'node', 'node-modules-inspector', 'nodemon', 'npm-package-json-lint', 'nuxt', 'nuxtjs-i18n', 'nx', 'nyc', 'oclif', 'openapi-ts', 'orval', 'oxfmt', 'oxlint', 'panda-css', 'parcel', 'payload', 'pino', 'playwright', 'playwright-ct', 'playwright-test', 'plop', 'pm2', 'pnpm', 'postcss', 'preconstruct', 'prettier', 'prisma', 'quasar', 'qwik', 'raycast', 'react-cosmos', 'react-email', 'react-native', 'react-router', 'relay', 'release-it', 'remark', 'remix', 'rolldown', 'rollup', 'rsbuild', 'rslib', 'rspack', 'rstest', 'sanity', 'semantic-release', 'sentry', 'serverless-framework', 'simple-git-hooks', 'size-limit', 'sst', 'starlight', 'stencil', 'storybook', 'stryker', 'stylelint', 'svelte', 'sveltejs-package', 'sveltekit', 'svgo', 'svgr', 'swc', 'syncpack', 'tailwind', 'tanstack-router', 'taskfile', 'tauri', 'temporal', 'travis', 'ts-node', 'tsdown', 'tsup', 'tsx', 'typedoc', 'typescript', 'unbuild', 'unocss', 'unplugin-auto-import', 'unplugin-icons', 'unplugin-vue-components', 'unplugin-vue-i18n', 'unplugin-vue-markdown', 'unplugin-vue-router', 'vercel', 'vercel-og', 'vike', 'vite', 'vite-plugin-pages', 'vite-plugin-pwa', 'vite-plugin-vue-layouts-next', 'vite-plus', 'vite-pwa-assets-generator', 'vitepress', 'vitest', 'vue', 'webdriver-io', 'webpack', 'wireit', 'wrangler', 'wxt', 'xo', 'yarn', 'yorkie', 'zx'];
|
package/dist/types/config.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type { PackageJson } from './package-json.ts';
|
|
|
14
14
|
export interface GetInputsFromScriptsOptions extends BaseOptions {
|
|
15
15
|
knownBinsOnly?: boolean;
|
|
16
16
|
containingFilePath: string;
|
|
17
|
+
expandedScripts?: Set<string>;
|
|
17
18
|
}
|
|
18
19
|
export type GetInputsFromScripts<T = GetInputsFromScriptsOptions> = (npmScripts: string | string[] | Set<string>, options: T) => Input[];
|
|
19
20
|
export type GetInputsFromScriptsPartial = (npmScripts: string | string[] | Set<string>, options?: Partial<GetInputsFromScriptsOptions>) => Input[];
|
|
@@ -8,6 +8,7 @@ export type ResolveModule = (specifier: string, containingFile: string) => Resol
|
|
|
8
8
|
export interface ResolvedModule {
|
|
9
9
|
resolvedFileName: string;
|
|
10
10
|
isExternalLibraryImport: boolean;
|
|
11
|
+
packageName?: string;
|
|
11
12
|
}
|
|
12
13
|
export declare const buildLineStarts: (sourceText: string) => number[];
|
|
13
14
|
export declare const getLineAndCol: (lineStarts: number[], pos: number) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isBuiltin } from 'node:module';
|
|
2
2
|
import { IMPORT_FLAGS, IMPORT_STAR, OPAQUE, PROTOCOL_VIRTUAL, SIDE_EFFECTS } from '../constants.js';
|
|
3
3
|
import { addNsValue, addValue, createImports } from '../util/module-graph.js';
|
|
4
|
-
import { getPackageNameFromFilePath, isStartsLikePackageName, sanitizeSpecifier } from '../util/modules.js';
|
|
4
|
+
import { getPackageNameFromFilePath, getPackageNameFromModuleSpecifier, isStartsLikePackageName, sanitizeSpecifier, } from '../util/modules.js';
|
|
5
5
|
import { timerify } from '../util/Performance.js';
|
|
6
6
|
import { dirname, isInNodeModules, resolve } from '../util/path.js';
|
|
7
7
|
import { shouldIgnore } from '../util/tag.js';
|
|
@@ -125,9 +125,12 @@ const getImportsAndExports = (filePath, sourceText, resolveModule, options, igno
|
|
|
125
125
|
if (module.isExternalLibraryImport) {
|
|
126
126
|
if (options.skipTypeOnly && modifiers & IMPORT_FLAGS.TYPE_ONLY)
|
|
127
127
|
return;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
let sanitizedSpecifier = sanitizeSpecifier(isInNodeModules(specifier) ? getPackageNameFromFilePath(specifier) : specifier);
|
|
129
|
+
if (module.packageName &&
|
|
130
|
+
isStartsLikePackageName(module.packageName) &&
|
|
131
|
+
getPackageNameFromModuleSpecifier(sanitizedSpecifier) !== module.packageName) {
|
|
132
|
+
sanitizedSpecifier = module.packageName;
|
|
133
|
+
}
|
|
131
134
|
if (!isStartsLikePackageName(sanitizedSpecifier))
|
|
132
135
|
return;
|
|
133
136
|
const ePos = specifierPos ?? pos;
|
|
@@ -277,7 +280,7 @@ const getImportsAndExports = (filePath, sourceText, resolveModule, options, igno
|
|
|
277
280
|
pluginCtx.addImportGlob = (patterns, opts) => importGlobs.push({ patterns, base: opts?.base, filter: opts?.filter });
|
|
278
281
|
pluginCtx.markExportRegistered = (name) => registeredCustomElements.add(name);
|
|
279
282
|
}
|
|
280
|
-
const localRefs = _walkAST(result.program, sourceText, filePath, {
|
|
283
|
+
const localRefs = _walkAST(result.program, sourceText, filePath, result.module.hasModuleSyntax, {
|
|
281
284
|
lineStarts,
|
|
282
285
|
skipExports,
|
|
283
286
|
options,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ToSourceFilePath,
|
|
1
|
+
import type { ToSourceFilePath, WorkspacePackageTargetHandler } from '../util/to-source-path.ts';
|
|
2
2
|
import type { ResolveModule } from './ast-nodes.ts';
|
|
3
3
|
type ScopedPaths = Array<{
|
|
4
4
|
scope: string;
|
|
@@ -14,5 +14,5 @@ export declare function createGlobAliasResolver(scopedPaths: ScopedPaths | undef
|
|
|
14
14
|
export declare function createCustomModuleResolver(compilerOptions: {
|
|
15
15
|
scopedPaths?: ScopedPaths;
|
|
16
16
|
scopedRootDirs?: ScopedRootDirs;
|
|
17
|
-
}, customCompilerExtensions: string[], toSourceFilePath: ToSourceFilePath,
|
|
17
|
+
}, customCompilerExtensions: string[], toSourceFilePath: ToSourceFilePath, findWorkspacePackageTarget?: WorkspacePackageTargetHandler, tsConfigFile?: string): ResolveModule;
|
|
18
18
|
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
1
|
+
import { existsSync, realpathSync } from 'node:fs';
|
|
2
2
|
import { isBuiltin } from 'node:module';
|
|
3
|
-
import { DEFAULT_EXTENSIONS, DTS_EXTENSIONS } from '../constants.js';
|
|
4
|
-
import {
|
|
3
|
+
import { DEFAULT_EXTENSIONS, DTS_EXTENSIONS, IS_DTS } from '../constants.js';
|
|
4
|
+
import { isFile } from '../util/fs.js';
|
|
5
|
+
import { getPackageNameFromFilePath, getPackageNameFromModuleSpecifier, sanitizeSpecifier } from '../util/modules.js';
|
|
5
6
|
import { timerify } from '../util/Performance.js';
|
|
6
7
|
import { dirname, extname, isAbsolute, isInNodeModules, join, toPosix } from '../util/path.js';
|
|
7
8
|
import { _createSyncModuleResolver, _resolveModuleSync } from '../util/resolve.js';
|
|
@@ -22,10 +23,81 @@ function pickStringTarget(value) {
|
|
|
22
23
|
return s;
|
|
23
24
|
}
|
|
24
25
|
}
|
|
26
|
+
const invalidSegments = /(^|\\|\/)((\.|%2e)(\.|%2e)?|node_modules)(\\|\/|$)/i;
|
|
27
|
+
const expandPackageTarget = (target, patternMatch) => {
|
|
28
|
+
if (!target?.startsWith('./') || invalidSegments.test(target.slice(2)))
|
|
29
|
+
return;
|
|
30
|
+
if (!target.includes('*'))
|
|
31
|
+
return target;
|
|
32
|
+
if (patternMatch === undefined || invalidSegments.test(patternMatch))
|
|
33
|
+
return;
|
|
34
|
+
return target.replaceAll('*', patternMatch);
|
|
35
|
+
};
|
|
36
|
+
const toPackagePath = (dir, target) => {
|
|
37
|
+
const candidate = join(dir, target);
|
|
38
|
+
return candidate.startsWith(`${dir}/`) ? candidate : undefined;
|
|
39
|
+
};
|
|
40
|
+
function pickExistingPackageTarget(value, dir, patternMatch, moduleExtensions) {
|
|
41
|
+
if (typeof value === 'string') {
|
|
42
|
+
const target = expandPackageTarget(value, patternMatch);
|
|
43
|
+
if (!target || IS_DTS.test(target) || !moduleExtensions.has(extname(target)))
|
|
44
|
+
return;
|
|
45
|
+
const candidate = toPackagePath(dir, target);
|
|
46
|
+
return candidate && isFile(candidate) ? candidate : undefined;
|
|
47
|
+
}
|
|
48
|
+
if (!value || typeof value !== 'object')
|
|
49
|
+
return;
|
|
50
|
+
if (Array.isArray(value)) {
|
|
51
|
+
for (const item of value) {
|
|
52
|
+
const target = pickExistingPackageTarget(item, dir, patternMatch, moduleExtensions);
|
|
53
|
+
if (target)
|
|
54
|
+
return target;
|
|
55
|
+
}
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
for (const [condition, child] of Object.entries(value)) {
|
|
59
|
+
if (condition === 'types')
|
|
60
|
+
continue;
|
|
61
|
+
const target = pickExistingPackageTarget(child, dir, patternMatch, moduleExtensions);
|
|
62
|
+
if (target)
|
|
63
|
+
return target;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
25
66
|
const moduleResolutionCaches = [];
|
|
67
|
+
const installedPackageRootCache = new Map();
|
|
26
68
|
export function clearModuleResolutionCaches() {
|
|
27
69
|
for (const cache of moduleResolutionCaches)
|
|
28
70
|
cache.clear();
|
|
71
|
+
installedPackageRootCache.clear();
|
|
72
|
+
}
|
|
73
|
+
function getInstalledPackageRoot(candidate) {
|
|
74
|
+
if (installedPackageRootCache.has(candidate))
|
|
75
|
+
return installedPackageRootCache.get(candidate);
|
|
76
|
+
let packageRoot;
|
|
77
|
+
try {
|
|
78
|
+
packageRoot = toPosix(realpathSync(candidate));
|
|
79
|
+
}
|
|
80
|
+
catch { }
|
|
81
|
+
installedPackageRootCache.set(candidate, packageRoot);
|
|
82
|
+
return packageRoot;
|
|
83
|
+
}
|
|
84
|
+
function getAttributedPackageName(specifier, containingFile, resolvedFileName) {
|
|
85
|
+
const packageName = getPackageNameFromFilePath(resolvedFileName);
|
|
86
|
+
const specifierPackageName = getPackageNameFromModuleSpecifier(specifier);
|
|
87
|
+
if (!specifierPackageName || specifierPackageName === packageName)
|
|
88
|
+
return packageName;
|
|
89
|
+
let dir = dirname(containingFile);
|
|
90
|
+
while (true) {
|
|
91
|
+
const packageRoot = getInstalledPackageRoot(join(dir, 'node_modules', specifierPackageName));
|
|
92
|
+
if (packageRoot) {
|
|
93
|
+
const isResolvedInstall = resolvedFileName === packageRoot || resolvedFileName.startsWith(`${packageRoot}/`);
|
|
94
|
+
return isResolvedInstall ? specifierPackageName : packageName;
|
|
95
|
+
}
|
|
96
|
+
const parent = dirname(dir);
|
|
97
|
+
if (parent === dir)
|
|
98
|
+
return packageName;
|
|
99
|
+
dir = parent;
|
|
100
|
+
}
|
|
29
101
|
}
|
|
30
102
|
function compilePathMappings(scopedPaths) {
|
|
31
103
|
if (!scopedPaths)
|
|
@@ -90,8 +162,9 @@ export function createGlobAliasResolver(scopedPaths) {
|
|
|
90
162
|
return resolved;
|
|
91
163
|
};
|
|
92
164
|
}
|
|
93
|
-
export function createCustomModuleResolver(compilerOptions, customCompilerExtensions, toSourceFilePath,
|
|
165
|
+
export function createCustomModuleResolver(compilerOptions, customCompilerExtensions, toSourceFilePath, findWorkspacePackageTarget, tsConfigFile) {
|
|
94
166
|
const customCompilerExtensionsSet = new Set(customCompilerExtensions);
|
|
167
|
+
const moduleExtensions = new Set([...DEFAULT_EXTENSIONS, ...customCompilerExtensions, '.json', '.jsonc']);
|
|
95
168
|
const hasCustomExts = customCompilerExtensionsSet.size > 0;
|
|
96
169
|
const extensions = [...DEFAULT_EXTENSIONS, ...customCompilerExtensions, ...DTS_EXTENSIONS, '.json', '.jsonc'];
|
|
97
170
|
const resolveSync = hasCustomExts || tsConfigFile ? _createSyncModuleResolver(extensions, tsConfigFile) : _resolveModuleSync;
|
|
@@ -103,11 +176,15 @@ export function createCustomModuleResolver(compilerOptions, customCompilerExtens
|
|
|
103
176
|
}
|
|
104
177
|
return resolvedFileName;
|
|
105
178
|
}
|
|
106
|
-
function toResult(resolvedFileName) {
|
|
179
|
+
function toResult(specifier, containingFile, resolvedFileName) {
|
|
107
180
|
const mapped = toSourcePath(resolvedFileName);
|
|
181
|
+
const isExternalLibraryImport = mapped === resolvedFileName && isInNodeModules(resolvedFileName);
|
|
108
182
|
return {
|
|
109
183
|
resolvedFileName: mapped,
|
|
110
|
-
isExternalLibraryImport
|
|
184
|
+
isExternalLibraryImport,
|
|
185
|
+
packageName: isExternalLibraryImport
|
|
186
|
+
? getAttributedPackageName(specifier, containingFile, resolvedFileName)
|
|
187
|
+
: undefined,
|
|
111
188
|
};
|
|
112
189
|
}
|
|
113
190
|
const cache = new Map();
|
|
@@ -133,7 +210,7 @@ export function createCustomModuleResolver(compilerOptions, customCompilerExtens
|
|
|
133
210
|
return undefined;
|
|
134
211
|
const resolvedFileName = resolveSync(specifier, containingFile);
|
|
135
212
|
if (resolvedFileName)
|
|
136
|
-
return toResult(resolvedFileName);
|
|
213
|
+
return toResult(specifier, containingFile, resolvedFileName);
|
|
137
214
|
if (pathMappings) {
|
|
138
215
|
const dir = dirname(containingFile);
|
|
139
216
|
for (const { prefix, wildcard, values, scope } of pathMappings) {
|
|
@@ -146,7 +223,7 @@ export function createCustomModuleResolver(compilerOptions, customCompilerExtens
|
|
|
146
223
|
const mapped = starIdx >= 0 ? value.slice(0, starIdx) + captured + value.slice(starIdx + 1) : value;
|
|
147
224
|
const resolved = resolveSync(mapped, containingFile);
|
|
148
225
|
if (resolved)
|
|
149
|
-
return toResult(resolved);
|
|
226
|
+
return toResult(specifier, containingFile, resolved);
|
|
150
227
|
}
|
|
151
228
|
}
|
|
152
229
|
}
|
|
@@ -165,21 +242,23 @@ export function createCustomModuleResolver(compilerOptions, customCompilerExtens
|
|
|
165
242
|
continue;
|
|
166
243
|
const resolved = resolveSync(join(targetRoot, relPath, specifier), containingFile);
|
|
167
244
|
if (resolved)
|
|
168
|
-
return toResult(resolved);
|
|
245
|
+
return toResult(specifier, containingFile, resolved);
|
|
169
246
|
}
|
|
170
247
|
}
|
|
171
248
|
}
|
|
172
249
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
250
|
+
const workspaceTarget = findWorkspacePackageTarget?.(specifier, containingFile);
|
|
251
|
+
if (workspaceTarget) {
|
|
252
|
+
const target = expandPackageTarget(pickStringTarget(workspaceTarget.target), workspaceTarget.patternMatch);
|
|
253
|
+
if (target) {
|
|
254
|
+
const targetPath = toPackagePath(workspaceTarget.dir, target);
|
|
255
|
+
const sourcePath = targetPath && toSourceFilePath(targetPath);
|
|
256
|
+
if (sourcePath)
|
|
257
|
+
return toResult(specifier, containingFile, sourcePath);
|
|
182
258
|
}
|
|
259
|
+
const existingTarget = pickExistingPackageTarget(workspaceTarget.target, workspaceTarget.dir, workspaceTarget.patternMatch, moduleExtensions);
|
|
260
|
+
if (existingTarget)
|
|
261
|
+
return toResult(specifier, containingFile, existingTarget);
|
|
183
262
|
}
|
|
184
263
|
const candidate = isAbsolute(specifier) ? specifier : join(dirname(containingFile), specifier);
|
|
185
264
|
if (existsSync(candidate)) {
|
|
@@ -50,6 +50,7 @@ export interface WalkState extends WalkContext {
|
|
|
50
50
|
filePath: string;
|
|
51
51
|
sourceText: string;
|
|
52
52
|
isJS: boolean;
|
|
53
|
+
isModuleFile: boolean;
|
|
53
54
|
handledImportExpressions: Set<number>;
|
|
54
55
|
bareExprRefs: Set<string>;
|
|
55
56
|
accessedAliases: Set<string>;
|
|
@@ -88,6 +89,6 @@ export interface WalkState extends WalkContext {
|
|
|
88
89
|
}
|
|
89
90
|
export declare const isShadowed: (name: string, pos: number) => boolean;
|
|
90
91
|
export declare function buildVisitor(pluginVisitorObjects: PluginVisitorObject[], includeLocalRefs?: boolean): Visitor;
|
|
91
|
-
declare function walkAST(program: Program, sourceText: string, filePath: string, ctx: WalkContext): Set<string> | undefined;
|
|
92
|
+
declare function walkAST(program: Program, sourceText: string, filePath: string, hasModuleSyntax: boolean, ctx: WalkContext): Set<string> | undefined;
|
|
92
93
|
export declare const _walkAST: typeof walkAST;
|
|
93
94
|
export {};
|
|
@@ -211,7 +211,7 @@ const coreVisitorObject = {
|
|
|
211
211
|
},
|
|
212
212
|
TSModuleDeclaration(node) {
|
|
213
213
|
state.nsRanges.push([node.start, node.end]);
|
|
214
|
-
if (node.kind !== 'global' && isStringLiteral(node.id)) {
|
|
214
|
+
if (node.kind !== 'global' && state.isModuleFile && isStringLiteral(node.id)) {
|
|
215
215
|
const specifier = getStringValue(node.id);
|
|
216
216
|
for (const name of collectAugmentationRefs(node))
|
|
217
217
|
state.addImport(specifier, name, undefined, undefined, node.id.start, IMPORT_FLAGS.TYPE_ONLY | IMPORT_FLAGS.AUGMENT);
|
|
@@ -704,13 +704,24 @@ export function buildVisitor(pluginVisitorObjects, includeLocalRefs) {
|
|
|
704
704
|
}
|
|
705
705
|
return new Visitor(merged);
|
|
706
706
|
}
|
|
707
|
-
|
|
707
|
+
const isExternalModule = (program, hasModuleSyntax) => {
|
|
708
|
+
if (hasModuleSyntax)
|
|
709
|
+
return true;
|
|
710
|
+
for (const node of program.body) {
|
|
711
|
+
if (node.type === 'TSImportEqualsDeclaration' && node.moduleReference.type === 'TSExternalModuleReference') {
|
|
712
|
+
return true;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
return false;
|
|
716
|
+
};
|
|
717
|
+
function walkAST(program, sourceText, filePath, hasModuleSyntax, ctx) {
|
|
708
718
|
const isJS = filePath.endsWith('.js') || filePath.endsWith('.mjs') || filePath.endsWith('.cjs') || filePath.endsWith('.jsx');
|
|
709
719
|
state = {
|
|
710
720
|
...ctx,
|
|
711
721
|
filePath,
|
|
712
722
|
sourceText,
|
|
713
723
|
isJS,
|
|
724
|
+
isModuleFile: isExternalModule(program, hasModuleSyntax),
|
|
714
725
|
handledImportExpressions: new Set(),
|
|
715
726
|
bareExprRefs: new Set(),
|
|
716
727
|
accessedAliases: new Set(),
|
|
@@ -55,7 +55,14 @@ export const createInputHandler = (deputy, chief, isGitIgnored, addIssue, extern
|
|
|
55
55
|
const isWorkspace = chief.workspacesByPkgName.has(packageName);
|
|
56
56
|
const inputWorkspace = getWorkspaceFor(input, chief, workspace);
|
|
57
57
|
if (inputWorkspace) {
|
|
58
|
-
|
|
58
|
+
let isHandled = deputy.maybeAddReferencedExternalDependency(inputWorkspace, packageName, isConfig(input), input.isTypeOnly);
|
|
59
|
+
if (input.isTypeOnly && input.containingFilePath) {
|
|
60
|
+
const owningWorkspace = chief.findWorkspaceByFilePath(input.containingFilePath);
|
|
61
|
+
if (owningWorkspace && owningWorkspace !== inputWorkspace) {
|
|
62
|
+
const isOwnerHandled = deputy.maybeAddReferencedExternalDependency(owningWorkspace, packageName, isConfig(input), input.isTypeOnly);
|
|
63
|
+
isHandled = isHandled || isOwnerHandled;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
59
66
|
if (externalRefs && !isWorkspace) {
|
|
60
67
|
addExternalRef(externalRefs, containingFilePath, { specifier: packageName, identifier: undefined });
|
|
61
68
|
}
|
|
@@ -745,6 +745,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
745
745
|
entry?: string | string[] | undefined;
|
|
746
746
|
project?: string | string[] | undefined;
|
|
747
747
|
} | undefined;
|
|
748
|
+
temporal?: string | boolean | string[] | {
|
|
749
|
+
config?: string | string[] | undefined;
|
|
750
|
+
entry?: string | string[] | undefined;
|
|
751
|
+
project?: string | string[] | undefined;
|
|
752
|
+
} | undefined;
|
|
748
753
|
travis?: string | boolean | string[] | {
|
|
749
754
|
config?: string | string[] | undefined;
|
|
750
755
|
entry?: string | string[] | undefined;
|
|
@@ -1653,6 +1658,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
1653
1658
|
entry?: string | string[] | undefined;
|
|
1654
1659
|
project?: string | string[] | undefined;
|
|
1655
1660
|
} | undefined;
|
|
1661
|
+
temporal?: string | boolean | string[] | {
|
|
1662
|
+
config?: string | string[] | undefined;
|
|
1663
|
+
entry?: string | string[] | undefined;
|
|
1664
|
+
project?: string | string[] | undefined;
|
|
1665
|
+
} | undefined;
|
|
1656
1666
|
travis?: string | boolean | string[] | {
|
|
1657
1667
|
config?: string | string[] | undefined;
|
|
1658
1668
|
entry?: string | string[] | undefined;
|
|
@@ -5,6 +5,13 @@ interface ExtendedPackageJson extends PackageJson {
|
|
|
5
5
|
[INDENT]?: string;
|
|
6
6
|
[NEWLINE]?: string;
|
|
7
7
|
}
|
|
8
|
+
export declare const getPackageMapTarget: (map: unknown, key: string) => {
|
|
9
|
+
target: any;
|
|
10
|
+
patternMatch?: undefined;
|
|
11
|
+
} | {
|
|
12
|
+
target: unknown;
|
|
13
|
+
patternMatch: string;
|
|
14
|
+
} | undefined;
|
|
8
15
|
export declare const load: (filePath: string) => Promise<ExtendedPackageJson>;
|
|
9
16
|
export declare const save: (filePath: string, content: ExtendedPackageJson) => Promise<void>;
|
|
10
17
|
export declare const getEntrySpecifiersFromManifest: (manifest: PackageJson) => Set<string>;
|