knip 6.43.0 → 6.44.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -4
- package/dist/CacheConsultant.d.ts +1 -0
- package/dist/CacheConsultant.js +2 -0
- package/dist/CatalogCounselor.d.ts +1 -3
- package/dist/CatalogCounselor.js +18 -15
- package/dist/ConfigurationChief.d.ts +24 -0
- package/dist/DependencyDeputy.d.ts +2 -1
- package/dist/DependencyDeputy.js +11 -6
- package/dist/IssueCollector.js +1 -0
- package/dist/ProjectPrincipal.d.ts +4 -2
- package/dist/ProjectPrincipal.js +32 -10
- package/dist/WorkspaceWorker.d.ts +5 -2
- package/dist/WorkspaceWorker.js +20 -7
- package/dist/binaries/resolvers/bun.js +7 -2
- package/dist/binaries/util.js +2 -1
- package/dist/cli.js +6 -1
- package/dist/compilers/index.d.ts +5 -0
- package/dist/compilers/index.js +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +2 -0
- package/dist/graph/analyze.js +3 -2
- package/dist/graph/build.d.ts +2 -0
- package/dist/graph/build.js +37 -22
- package/dist/graph-explorer/cache.d.ts +2 -1
- package/dist/graph-explorer/cache.js +5 -1
- package/dist/graph-explorer/explorer.d.ts +3 -5
- package/dist/graph-explorer/explorer.js +24 -3
- package/dist/plugins/babel/index.js +6 -1
- package/dist/plugins/biome/index.js +1 -1
- package/dist/plugins/cspell/index.js +10 -2
- package/dist/plugins/dependency-cruiser/index.js +2 -2
- package/dist/plugins/docusaurus/helpers.js +4 -4
- package/dist/plugins/electron-vite/index.js +2 -2
- package/dist/plugins/eleventy/index.js +2 -2
- package/dist/plugins/expressive-code/index.d.ts +1 -1
- package/dist/plugins/expressive-code/index.js +2 -2
- package/dist/plugins/gatsby/index.js +6 -6
- package/dist/plugins/gatsby/types.d.ts +1 -1
- package/dist/plugins/github-actions/index.js +1 -1
- package/dist/plugins/i18next-parser/index.js +2 -2
- package/dist/plugins/index.d.ts +5 -1
- package/dist/plugins/index.js +8 -0
- package/dist/plugins/jasmine/index.js +2 -2
- package/dist/plugins/karma/index.js +4 -4
- package/dist/plugins/kysely-codegen/index.d.ts +3 -0
- package/dist/plugins/kysely-codegen/index.js +20 -0
- package/dist/plugins/lefthook/index.js +2 -2
- package/dist/plugins/lingui/index.d.ts +3 -0
- package/dist/plugins/lingui/index.js +16 -0
- package/dist/plugins/lockfile-lint/index.js +2 -2
- package/dist/plugins/lost-pixel/index.js +2 -2
- package/dist/plugins/lunaria/index.js +2 -2
- package/dist/plugins/marko/index.js +5 -6
- package/dist/plugins/mastra/index.d.ts +3 -0
- package/dist/plugins/mastra/index.js +57 -0
- package/dist/plugins/mcp/index.js +1 -1
- package/dist/plugins/mise/index.js +0 -3
- package/dist/plugins/mocha/index.js +43 -4
- package/dist/plugins/mocha/types.d.ts +1 -0
- package/dist/plugins/npm-package-json-lint/index.js +1 -1
- package/dist/plugins/npm-package-json-lint/types.d.ts +1 -1
- package/dist/plugins/nx/index.js +3 -8
- package/dist/plugins/nyc/index.js +1 -1
- package/dist/plugins/openapi-ts/index.js +2 -2
- package/dist/plugins/oxfmt/index.js +2 -2
- package/dist/plugins/playwright/index.js +6 -11
- package/dist/plugins/pnpm/index.js +2 -4
- package/dist/plugins/purgecss/index.d.ts +3 -0
- package/dist/plugins/purgecss/index.js +16 -0
- package/dist/plugins/railway/index.js +1 -4
- package/dist/plugins/relay/index.js +1 -1
- package/dist/plugins/release-it/index.js +1 -1
- package/dist/plugins/remix/index.js +1 -1
- package/dist/plugins/rsbuild/index.js +29 -1
- package/dist/plugins/rsbuild/types.d.ts +8 -0
- package/dist/plugins/rstest/index.js +2 -2
- package/dist/plugins/serverless-framework/index.js +1 -1
- package/dist/plugins/storybook/index.js +5 -5
- package/dist/plugins/sveltekit/resolveFromAST.js +1 -1
- package/dist/plugins/svgr/index.js +2 -1
- package/dist/plugins/swc/index.js +8 -3
- package/dist/plugins/syncpack/index.js +2 -2
- package/dist/plugins/tanstack-router/index.js +3 -2
- package/dist/plugins/taskfile/index.js +4 -7
- package/dist/plugins/textlint/helpers.js +2 -2
- package/dist/plugins/typescript/index.js +7 -3
- package/dist/plugins/unocss/index.js +2 -2
- package/dist/plugins/vite-plugin-pwa/index.js +1 -4
- package/dist/plugins/vite-plugin-pwa/resolveFromAST.d.ts +0 -2
- package/dist/plugins/vite-plugin-pwa/resolveFromAST.js +2 -2
- package/dist/plugins/vite-pwa-assets-generator/index.js +2 -2
- package/dist/plugins/vitest/helpers.js +4 -7
- package/dist/plugins/vitest/index.js +1 -1
- package/dist/plugins/webpack/index.d.ts +2 -0
- package/dist/plugins/webpack/index.js +11 -6
- package/dist/plugins/yarn/index.js +2 -4
- package/dist/reporters/codeclimate.d.ts +2 -2
- package/dist/reporters/codeclimate.js +2 -4
- package/dist/reporters/codeowners.d.ts +2 -2
- package/dist/reporters/codeowners.js +9 -9
- package/dist/reporters/compact.d.ts +2 -2
- package/dist/reporters/compact.js +8 -7
- package/dist/reporters/cycles.d.ts +2 -2
- package/dist/reporters/cycles.js +7 -6
- package/dist/reporters/disclosure.d.ts +2 -2
- package/dist/reporters/disclosure.js +6 -4
- package/dist/reporters/github-actions.d.ts +2 -2
- package/dist/reporters/github-actions.js +7 -5
- package/dist/reporters/index.d.ts +10 -10
- package/dist/reporters/json.d.ts +2 -2
- package/dist/reporters/json.js +2 -4
- package/dist/reporters/markdown.d.ts +2 -2
- package/dist/reporters/markdown.js +11 -9
- package/dist/reporters/sarif.d.ts +2 -2
- package/dist/reporters/sarif.js +2 -3
- package/dist/reporters/symbols.d.ts +2 -2
- package/dist/reporters/symbols.js +6 -4
- package/dist/run.d.ts +1 -1
- package/dist/run.js +3 -10
- package/dist/schema/configuration.d.ts +60 -0
- package/dist/schema/plugins.d.ts +20 -0
- package/dist/schema/plugins.js +4 -0
- package/dist/session/configuration.d.ts +15 -0
- package/dist/session/configuration.js +62 -0
- package/dist/session/incremental.d.ts +54 -0
- package/dist/session/incremental.js +49 -0
- package/dist/session/session.d.ts +1 -1
- package/dist/session/session.js +63 -27
- package/dist/session/watch.d.ts +2 -0
- package/dist/session/watch.js +41 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +4 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/issues.d.ts +4 -0
- package/dist/types/package-json.d.ts +0 -3
- package/dist/typescript/get-imports-and-exports.js +2 -0
- package/dist/typescript/visitors/calls.js +15 -11
- package/dist/typescript/visitors/imports.d.ts +3 -1
- package/dist/typescript/visitors/imports.js +77 -53
- package/dist/typescript/visitors/members.js +23 -26
- package/dist/typescript/visitors/walk.d.ts +3 -0
- package/dist/typescript/visitors/walk.js +43 -2
- package/dist/util/cli-arguments.d.ts +2 -1
- package/dist/util/cli-arguments.js +3 -0
- package/dist/util/create-input-handler.js +1 -1
- package/dist/util/create-options.d.ts +43 -2
- package/dist/util/create-options.js +17 -4
- package/dist/util/file-entry-cache.d.ts +2 -0
- package/dist/util/file-entry-cache.js +19 -1
- package/dist/util/gitignore-cache.d.ts +1 -0
- package/dist/util/gitignore-cache.js +1 -0
- package/dist/util/glob-core.js +4 -2
- package/dist/util/glob.d.ts +1 -0
- package/dist/util/glob.js +6 -0
- package/dist/util/input.d.ts +2 -0
- package/dist/util/loader.d.ts +1 -0
- package/dist/util/loader.js +29 -1
- package/dist/util/modules.js +5 -2
- package/dist/util/path.d.ts +1 -0
- package/dist/util/path.js +1 -0
- package/dist/util/reporter.d.ts +1 -1
- package/dist/util/reporter.js +53 -9
- package/dist/util/watch.d.ts +5 -11
- package/dist/util/watch.js +84 -68
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schema.json +16 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
2
|
+
export const isIncrementalFile = (file) => file.scripts.size === 0 &&
|
|
3
|
+
file.importGlobs.length === 0 &&
|
|
4
|
+
file.imports.programFiles.size === 0 &&
|
|
5
|
+
file.imports.entryFiles.size === 0;
|
|
6
|
+
export const getFileTopology = (file) => {
|
|
7
|
+
const exports = [];
|
|
8
|
+
for (const [identifier, item] of file.exports) {
|
|
9
|
+
const members = [];
|
|
10
|
+
for (const member of item.members) {
|
|
11
|
+
members.push({
|
|
12
|
+
identifier: member.identifier,
|
|
13
|
+
type: member.type,
|
|
14
|
+
flags: member.flags,
|
|
15
|
+
jsDocTags: member.jsDocTags,
|
|
16
|
+
hasRefsInFile: member.hasRefsInFile,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
exports.push({
|
|
20
|
+
identifier,
|
|
21
|
+
binding: item.binding,
|
|
22
|
+
type: item.type,
|
|
23
|
+
jsDocTags: item.jsDocTags,
|
|
24
|
+
hasRefsInFile: item.hasRefsInFile,
|
|
25
|
+
isRegistered: item.isRegistered,
|
|
26
|
+
referencedIn: item.referencedIn,
|
|
27
|
+
isReExport: item.isReExport,
|
|
28
|
+
isBindingReExport: item.isBindingReExport,
|
|
29
|
+
members,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const facts = (items) => {
|
|
33
|
+
const result = [];
|
|
34
|
+
for (const { specifier, filePath, identifier, alias, isTypeOnly, modifiers, jsDocTags } of items)
|
|
35
|
+
result.push({ specifier, filePath, identifier, alias, isTypeOnly, modifiers, jsDocTags });
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
internal: file.imports.internal,
|
|
40
|
+
paths: [...file.imports.internal.keys()],
|
|
41
|
+
imports: facts(file.imports.imports),
|
|
42
|
+
external: facts(file.imports.external),
|
|
43
|
+
unresolved: facts(file.imports.unresolved),
|
|
44
|
+
externalRefs: file.imports.externalRefs,
|
|
45
|
+
exports,
|
|
46
|
+
skipExports: file.skipExports,
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export const hasSameTopology = (before, after) => isIncrementalFile(after) && isDeepStrictEqual(before, getFileTopology(after));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CollectorIssues } from '../IssueCollector.ts';
|
|
2
2
|
import { type Results } from '../run.ts';
|
|
3
|
-
import type
|
|
3
|
+
import { type MainOptions } from '../util/create-options.ts';
|
|
4
4
|
import type { WatchChange } from '../util/watch.ts';
|
|
5
5
|
import { type FileDescriptorOptions } from './file-descriptor.ts';
|
|
6
6
|
import { type PackageJsonFile } from './package-json-descriptor.ts';
|
package/dist/session/session.js
CHANGED
|
@@ -1,36 +1,72 @@
|
|
|
1
1
|
import { run } from '../run.js';
|
|
2
|
+
import { createOptions } from '../util/create-options.js';
|
|
2
3
|
import { createPreprocessor, toReporterOptions } from '../util/preprocessor.js';
|
|
4
|
+
import { clearResolverCache } from '../util/resolve.js';
|
|
5
|
+
import { clearModuleResolutionCaches } from '../typescript/resolve-module-names.js';
|
|
6
|
+
import { clearGlobCache } from '../util/glob-cache.js';
|
|
7
|
+
import { clearGitignoreCache } from '../util/gitignore-cache.js';
|
|
8
|
+
import { unload } from '../util/loader.js';
|
|
3
9
|
import { buildFileDescriptor } from './file-descriptor.js';
|
|
4
10
|
import { buildPackageJsonDescriptor } from './package-json-descriptor.js';
|
|
11
|
+
import { SessionConfigurationChangedError } from './configuration.js';
|
|
5
12
|
export const createSession = async (options) => {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const initialize = async (options) => {
|
|
14
|
+
const { session, results } = await run(options);
|
|
15
|
+
if (!session)
|
|
16
|
+
throw new Error('Unable to initialize watch session');
|
|
17
|
+
const preprocess = options.preprocessor.length > 0 ? await createPreprocessor(options.preprocessor) : undefined;
|
|
18
|
+
const updateResults = async () => {
|
|
19
|
+
const collected = session.getIssues();
|
|
20
|
+
const data = preprocess
|
|
21
|
+
? await preprocess({ ...toReporterOptions(options, results), ...structuredClone(collected) })
|
|
22
|
+
: collected;
|
|
23
|
+
results.issues = data.issues;
|
|
24
|
+
results.counters = data.counters;
|
|
25
|
+
results.tagHints = data.tagHints;
|
|
26
|
+
results.configurationHints = data.configurationHints;
|
|
27
|
+
results.hasConfigLoadErrors = collected.hasConfigLoadErrors;
|
|
28
|
+
};
|
|
29
|
+
await updateResults();
|
|
30
|
+
return { session, results, options, updateResults, preprocess };
|
|
15
31
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
let current = await initialize(options);
|
|
33
|
+
const results = current.results;
|
|
34
|
+
let pending = Promise.resolve();
|
|
35
|
+
const processChanges = async (changes) => {
|
|
36
|
+
try {
|
|
37
|
+
const update = await current.session.handleFileChanges(changes);
|
|
38
|
+
if (update) {
|
|
39
|
+
await current.updateResults();
|
|
40
|
+
Object.assign(results, current.results);
|
|
41
|
+
}
|
|
42
|
+
return update;
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
if (!(error instanceof SessionConfigurationChangedError))
|
|
46
|
+
throw error;
|
|
47
|
+
const startTime = performance.now();
|
|
48
|
+
clearResolverCache();
|
|
49
|
+
clearModuleResolutionCaches();
|
|
50
|
+
clearGlobCache();
|
|
51
|
+
clearGitignoreCache();
|
|
52
|
+
const { configurationFiles } = current.session;
|
|
53
|
+
if (configurationFiles)
|
|
54
|
+
unload(configurationFiles.getAffected(changes, current.options.cwd));
|
|
55
|
+
const nextOptions = await createOptions(current.options.createdFrom, true);
|
|
56
|
+
current = await initialize({ ...nextOptions, isCache: false });
|
|
57
|
+
Object.assign(results, current.results);
|
|
58
|
+
return { duration: performance.now() - startTime, mem: process.memoryUsage().heapUsed };
|
|
59
|
+
}
|
|
26
60
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
61
|
+
return {
|
|
62
|
+
handleFileChanges: changes => {
|
|
63
|
+
const update = pending.then(() => processChanges(changes));
|
|
64
|
+
pending = update.then(() => { }, () => { });
|
|
65
|
+
return update;
|
|
66
|
+
},
|
|
67
|
+
getIssues: () => (current.preprocess ? results : current.session.getIssues()),
|
|
68
|
+
getResults: () => results,
|
|
69
|
+
describeFile: (filePath, opts) => buildFileDescriptor(filePath, current.options.cwd, current.session.getGraph(), current.session.getEntryPaths(), opts),
|
|
70
|
+
describePackageJson: () => buildPackageJsonDescriptor(current.session.getGraph(), current.session.getEntryPaths()),
|
|
33
71
|
};
|
|
34
|
-
adapter.getIssues = () => results;
|
|
35
|
-
return adapter;
|
|
36
72
|
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { watch } from 'node:fs';
|
|
2
|
+
import { ConsoleStreamer } from '../ConsoleStreamer.js';
|
|
3
|
+
import watchReporter from '../reporters/watch.js';
|
|
4
|
+
import { debugLog } from '../util/debug.js';
|
|
5
|
+
import { hasErrorCause } from '../util/errors.js';
|
|
6
|
+
import { isFile } from '../util/fs.js';
|
|
7
|
+
import { logError } from '../util/log.js';
|
|
8
|
+
import { toPosix } from '../util/path.js';
|
|
9
|
+
import { createSession } from './session.js';
|
|
10
|
+
export const watchSession = async (options) => {
|
|
11
|
+
const streamer = new ConsoleStreamer(options);
|
|
12
|
+
const session = await createSession(options);
|
|
13
|
+
const report = (duration) => {
|
|
14
|
+
const { issues, counters } = session.getIssues();
|
|
15
|
+
watchReporter(options, { issues, streamer, size: counters.processed - counters.files, duration });
|
|
16
|
+
};
|
|
17
|
+
const onError = (error) => {
|
|
18
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
19
|
+
const reason = error instanceof Error && hasErrorCause(error) ? `\nReason: ${error.cause.message}` : '';
|
|
20
|
+
logError(message + reason);
|
|
21
|
+
process.exitCode = 2;
|
|
22
|
+
};
|
|
23
|
+
const watcher = watch(options.cwd, { recursive: true }, (eventType, filePath) => {
|
|
24
|
+
debugLog('*', `(raw) ${eventType} ${filePath}`);
|
|
25
|
+
if (typeof filePath !== 'string')
|
|
26
|
+
return;
|
|
27
|
+
const path = toPosix(filePath);
|
|
28
|
+
const type = eventType === 'rename' ? (isFile(options.cwd, path) ? 'added' : 'deleted') : 'modified';
|
|
29
|
+
session.handleFileChanges([{ type, filePath: path }]).then(update => {
|
|
30
|
+
if (!update)
|
|
31
|
+
return;
|
|
32
|
+
process.exitCode = 0;
|
|
33
|
+
report(update.duration);
|
|
34
|
+
}, onError);
|
|
35
|
+
});
|
|
36
|
+
watcher.on('error', error => {
|
|
37
|
+
onError(error);
|
|
38
|
+
watcher.close();
|
|
39
|
+
});
|
|
40
|
+
report();
|
|
41
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type PluginName = 'angular' | 'astro' | 'astro-db' | 'astro-markdoc' | 'astro-og-canvas' | 'ava' | 'babel' | 'biome' | 'borp' | 'buf' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'catalyst' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'electron-forge' | 'electron-vite' | 'eleventy' | 'esbuild' | 'eslint' | 'eve' | 'execa' | 'expo' | 'expo-router' | 'expressive-code' | 'fast' | 'filesystem-routing' | 'flue' | 'fumadocs' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jasmine' | 'jest' | 'karma' | 'knex' | 'ladle' | 'laravel-vite-plugin' | 'lefthook' | 'lint-staged' | 'linthtml' | 'lit' | 'lockfile-lint' | 'lost-pixel' | 'lunaria' | 'markdownlint' | 'marko' | 'mcp' | 'mdx' | 'mdxlint' | 'metro' | 'mise' | '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' | 'openclaw' | 'orval' | 'osls' | 'oxfmt' | 'oxlint' | 'panda-css' | 'parcel' | 'payload' | 'pino' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pm2' | 'pnpm' | 'postcss' | 'pre-commit' | 'preconstruct' | 'prettier' | 'prisma' | 'quasar' | 'qwik' | 'railway' | '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' | 'solidjs-vite-plugin' | 'sst' | 'starlight' | 'stencil' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'sveltejs-package' | 'sveltekit' | 'svgo' | 'svgr' | 'swc' | 'syncpack' | 'tailwind' | 'tanstack-router' | 'taskfile' | 'tauri' | 'temporal' | 'textlint' | 'travis' | 'ts-node' | 'tsd' | 'tsdown' | 'tsrs' | 'tsup' | 'tsx' | 'turbo' | 'typedoc' | 'typescript' | 'typescript-content-mapper' | 'unbuild' | 'unocss' | 'unplugin-auto-import' | 'unplugin-icons' | 'unplugin-vue-components' | 'unplugin-vue-i18n' | 'unplugin-vue-markdown' | 'unplugin-vue-router' | 'varlock' | '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', 'borp', 'buf', 'bumpp', 'bun', 'c8', 'capacitor', 'catalyst', 'changelogen', 'changelogithub', 'changesets', 'commitizen', 'commitlint', 'convex', 'create-typescript-app', 'cspell', 'cucumber', 'cypress', 'danger', 'dependency-cruiser', 'docusaurus', 'dotenv', 'drizzle', 'electron-forge', 'electron-vite', 'eleventy', 'esbuild', 'eslint', 'eve', 'execa', 'expo', 'expo-router', 'expressive-code', 'fast', 'filesystem-routing', 'flue', 'fumadocs', 'gatsby', 'github-action', 'github-actions', 'glob', 'graphql-codegen', 'hardhat', 'husky', 'i18next-parser', 'jasmine', 'jest', 'karma', 'knex', 'ladle', 'laravel-vite-plugin', 'lefthook', 'lint-staged', 'linthtml', 'lit', 'lockfile-lint', 'lost-pixel', 'lunaria', 'markdownlint', 'marko', 'mcp', 'mdx', 'mdxlint', 'metro', 'mise', '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', 'openclaw', 'orval', 'osls', 'oxfmt', 'oxlint', 'panda-css', 'parcel', 'payload', 'pino', 'playwright', 'playwright-ct', 'playwright-test', 'plop', 'pm2', 'pnpm', 'postcss', 'pre-commit', 'preconstruct', 'prettier', 'prisma', 'quasar', 'qwik', 'railway', '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', 'solidjs-vite-plugin', 'sst', 'starlight', 'stencil', 'storybook', 'stryker', 'stylelint', 'svelte', 'sveltejs-package', 'sveltekit', 'svgo', 'svgr', 'swc', 'syncpack', 'tailwind', 'tanstack-router', 'taskfile', 'tauri', 'temporal', 'textlint', 'travis', 'ts-node', 'tsd', 'tsdown', 'tsrs', 'tsup', 'tsx', 'turbo', 'typedoc', 'typescript', 'typescript-content-mapper', 'unbuild', 'unocss', 'unplugin-auto-import', 'unplugin-icons', 'unplugin-vue-components', 'unplugin-vue-i18n', 'unplugin-vue-markdown', 'unplugin-vue-router', 'varlock', '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' | 'borp' | 'buf' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'catalyst' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'electron-forge' | 'electron-vite' | 'eleventy' | 'esbuild' | 'eslint' | 'eve' | 'execa' | 'expo' | 'expo-router' | 'expressive-code' | 'fast' | 'filesystem-routing' | 'flue' | 'fumadocs' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jasmine' | 'jest' | 'karma' | 'knex' | 'kysely-codegen' | 'ladle' | 'laravel-vite-plugin' | 'lefthook' | 'lingui' | 'lint-staged' | 'linthtml' | 'lit' | 'lockfile-lint' | 'lost-pixel' | 'lunaria' | 'markdownlint' | 'marko' | 'mastra' | 'mcp' | 'mdx' | 'mdxlint' | 'metro' | 'mise' | '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' | 'openclaw' | 'orval' | 'osls' | 'oxfmt' | 'oxlint' | 'panda-css' | 'parcel' | 'payload' | 'pino' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pm2' | 'pnpm' | 'postcss' | 'pre-commit' | 'preconstruct' | 'prettier' | 'prisma' | 'purgecss' | 'quasar' | 'qwik' | 'railway' | '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' | 'solidjs-vite-plugin' | 'sst' | 'starlight' | 'stencil' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'sveltejs-package' | 'sveltekit' | 'svgo' | 'svgr' | 'swc' | 'syncpack' | 'tailwind' | 'tanstack-router' | 'taskfile' | 'tauri' | 'temporal' | 'textlint' | 'travis' | 'ts-node' | 'tsd' | 'tsdown' | 'tsrs' | 'tsup' | 'tsx' | 'turbo' | 'typedoc' | 'typescript' | 'typescript-content-mapper' | 'unbuild' | 'unocss' | 'unplugin-auto-import' | 'unplugin-icons' | 'unplugin-vue-components' | 'unplugin-vue-i18n' | 'unplugin-vue-markdown' | 'unplugin-vue-router' | 'varlock' | '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', 'borp', 'buf', 'bumpp', 'bun', 'c8', 'capacitor', 'catalyst', 'changelogen', 'changelogithub', 'changesets', 'commitizen', 'commitlint', 'convex', 'create-typescript-app', 'cspell', 'cucumber', 'cypress', 'danger', 'dependency-cruiser', 'docusaurus', 'dotenv', 'drizzle', 'electron-forge', 'electron-vite', 'eleventy', 'esbuild', 'eslint', 'eve', 'execa', 'expo', 'expo-router', 'expressive-code', 'fast', 'filesystem-routing', 'flue', 'fumadocs', 'gatsby', 'github-action', 'github-actions', 'glob', 'graphql-codegen', 'hardhat', 'husky', 'i18next-parser', 'jasmine', 'jest', 'karma', 'knex', 'kysely-codegen', 'ladle', 'laravel-vite-plugin', 'lefthook', 'lingui', 'lint-staged', 'linthtml', 'lit', 'lockfile-lint', 'lost-pixel', 'lunaria', 'markdownlint', 'marko', 'mastra', 'mcp', 'mdx', 'mdxlint', 'metro', 'mise', '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', 'openclaw', 'orval', 'osls', 'oxfmt', 'oxlint', 'panda-css', 'parcel', 'payload', 'pino', 'playwright', 'playwright-ct', 'playwright-test', 'plop', 'pm2', 'pnpm', 'postcss', 'pre-commit', 'preconstruct', 'prettier', 'prisma', 'purgecss', 'quasar', 'qwik', 'railway', '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', 'solidjs-vite-plugin', 'sst', 'starlight', 'stencil', 'storybook', 'stryker', 'stylelint', 'svelte', 'sveltejs-package', 'sveltekit', 'svgo', 'svgr', 'swc', 'syncpack', 'tailwind', 'tanstack-router', 'taskfile', 'tauri', 'temporal', 'textlint', 'travis', 'ts-node', 'tsd', 'tsdown', 'tsrs', 'tsup', 'tsx', 'turbo', 'typedoc', 'typescript', 'typescript-content-mapper', 'unbuild', 'unocss', 'unplugin-auto-import', 'unplugin-icons', 'unplugin-vue-components', 'unplugin-vue-i18n', 'unplugin-vue-markdown', 'unplugin-vue-router', 'varlock', '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'];
|
|
@@ -55,9 +55,11 @@ export const pluginNames = [
|
|
|
55
55
|
'jest',
|
|
56
56
|
'karma',
|
|
57
57
|
'knex',
|
|
58
|
+
'kysely-codegen',
|
|
58
59
|
'ladle',
|
|
59
60
|
'laravel-vite-plugin',
|
|
60
61
|
'lefthook',
|
|
62
|
+
'lingui',
|
|
61
63
|
'lint-staged',
|
|
62
64
|
'linthtml',
|
|
63
65
|
'lit',
|
|
@@ -66,6 +68,7 @@ export const pluginNames = [
|
|
|
66
68
|
'lunaria',
|
|
67
69
|
'markdownlint',
|
|
68
70
|
'marko',
|
|
71
|
+
'mastra',
|
|
69
72
|
'mcp',
|
|
70
73
|
'mdx',
|
|
71
74
|
'mdxlint',
|
|
@@ -112,6 +115,7 @@ export const pluginNames = [
|
|
|
112
115
|
'preconstruct',
|
|
113
116
|
'prettier',
|
|
114
117
|
'prisma',
|
|
118
|
+
'purgecss',
|
|
115
119
|
'quasar',
|
|
116
120
|
'qwik',
|
|
117
121
|
'railway',
|
package/dist/types/config.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export interface GetInputsFromScriptsOptions extends BaseOptions {
|
|
|
17
17
|
optionalBinaries?: boolean;
|
|
18
18
|
containingFilePath: string;
|
|
19
19
|
expandedScripts?: Set<string>;
|
|
20
|
+
manifestDir?: string;
|
|
20
21
|
}
|
|
21
22
|
export type GetInputsFromScripts<T = GetInputsFromScriptsOptions> = (npmScripts: string | string[] | Set<string>, options: T) => Input[];
|
|
22
23
|
export type GetInputsFromScriptsPartial = (npmScripts: string | string[] | Set<string>, options?: Partial<GetInputsFromScriptsOptions>) => Input[];
|
package/dist/types/issues.d.ts
CHANGED
|
@@ -71,6 +71,10 @@ export type ReporterOptions = {
|
|
|
71
71
|
selectedWorkspaces: string[] | undefined;
|
|
72
72
|
configFilePath: string | undefined;
|
|
73
73
|
maxShowIssues?: number;
|
|
74
|
+
write?: (output: string) => void;
|
|
75
|
+
};
|
|
76
|
+
export type InternalReporterOptions = ReporterOptions & {
|
|
77
|
+
write: (output: string) => void;
|
|
74
78
|
};
|
|
75
79
|
export type Reporter = (options: ReporterOptions) => void;
|
|
76
80
|
export type Preprocessor = (options: ReporterOptions) => ReporterOptions;
|
|
@@ -28,9 +28,6 @@ type Dependencies = Record<string, string>;
|
|
|
28
28
|
type TypesVersions = Record<string, Record<string, string[]>>;
|
|
29
29
|
export type PackageExtensions = Record<string, {
|
|
30
30
|
peerDependencies?: Dependencies;
|
|
31
|
-
peerDependenciesMeta?: Record<string, {
|
|
32
|
-
optional?: boolean;
|
|
33
|
-
}>;
|
|
34
31
|
}>;
|
|
35
32
|
export type PackageJson = {
|
|
36
33
|
name?: string;
|
|
@@ -26,6 +26,7 @@ const getImportsAndExports = (filePath, sourceText, resolveModule, options, igno
|
|
|
26
26
|
const scripts = new Set();
|
|
27
27
|
const importGlobs = [];
|
|
28
28
|
const handledImportExpressions = new Set();
|
|
29
|
+
const caughtImportExpressions = new Set();
|
|
29
30
|
const importAliases = new Map();
|
|
30
31
|
const addImportAlias = (aliasName, id, importFilePath) => {
|
|
31
32
|
const aliases = importAliases.get(aliasName);
|
|
@@ -342,6 +343,7 @@ const getImportsAndExports = (filePath, sourceText, resolveModule, options, igno
|
|
|
342
343
|
programFiles,
|
|
343
344
|
entryFiles,
|
|
344
345
|
handledImportExpressions,
|
|
346
|
+
caughtImportExpressions,
|
|
345
347
|
visitor,
|
|
346
348
|
getJSDocTags,
|
|
347
349
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IMPORT_FLAGS, OPAQUE } from '../../constants.js';
|
|
2
2
|
import { addValue } from '../../util/module-graph.js';
|
|
3
|
+
import { isStartsLikePackageName } from '../../util/modules.js';
|
|
3
4
|
import { getSafeScriptFromArgs, getScriptFromArg, getStringValue, isStringLiteral } from '../ast-nodes.js';
|
|
4
5
|
import { isShadowed } from './walk.js';
|
|
5
6
|
function getRegisteredCustomElement(node, s) {
|
|
@@ -136,23 +137,26 @@ export function handleCallExpression(node, s) {
|
|
|
136
137
|
s.addImport(specifier, undefined, undefined, undefined, node.arguments[0].start, IMPORT_FLAGS.ENTRY);
|
|
137
138
|
return;
|
|
138
139
|
}
|
|
139
|
-
if (s.hasNodeModuleImport &&
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
140
|
+
if (s.hasNodeModuleImport && node.arguments.length >= 1 && isStringLiteral(node.arguments[0])) {
|
|
141
|
+
const { callee } = node;
|
|
142
|
+
const nodeModuleMethod = callee.type === 'Identifier'
|
|
143
|
+
? callee.name
|
|
144
|
+
: callee.type === 'MemberExpression' &&
|
|
145
|
+
!callee.computed &&
|
|
146
|
+
callee.object.type === 'Identifier' &&
|
|
147
|
+
callee.object.name === 'module' &&
|
|
148
|
+
callee.property.type === 'Identifier' &&
|
|
149
|
+
callee.property.name;
|
|
148
150
|
const specifier = getStringValue(node.arguments[0]);
|
|
149
151
|
const arg1 = node.arguments[1];
|
|
150
|
-
if (
|
|
152
|
+
if ((nodeModuleMethod === 'register' &&
|
|
153
|
+
specifier &&
|
|
151
154
|
(!specifier.startsWith('.') ||
|
|
152
155
|
(arg1?.type === 'MemberExpression' &&
|
|
153
156
|
!arg1.computed &&
|
|
154
157
|
arg1.object.type === 'MetaProperty' &&
|
|
155
|
-
arg1.property.name === 'url')))
|
|
158
|
+
arg1.property.name === 'url'))) ||
|
|
159
|
+
(nodeModuleMethod === 'findPackageJSON' && isStartsLikePackageName(specifier) && !URL.canParse(specifier))) {
|
|
156
160
|
s.addImport(specifier, undefined, undefined, undefined, node.arguments[0].start, IMPORT_FLAGS.ENTRY);
|
|
157
161
|
return;
|
|
158
162
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { ImportExpression, VariableDeclarator } from 'oxc-parser';
|
|
1
|
+
import type { ArrayExpression, CallExpression, Expression, ImportExpression, VariableDeclarator } from 'oxc-parser';
|
|
2
2
|
import type { WalkState } from './walk.ts';
|
|
3
|
+
export declare function getPromiseAllElements(expression: Expression): ArrayExpression['elements'] | undefined;
|
|
3
4
|
export declare function handleVariableDeclarator(node: VariableDeclarator, s: WalkState): void;
|
|
5
|
+
export declare function handleImportThen(node: CallExpression, s: WalkState): void;
|
|
4
6
|
export declare function handleImportExpression(node: ImportExpression, s: WalkState): void;
|
|
@@ -2,6 +2,17 @@ import { IMPORT_FLAGS, IMPORT_STAR, OPAQUE } from '../../constants.js';
|
|
|
2
2
|
import { addValue } from '../../util/module-graph.js';
|
|
3
3
|
import { isInNodeModules } from '../../util/path.js';
|
|
4
4
|
import { getStringValue, isStringLiteral } from '../ast-nodes.js';
|
|
5
|
+
export function getPromiseAllElements(expression) {
|
|
6
|
+
if (expression.type === 'CallExpression' &&
|
|
7
|
+
expression.callee.type === 'MemberExpression' &&
|
|
8
|
+
!expression.callee.computed &&
|
|
9
|
+
expression.callee.object.type === 'Identifier' &&
|
|
10
|
+
expression.callee.object.name === 'Promise' &&
|
|
11
|
+
expression.callee.property.name === 'all' &&
|
|
12
|
+
expression.arguments[0]?.type === 'ArrayExpression') {
|
|
13
|
+
return expression.arguments[0].elements;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
5
16
|
export function handleVariableDeclarator(node, s) {
|
|
6
17
|
const init = node.init;
|
|
7
18
|
if (!init)
|
|
@@ -14,45 +25,8 @@ export function handleVariableDeclarator(node, s) {
|
|
|
14
25
|
importExpr = init;
|
|
15
26
|
}
|
|
16
27
|
if (importExpr && isStringLiteral(importExpr.source)) {
|
|
17
|
-
s.
|
|
18
|
-
|
|
19
|
-
if (node.id.type === 'ObjectPattern') {
|
|
20
|
-
for (const prop of node.id.properties) {
|
|
21
|
-
if (prop.type === 'Property') {
|
|
22
|
-
const importedName = prop.key?.type === 'Identifier'
|
|
23
|
-
? prop.key.name
|
|
24
|
-
: prop.key?.type === 'Literal' && typeof prop.key.value === 'string'
|
|
25
|
-
? prop.key.value
|
|
26
|
-
: undefined;
|
|
27
|
-
const localName = prop.value?.type === 'Identifier' ? prop.value.name : importedName;
|
|
28
|
-
const alias = localName !== importedName ? localName : undefined;
|
|
29
|
-
s.addImport(specifier, importedName, alias, undefined, prop.key?.start ?? prop.start, IMPORT_FLAGS.DYNAMIC);
|
|
30
|
-
}
|
|
31
|
-
else if (prop.type === 'RestElement' && prop.argument?.type === 'Identifier') {
|
|
32
|
-
s.addImport(specifier, IMPORT_STAR, prop.argument.name, undefined, prop.start, IMPORT_FLAGS.DYNAMIC);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
else if (node.id.type === 'Identifier') {
|
|
37
|
-
if (init.type === 'AwaitExpression') {
|
|
38
|
-
s.addImport(specifier, 'default', node.id.name, undefined, importExpr.source.start, IMPORT_FLAGS.DYNAMIC);
|
|
39
|
-
const resolved = s.resolveModule(specifier, s.filePath);
|
|
40
|
-
if (resolved && !resolved.isExternalLibraryImport && !isInNodeModules(resolved.resolvedFileName)) {
|
|
41
|
-
s.localImportMap.set(node.id.name, {
|
|
42
|
-
importedName: IMPORT_STAR,
|
|
43
|
-
filePath: resolved.resolvedFileName,
|
|
44
|
-
isNamespace: true,
|
|
45
|
-
isDynamicImport: true,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
s.addImport(specifier, undefined, undefined, undefined, importExpr.source.start, IMPORT_FLAGS.DYNAMIC | IMPORT_FLAGS.OPAQUE);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
s.addImport(specifier, undefined, undefined, undefined, importExpr.source.start, IMPORT_FLAGS.DYNAMIC | IMPORT_FLAGS.OPAQUE);
|
|
55
|
-
}
|
|
28
|
+
const caughtFlag = init.type === 'AwaitExpression' && s.caughtTryBlockEnds.length > 0 ? IMPORT_FLAGS.CAUGHT : IMPORT_FLAGS.NONE;
|
|
29
|
+
handleDynamicImportBinding(node.id, importExpr, init.type === 'AwaitExpression', caughtFlag, s);
|
|
56
30
|
return;
|
|
57
31
|
}
|
|
58
32
|
if (init.type === 'CallExpression' &&
|
|
@@ -87,16 +61,8 @@ export function handleVariableDeclarator(node, s) {
|
|
|
87
61
|
}
|
|
88
62
|
return;
|
|
89
63
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
init.argument.callee.type === 'MemberExpression' &&
|
|
93
|
-
!init.argument.callee.computed &&
|
|
94
|
-
init.argument.callee.object.type === 'Identifier' &&
|
|
95
|
-
init.argument.callee.object.name === 'Promise' &&
|
|
96
|
-
init.argument.callee.property.name === 'all' &&
|
|
97
|
-
init.argument.arguments[0]?.type === 'ArrayExpression' &&
|
|
98
|
-
node.id.type === 'ArrayPattern') {
|
|
99
|
-
const imports = init.argument.arguments[0].elements;
|
|
64
|
+
const imports = init.type === 'AwaitExpression' ? getPromiseAllElements(init.argument) : undefined;
|
|
65
|
+
if (imports && node.id.type === 'ArrayPattern') {
|
|
100
66
|
const bindings = node.id.elements;
|
|
101
67
|
for (let i = 0; i < imports.length; i++) {
|
|
102
68
|
const imp = imports[i];
|
|
@@ -106,6 +72,7 @@ export function handleVariableDeclarator(node, s) {
|
|
|
106
72
|
if (imp?.type === 'ImportExpression' && isStringLiteral(imp.source)) {
|
|
107
73
|
s.handledImportExpressions.add(imp.start);
|
|
108
74
|
const specifier = getStringValue(imp.source);
|
|
75
|
+
const caughtFlag = s.caughtTryBlockEnds.length > 0 ? IMPORT_FLAGS.CAUGHT : IMPORT_FLAGS.NONE;
|
|
109
76
|
if (binding?.type === 'ObjectPattern') {
|
|
110
77
|
for (const prop of binding.properties) {
|
|
111
78
|
if (prop.type === 'Property') {
|
|
@@ -114,12 +81,12 @@ export function handleVariableDeclarator(node, s) {
|
|
|
114
81
|
: prop.key?.type === 'Literal' && typeof prop.key.value === 'string'
|
|
115
82
|
? prop.key.value
|
|
116
83
|
: undefined;
|
|
117
|
-
s.addImport(specifier, importedName, undefined, undefined, prop.key?.start ?? prop.start,
|
|
84
|
+
s.addImport(specifier, importedName, undefined, undefined, prop.key?.start ?? prop.start, caughtFlag);
|
|
118
85
|
}
|
|
119
86
|
}
|
|
120
87
|
}
|
|
121
88
|
else if (binding?.type === 'Identifier') {
|
|
122
|
-
s.addImport(specifier, 'default', binding.name, undefined, imp.source.start, IMPORT_FLAGS.DYNAMIC);
|
|
89
|
+
s.addImport(specifier, 'default', binding.name, undefined, imp.source.start, IMPORT_FLAGS.DYNAMIC | caughtFlag);
|
|
123
90
|
const resolved = s.resolveModule(specifier, s.filePath);
|
|
124
91
|
if (resolved && !resolved.isExternalLibraryImport && !isInNodeModules(resolved.resolvedFileName)) {
|
|
125
92
|
s.localImportMap.set(binding.name, {
|
|
@@ -131,7 +98,7 @@ export function handleVariableDeclarator(node, s) {
|
|
|
131
98
|
}
|
|
132
99
|
}
|
|
133
100
|
else {
|
|
134
|
-
s.addImport(specifier, undefined, undefined, undefined, imp.source.start, IMPORT_FLAGS.DYNAMIC | IMPORT_FLAGS.SIDE_EFFECTS);
|
|
101
|
+
s.addImport(specifier, undefined, undefined, undefined, imp.source.start, IMPORT_FLAGS.DYNAMIC | IMPORT_FLAGS.SIDE_EFFECTS | caughtFlag);
|
|
135
102
|
}
|
|
136
103
|
}
|
|
137
104
|
}
|
|
@@ -263,11 +230,68 @@ export function handleVariableDeclarator(node, s) {
|
|
|
263
230
|
}
|
|
264
231
|
}
|
|
265
232
|
}
|
|
233
|
+
function handleDynamicImportBinding(id, importExpr, isAwaited, caughtFlag, s) {
|
|
234
|
+
s.handledImportExpressions.add(importExpr.start);
|
|
235
|
+
const specifier = getStringValue(importExpr.source);
|
|
236
|
+
if (id.type === 'ObjectPattern') {
|
|
237
|
+
for (const prop of id.properties) {
|
|
238
|
+
if (prop.type === 'Property') {
|
|
239
|
+
const importedName = prop.key?.type === 'Identifier'
|
|
240
|
+
? prop.key.name
|
|
241
|
+
: prop.key?.type === 'Literal' && typeof prop.key.value === 'string'
|
|
242
|
+
? prop.key.value
|
|
243
|
+
: undefined;
|
|
244
|
+
const localName = prop.value?.type === 'Identifier' ? prop.value.name : importedName;
|
|
245
|
+
const alias = localName !== importedName ? localName : undefined;
|
|
246
|
+
s.addImport(specifier, importedName, alias, undefined, prop.key?.start ?? prop.start, IMPORT_FLAGS.DYNAMIC | caughtFlag);
|
|
247
|
+
}
|
|
248
|
+
else if (prop.type === 'RestElement' && prop.argument?.type === 'Identifier') {
|
|
249
|
+
s.addImport(specifier, IMPORT_STAR, prop.argument.name, undefined, prop.start, IMPORT_FLAGS.DYNAMIC | caughtFlag);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
else if (id.type === 'Identifier') {
|
|
254
|
+
if (isAwaited) {
|
|
255
|
+
s.addImport(specifier, 'default', id.name, undefined, importExpr.source.start, IMPORT_FLAGS.DYNAMIC | caughtFlag);
|
|
256
|
+
const resolved = s.resolveModule(specifier, s.filePath);
|
|
257
|
+
if (resolved && !resolved.isExternalLibraryImport && !isInNodeModules(resolved.resolvedFileName)) {
|
|
258
|
+
s.localImportMap.set(id.name, {
|
|
259
|
+
importedName: IMPORT_STAR,
|
|
260
|
+
filePath: resolved.resolvedFileName,
|
|
261
|
+
isNamespace: true,
|
|
262
|
+
isDynamicImport: true,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
s.addImport(specifier, undefined, undefined, undefined, importExpr.source.start, IMPORT_FLAGS.DYNAMIC | IMPORT_FLAGS.OPAQUE | caughtFlag);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
s.addImport(specifier, undefined, undefined, undefined, importExpr.source.start, IMPORT_FLAGS.DYNAMIC | IMPORT_FLAGS.OPAQUE | caughtFlag);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
export function handleImportThen(node, s) {
|
|
275
|
+
const callee = node.callee;
|
|
276
|
+
if (callee.type !== 'MemberExpression' || callee.computed || callee.property.name !== 'then')
|
|
277
|
+
return;
|
|
278
|
+
if (callee.object.type !== 'ImportExpression' || !isStringLiteral(callee.object.source))
|
|
279
|
+
return;
|
|
280
|
+
const fn = node.arguments[0];
|
|
281
|
+
if (fn?.type !== 'ArrowFunctionExpression' && fn?.type !== 'FunctionExpression')
|
|
282
|
+
return;
|
|
283
|
+
const param = fn.params[0];
|
|
284
|
+
if (param?.type !== 'Identifier' && param?.type !== 'ObjectPattern')
|
|
285
|
+
return;
|
|
286
|
+
const caughtFlag = s.caughtImportExpressions.has(callee.object.start) ? IMPORT_FLAGS.CAUGHT : IMPORT_FLAGS.NONE;
|
|
287
|
+
handleDynamicImportBinding(param, callee.object, true, caughtFlag, s);
|
|
288
|
+
}
|
|
266
289
|
export function handleImportExpression(node, s) {
|
|
267
290
|
if (s.handledImportExpressions.has(node.start))
|
|
268
291
|
return;
|
|
269
292
|
const specifier = getStringValue(node.source);
|
|
270
293
|
if (specifier) {
|
|
271
|
-
s.
|
|
294
|
+
const caughtFlag = s.caughtImportExpressions.has(node.start) ? IMPORT_FLAGS.CAUGHT : IMPORT_FLAGS.NONE;
|
|
295
|
+
s.addImport(specifier, undefined, undefined, undefined, node.source.start, IMPORT_FLAGS.DYNAMIC | IMPORT_FLAGS.OPAQUE | caughtFlag);
|
|
272
296
|
}
|
|
273
297
|
}
|