knip 6.5.0 → 6.6.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/dist/ConfigurationChief.d.ts +8 -3
- package/dist/WorkspaceWorker.d.ts +6 -4
- package/dist/WorkspaceWorker.js +22 -4
- package/dist/binaries/plugins.js +2 -2
- package/dist/binaries/resolvers/bun.js +3 -3
- package/dist/binaries/resolvers/npm.js +2 -2
- package/dist/binaries/resolvers/pnpm.js +2 -2
- package/dist/binaries/resolvers/yarn.js +3 -3
- package/dist/compilers/index.d.ts +10 -0
- package/dist/graph/build.js +24 -14
- package/dist/plugins/astro/index.js +4 -2
- package/dist/plugins/astro/resolveFromAST.d.ts +1 -0
- package/dist/plugins/astro/resolveFromAST.js +40 -1
- package/dist/plugins/eslint/index.js +2 -7
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +2 -0
- package/dist/plugins/react-email/index.js +5 -3
- package/dist/plugins/rslib/index.js +8 -5
- package/dist/plugins/rslib/resolveFromAST.d.ts +2 -0
- package/dist/plugins/rslib/resolveFromAST.js +4 -0
- package/dist/plugins/sveltejs-package/helpers.d.ts +8 -0
- package/dist/plugins/sveltejs-package/helpers.js +65 -0
- package/dist/plugins/sveltejs-package/index.d.ts +3 -0
- package/dist/plugins/sveltejs-package/index.js +27 -0
- package/dist/plugins/vitest/helpers.d.ts +3 -1
- package/dist/plugins/vitest/helpers.js +18 -0
- package/dist/plugins/vitest/index.js +5 -19
- package/dist/reporters/trace.js +3 -3
- package/dist/reporters/util/util.d.ts +2 -2
- package/dist/reporters/util/util.js +13 -12
- package/dist/reporters/watch.js +4 -4
- 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/args.d.ts +2 -0
- package/dist/types/config.d.ts +17 -4
- package/dist/typescript/ast-helpers.d.ts +2 -0
- package/dist/typescript/ast-helpers.js +3 -3
- package/dist/util/colors.d.ts +18 -0
- package/dist/util/colors.js +24 -0
- package/dist/util/create-options.d.ts +10 -0
- package/dist/util/debug.js +2 -4
- package/dist/util/glob-core.js +18 -14
- package/dist/util/log.js +3 -3
- package/dist/util/package-json.d.ts +5 -0
- package/dist/util/package-json.js +9 -0
- package/dist/util/to-source-path.d.ts +3 -1
- package/dist/util/to-source-path.js +43 -20
- package/dist/util/trace.js +8 -8
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -3
- package/dist/plugins/rslib/types.d.ts +0 -1
- package/dist/plugins/rslib/types.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Configuration, IgnorePatterns, RawConfiguration, WorkspaceConfiguration } from './types/config.ts';
|
|
1
|
+
import type { Configuration, IgnorePatterns, RawConfiguration, SourceMap, WorkspaceConfiguration } from './types/config.ts';
|
|
2
2
|
import type { ConfigurationHint } from './types/issues.ts';
|
|
3
3
|
import type { WorkspacePackage } from './types/package-json.ts';
|
|
4
4
|
import type { MainOptions } from './util/create-options.ts';
|
|
@@ -14,8 +14,7 @@ export type Workspace = {
|
|
|
14
14
|
manifestPath: string;
|
|
15
15
|
manifestStr: string;
|
|
16
16
|
ignoreMembers: IgnorePatterns;
|
|
17
|
-
|
|
18
|
-
outDir?: string;
|
|
17
|
+
sourceMaps?: SourceMap[];
|
|
19
18
|
};
|
|
20
19
|
export declare class ConfigurationChief {
|
|
21
20
|
cwd: string;
|
|
@@ -637,6 +636,11 @@ export declare class ConfigurationChief {
|
|
|
637
636
|
entry?: string | string[] | undefined;
|
|
638
637
|
project?: string | string[] | undefined;
|
|
639
638
|
} | undefined;
|
|
639
|
+
'sveltejs-package'?: string | boolean | string[] | {
|
|
640
|
+
config?: string | string[] | undefined;
|
|
641
|
+
entry?: string | string[] | undefined;
|
|
642
|
+
project?: string | string[] | undefined;
|
|
643
|
+
} | undefined;
|
|
640
644
|
sveltekit?: string | boolean | string[] | {
|
|
641
645
|
config?: string | string[] | undefined;
|
|
642
646
|
entry?: string | string[] | undefined;
|
|
@@ -931,6 +935,7 @@ export declare class ConfigurationChief {
|
|
|
931
935
|
stryker?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
932
936
|
stylelint?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
933
937
|
svelte?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
938
|
+
"sveltejs-package"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
934
939
|
sveltekit?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
935
940
|
svgo?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
936
941
|
svgr?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { CacheConsultant } from './CacheConsultant.ts';
|
|
2
2
|
import { type Workspace } from './ConfigurationChief.ts';
|
|
3
|
-
import type { HandleInput, RegisterCompiler, RegisterVisitorsOptions, WorkspaceConfiguration } from './types/config.ts';
|
|
3
|
+
import type { HandleInput, RegisterCompiler, RegisterVisitorsOptions, SourceMap, WorkspaceConfiguration } from './types/config.ts';
|
|
4
4
|
import type { ConfigurationHint } from './types/issues.ts';
|
|
5
5
|
import type { PluginName } from './types/PluginNames.ts';
|
|
6
6
|
import type { PackageJson } from './types/package-json.ts';
|
|
7
7
|
import type { DependencySet } from './types/workspace.ts';
|
|
8
|
+
import { type Manifest } from './util/package-json.ts';
|
|
8
9
|
import type { MainOptions } from './util/create-options.ts';
|
|
9
10
|
import { type Input } from './util/input.ts';
|
|
10
11
|
type WorkspaceManagerOptions = {
|
|
@@ -13,7 +14,7 @@ type WorkspaceManagerOptions = {
|
|
|
13
14
|
config: WorkspaceConfiguration;
|
|
14
15
|
manifest: PackageJson;
|
|
15
16
|
dependencies: DependencySet;
|
|
16
|
-
rootManifest:
|
|
17
|
+
rootManifest: Manifest | undefined;
|
|
17
18
|
handleInput: HandleInput;
|
|
18
19
|
findWorkspaceByFilePath: (filePath: string) => Workspace | undefined;
|
|
19
20
|
readFile: (filePath: string) => string;
|
|
@@ -32,8 +33,8 @@ export declare class WorkspaceWorker {
|
|
|
32
33
|
name: string;
|
|
33
34
|
dir: string;
|
|
34
35
|
config: WorkspaceConfiguration;
|
|
35
|
-
manifest:
|
|
36
|
-
rootManifest:
|
|
36
|
+
manifest: Manifest;
|
|
37
|
+
rootManifest: Manifest | undefined;
|
|
37
38
|
dependencies: DependencySet;
|
|
38
39
|
handleInput: HandleInput;
|
|
39
40
|
findWorkspaceByFilePath: (filePath: string) => Workspace | undefined;
|
|
@@ -60,6 +61,7 @@ export declare class WorkspaceWorker {
|
|
|
60
61
|
getProductionProjectFilePatterns(negatedTestFilePatterns: string[]): string[];
|
|
61
62
|
private getConfigurationFilePatterns;
|
|
62
63
|
registerCompilers(registerCompiler: RegisterCompiler): Promise<void>;
|
|
64
|
+
resolveSourceMaps(): Promise<SourceMap[]>;
|
|
63
65
|
registerVisitors(options: RegisterVisitorsOptions): void;
|
|
64
66
|
runPlugins(): Promise<Input[]>;
|
|
65
67
|
private filterTransitiveDependencies;
|
package/dist/WorkspaceWorker.js
CHANGED
|
@@ -5,6 +5,7 @@ import { isDefaultPattern } from './ConfigurationChief.js';
|
|
|
5
5
|
import { DEFAULT_EXTENSIONS, ROOT_WORKSPACE_NAME } from './constants.js';
|
|
6
6
|
import { getFilteredScripts } from './manifest/helpers.js';
|
|
7
7
|
import { PluginEntries, Plugins } from './plugins.js';
|
|
8
|
+
import { createManifest } from './util/package-json.js';
|
|
8
9
|
import { collectStringLiterals, isExternalReExportsOnly } from './typescript/ast-helpers.js';
|
|
9
10
|
import { parseFile } from './typescript/visitors/helpers.js';
|
|
10
11
|
import { compact } from './util/array.js';
|
|
@@ -42,7 +43,7 @@ export class WorkspaceWorker {
|
|
|
42
43
|
this.name = name;
|
|
43
44
|
this.dir = dir;
|
|
44
45
|
this.config = config;
|
|
45
|
-
this.manifest = manifest;
|
|
46
|
+
this.manifest = createManifest(manifest);
|
|
46
47
|
this.rootManifest = rootManifest;
|
|
47
48
|
this.dependencies = dependencies;
|
|
48
49
|
this.negatedWorkspacePatterns = negatedWorkspacePatterns;
|
|
@@ -170,6 +171,24 @@ export class WorkspaceWorker {
|
|
|
170
171
|
await plugin.registerCompilers({ cwd, hasDependency, registerCompiler });
|
|
171
172
|
}
|
|
172
173
|
}
|
|
174
|
+
async resolveSourceMaps() {
|
|
175
|
+
const options = {
|
|
176
|
+
cwd: this.dir,
|
|
177
|
+
rootCwd: this.options.cwd,
|
|
178
|
+
manifest: this.manifest,
|
|
179
|
+
rootManifest: this.rootManifest,
|
|
180
|
+
dependencies: this.dependencies,
|
|
181
|
+
};
|
|
182
|
+
const pairs = [];
|
|
183
|
+
for (const pluginName of this.enabledPlugins) {
|
|
184
|
+
const plugin = Plugins[pluginName];
|
|
185
|
+
if (!plugin.resolveSourceMap)
|
|
186
|
+
continue;
|
|
187
|
+
for (const pair of await plugin.resolveSourceMap(options))
|
|
188
|
+
pairs.push(pair);
|
|
189
|
+
}
|
|
190
|
+
return pairs;
|
|
191
|
+
}
|
|
173
192
|
registerVisitors(options) {
|
|
174
193
|
for (const pluginName of this.enabledPlugins) {
|
|
175
194
|
if (options.registeredPlugins.has(pluginName))
|
|
@@ -189,10 +208,9 @@ export class WorkspaceWorker {
|
|
|
189
208
|
const containingFilePath = join(cwd, 'package.json');
|
|
190
209
|
const isProduction = this.options.isProduction;
|
|
191
210
|
const knownBinsOnly = false;
|
|
192
|
-
const manifestScriptNames = new Set(Object.keys(manifest.scripts ?? {}));
|
|
193
211
|
const rootManifest = this.rootManifest;
|
|
194
|
-
const baseOptions = {
|
|
195
|
-
const baseScriptOptions = { ...baseOptions,
|
|
212
|
+
const baseOptions = { manifest, rootManifest, cwd, rootCwd, containingFilePath, knownBinsOnly };
|
|
213
|
+
const baseScriptOptions = { ...baseOptions, isProduction, enabledPlugins: this.enabledPlugins };
|
|
196
214
|
const [productionScripts, developmentScripts] = getFilteredScripts(manifest.scripts ?? {});
|
|
197
215
|
const inputsFromManifest = _getInputsFromScripts(Object.values(developmentScripts), baseOptions);
|
|
198
216
|
const productionInputsFromManifest = _getInputsFromScripts(Object.values(productionScripts), baseOptions);
|
package/dist/binaries/plugins.js
CHANGED
|
@@ -9,7 +9,7 @@ const isGlobLikeMatch = /(^!|[*+\\(|{^$])/;
|
|
|
9
9
|
const isGlobLike = (value) => isGlobLikeMatch.test(value);
|
|
10
10
|
const nodeLoadersArgs = { import: ['r', 'experimental-loader', 'require', 'loader'] };
|
|
11
11
|
export const resolve = (binary, _args, options) => {
|
|
12
|
-
const { cwd, fromArgs, containingFilePath } = options;
|
|
12
|
+
const { cwd, fromArgs, containingFilePath, manifest } = options;
|
|
13
13
|
const [pluginName, pluginArgs] = pluginArgsMap.get(binary) ?? [];
|
|
14
14
|
if (!pluginArgs)
|
|
15
15
|
return fallbackResolve(binary, _args, options);
|
|
@@ -59,7 +59,7 @@ export const resolve = (binary, _args, options) => {
|
|
|
59
59
|
return parsed[id] && pluginName ? [toConfig(pluginName, fn(parsed[id]), inputOpts)] : [];
|
|
60
60
|
};
|
|
61
61
|
const configFilePaths = config.flatMap(mapToConfigPattern);
|
|
62
|
-
const inputs = pluginArgs.resolveInputs?.(parsed, { args, cwd }) ?? [];
|
|
62
|
+
const inputs = pluginArgs.resolveInputs?.(parsed, { args, cwd, manifest }) ?? [];
|
|
63
63
|
return [
|
|
64
64
|
toBinary(binary, inputOpts),
|
|
65
65
|
...positionals,
|
|
@@ -57,10 +57,10 @@ export const resolve = (_binary, args, options) => {
|
|
|
57
57
|
const argsForX = args.filter(arg => arg !== 'x');
|
|
58
58
|
return resolveX(argsForX, options);
|
|
59
59
|
}
|
|
60
|
-
const {
|
|
61
|
-
if (command === 'run' &&
|
|
60
|
+
const { manifest, cwd, fromArgs } = options;
|
|
61
|
+
if (command === 'run' && manifest.scriptNames.has(script))
|
|
62
62
|
return [];
|
|
63
|
-
if (
|
|
63
|
+
if (manifest.scriptNames.has(command))
|
|
64
64
|
return [];
|
|
65
65
|
if (command !== 'run' && commands.has(command))
|
|
66
66
|
return [];
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import parseArgs from 'minimist';
|
|
2
2
|
export const resolve = (_binary, args, options) => {
|
|
3
|
-
const { fromArgs,
|
|
3
|
+
const { fromArgs, manifest } = options;
|
|
4
4
|
const parsed = parseArgs(args, { '--': true });
|
|
5
5
|
const [command, script] = parsed._;
|
|
6
6
|
const _childArgs = parsed['--'] && parsed['--'].length > 0 ? fromArgs(parsed['--'], { knownBinsOnly: true }) : [];
|
|
7
7
|
if (command === 'exec')
|
|
8
8
|
return _childArgs;
|
|
9
|
-
if (command === 'run' &&
|
|
9
|
+
if (command === 'run' && manifest.scriptNames.has(script))
|
|
10
10
|
return _childArgs;
|
|
11
11
|
return [];
|
|
12
12
|
};
|
|
@@ -73,14 +73,14 @@ export const resolve = (_binary, args, options) => {
|
|
|
73
73
|
const argsForDlx = args.filter(arg => arg !== 'dlx');
|
|
74
74
|
return resolveDlx(argsForDlx, options);
|
|
75
75
|
}
|
|
76
|
-
const {
|
|
76
|
+
const { manifest, fromArgs } = options;
|
|
77
77
|
if (parsed.filter && !parsed.recursive)
|
|
78
78
|
return [];
|
|
79
79
|
const childInputs = parsed['--'] && parsed['--'].length > 0 ? fromArgs(parsed['--'], { knownBinsOnly: true }) : [];
|
|
80
80
|
if (command === 'exec') {
|
|
81
81
|
return childInputs.length > 0 ? childInputs : fromArgs(parsed._.slice(1));
|
|
82
82
|
}
|
|
83
|
-
const isScript =
|
|
83
|
+
const isScript = manifest.scriptNames.has(command);
|
|
84
84
|
if (isScript || commands.includes(command))
|
|
85
85
|
return childInputs;
|
|
86
86
|
return command && isValidBinary(command) ? [toBinary(command)] : [];
|
|
@@ -49,7 +49,7 @@ const resolveDlx = (args, options) => {
|
|
|
49
49
|
return [...packages.map(id => toDependency(id)), ...command].map(id => isDependency(id) || isBinary(id) ? Object.assign(id, { optional: true }) : id);
|
|
50
50
|
};
|
|
51
51
|
export const resolve = (_binary, args, options) => {
|
|
52
|
-
const {
|
|
52
|
+
const { manifest, fromArgs, cwd, rootCwd } = options;
|
|
53
53
|
const parsed = parseArgs(args, { boolean: ['top-level'], string: ['cwd'], '--': true });
|
|
54
54
|
const dir = parsed['top-level'] ? rootCwd : parsed.cwd ? join(cwd, parsed.cwd) : undefined;
|
|
55
55
|
const [command, binary] = parsed._;
|
|
@@ -57,7 +57,7 @@ export const resolve = (_binary, args, options) => {
|
|
|
57
57
|
return [];
|
|
58
58
|
const _childArgs = parsed['--'] && parsed['--'].length > 0 ? fromArgs(parsed['--'], { knownBinsOnly: true }) : [];
|
|
59
59
|
if (command === 'run') {
|
|
60
|
-
if (
|
|
60
|
+
if (manifest.scriptNames.has(binary))
|
|
61
61
|
return _childArgs;
|
|
62
62
|
const bin = toBinary(binary, { optional: true });
|
|
63
63
|
if (dir)
|
|
@@ -70,7 +70,7 @@ export const resolve = (_binary, args, options) => {
|
|
|
70
70
|
const argsForDlx = args.filter(arg => arg !== 'dlx');
|
|
71
71
|
return resolveDlx(argsForDlx, options);
|
|
72
72
|
}
|
|
73
|
-
if ((!dir &&
|
|
73
|
+
if ((!dir && manifest.scriptNames.has(command)) || commands.includes(command))
|
|
74
74
|
return _childArgs;
|
|
75
75
|
const opts = dir ? { cwd: dir } : {};
|
|
76
76
|
return fromArgs(argsFrom(args, command === 'exec' ? binary : command), opts);
|
|
@@ -583,6 +583,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
583
583
|
entry?: string | string[] | undefined;
|
|
584
584
|
project?: string | string[] | undefined;
|
|
585
585
|
} | undefined;
|
|
586
|
+
'sveltejs-package'?: string | boolean | string[] | {
|
|
587
|
+
config?: string | string[] | undefined;
|
|
588
|
+
entry?: string | string[] | undefined;
|
|
589
|
+
project?: string | string[] | undefined;
|
|
590
|
+
} | undefined;
|
|
586
591
|
sveltekit?: string | boolean | string[] | {
|
|
587
592
|
config?: string | string[] | undefined;
|
|
588
593
|
entry?: string | string[] | undefined;
|
|
@@ -1339,6 +1344,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
1339
1344
|
entry?: string | string[] | undefined;
|
|
1340
1345
|
project?: string | string[] | undefined;
|
|
1341
1346
|
} | undefined;
|
|
1347
|
+
'sveltejs-package'?: string | boolean | string[] | {
|
|
1348
|
+
config?: string | string[] | undefined;
|
|
1349
|
+
entry?: string | string[] | undefined;
|
|
1350
|
+
project?: string | string[] | undefined;
|
|
1351
|
+
} | undefined;
|
|
1342
1352
|
sveltekit?: string | boolean | string[] | {
|
|
1343
1353
|
config?: string | string[] | undefined;
|
|
1344
1354
|
entry?: string | string[] | undefined;
|
package/dist/graph/build.js
CHANGED
|
@@ -6,6 +6,7 @@ import { createInputHandler } from '../util/create-input-handler.js';
|
|
|
6
6
|
import { debugLog, debugLogArray } from '../util/debug.js';
|
|
7
7
|
import { existsSync } from 'node:fs';
|
|
8
8
|
import { tryRealpath } from '../util/fs.js';
|
|
9
|
+
import { createManifest } from '../util/package-json.js';
|
|
9
10
|
import { _glob, _syncGlob, negate, prependDirToPattern as prependDir } from '../util/glob.js';
|
|
10
11
|
import { isAlias, isConfig, isDeferResolveEntry, isDeferResolveProductionEntry, isEntry, isIgnore, isProductionEntry, isProject, toProductionEntry, } from '../util/input.js';
|
|
11
12
|
import { loadTSConfig } from '../util/load-tsconfig.js';
|
|
@@ -14,7 +15,7 @@ import { getPackageNameFromModuleSpecifier, isStartsLikePackageName, sanitizeSpe
|
|
|
14
15
|
import { perfObserver } from '../util/Performance.js';
|
|
15
16
|
import { getEntrySpecifiersFromManifest, getManifestImportDependencies } from '../util/package-json.js';
|
|
16
17
|
import { dirname, extname, isAbsolute, isInNodeModules, join, relative } from '../util/path.js';
|
|
17
|
-
import { augmentWorkspace, getToSourcePathsHandler } from '../util/to-source-path.js';
|
|
18
|
+
import { augmentWorkspace, getToSourcePathsHandler, toSourceMappedSpecifiers } from '../util/to-source-path.js';
|
|
18
19
|
import { WorkspaceWorker } from '../WorkspaceWorker.js';
|
|
19
20
|
export async function build({ chief, collector, counselor, deputy, principal, isGitIgnored, streamer, workspaces, options, }) {
|
|
20
21
|
const configFilesMap = new Map();
|
|
@@ -24,7 +25,8 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
24
25
|
const addIssue = (issue) => collector.addIssue(issue) && options.isWatch && collector.retainIssue(issue);
|
|
25
26
|
const externalRefsFromInputs = options.isSession ? new Map() : undefined;
|
|
26
27
|
const handleInput = createInputHandler(deputy, chief, isGitIgnored, addIssue, externalRefsFromInputs, options);
|
|
27
|
-
const
|
|
28
|
+
const rawRootManifest = chief.getManifestForWorkspace('.');
|
|
29
|
+
const rootManifest = rawRootManifest ? createManifest(rawRootManifest) : undefined;
|
|
28
30
|
for (const workspace of workspaces) {
|
|
29
31
|
const { name, dir, manifestPath, manifestStr } = workspace;
|
|
30
32
|
const manifest = chief.getManifestForWorkspace(name);
|
|
@@ -57,8 +59,6 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
57
59
|
const tsConfigFilePath = join(dir, options.tsConfigFile ?? 'tsconfig.json');
|
|
58
60
|
const { isFile, compilerOptions, fileNames } = await loadTSConfig(tsConfigFilePath);
|
|
59
61
|
const [definitionPaths, tscSourcePaths] = partition(fileNames, filePath => IS_DTS.test(filePath));
|
|
60
|
-
if (isFile)
|
|
61
|
-
augmentWorkspace(workspace, dir, compilerOptions);
|
|
62
62
|
const worker = new WorkspaceWorker({
|
|
63
63
|
name,
|
|
64
64
|
dir,
|
|
@@ -89,6 +89,8 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
89
89
|
const extensionGlobStr = `.{${[...DEFAULT_EXTENSIONS, ...extensions].map(ext => ext.slice(1)).join(',')}}`;
|
|
90
90
|
const config = chief.getConfigForWorkspace(name, extensions);
|
|
91
91
|
worker.config = config;
|
|
92
|
+
const pluginSourceMaps = await worker.resolveSourceMaps();
|
|
93
|
+
augmentWorkspace(workspace, dir, isFile ? compilerOptions : undefined, pluginSourceMaps);
|
|
92
94
|
const inputs = new Set();
|
|
93
95
|
if (definitionPaths.length > 0) {
|
|
94
96
|
debugLogArray(name, 'Definition paths', definitionPaths);
|
|
@@ -105,13 +107,21 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
105
107
|
inputs.add(toProductionEntry(filePath));
|
|
106
108
|
}
|
|
107
109
|
for (const identifier of entrySpecifiersFromManifest) {
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
if (identifier.startsWith('!') || isGitIgnored(join(dir, identifier)))
|
|
111
|
+
continue;
|
|
112
|
+
if (!identifier.startsWith('.') && !identifier.startsWith('/')) {
|
|
113
|
+
const packageName = getPackageNameFromModuleSpecifier(identifier);
|
|
114
|
+
if (packageName && dependencies.has(packageName))
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const abs = prependDir(dir, identifier);
|
|
118
|
+
const mapped = toSourceMappedSpecifiers(workspace, abs, extensionGlobStr);
|
|
119
|
+
const hasWildcard = identifier.includes('*');
|
|
120
|
+
const exists = hasWildcard
|
|
121
|
+
? _syncGlob({ patterns: [identifier, ...mapped], cwd: dir }).length > 0
|
|
122
|
+
: existsSync(abs) || mapped.some(pattern => _syncGlob({ patterns: [pattern], cwd: dir }).length > 0);
|
|
123
|
+
if (!exists) {
|
|
124
|
+
collector.addConfigurationHint({ type: 'package-entry', filePath, identifier, workspaceName: name });
|
|
115
125
|
}
|
|
116
126
|
}
|
|
117
127
|
for (const dep of getManifestImportDependencies(manifest))
|
|
@@ -322,16 +332,16 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
322
332
|
}
|
|
323
333
|
}
|
|
324
334
|
}
|
|
325
|
-
|
|
335
|
+
const manifest = chief.getManifestForWorkspace(workspace.name);
|
|
336
|
+
if (manifest && file.scripts && file.scripts.size > 0) {
|
|
326
337
|
const dependencies = deputy.getDependencies(workspace.name);
|
|
327
|
-
const manifestScriptNames = new Set(Object.keys(chief.getManifestForWorkspace(workspace.name)?.scripts ?? {}));
|
|
328
338
|
const dir = dirname(filePath);
|
|
329
339
|
const opts = {
|
|
330
340
|
cwd: dir,
|
|
331
341
|
rootCwd: options.cwd,
|
|
332
342
|
containingFilePath: filePath,
|
|
333
343
|
dependencies,
|
|
334
|
-
|
|
344
|
+
manifest: createManifest(manifest),
|
|
335
345
|
rootManifest,
|
|
336
346
|
};
|
|
337
347
|
const inputs = _getInputsFromScripts(file.scripts, opts);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { toDependency, toEntry, toProductionEntry } from '../../util/input.js';
|
|
2
2
|
import { hasDependency } from '../../util/plugin.js';
|
|
3
|
+
import { getAliasInputs } from '../vitest/helpers.js';
|
|
3
4
|
import compiler from './compiler.js';
|
|
4
5
|
import mdxCompiler from './compiler-mdx.js';
|
|
5
|
-
import { getSrcDir, usesPassthroughImageService } from './resolveFromAST.js';
|
|
6
|
+
import { getSrcDir, getViteAliases, usesPassthroughImageService } from './resolveFromAST.js';
|
|
6
7
|
const title = 'Astro';
|
|
7
8
|
const enablers = ['astro'];
|
|
8
9
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
@@ -16,12 +17,13 @@ const production = [
|
|
|
16
17
|
'src/middleware.{js,ts}',
|
|
17
18
|
'src/actions/index.{js,ts}',
|
|
18
19
|
];
|
|
19
|
-
const resolveFromAST = program => {
|
|
20
|
+
const resolveFromAST = (program, options) => {
|
|
20
21
|
const srcDir = getSrcDir(program);
|
|
21
22
|
const setSrcDir = (entry) => entry.replace(/^src\//, `${srcDir}/`);
|
|
22
23
|
const inputs = [
|
|
23
24
|
...entry.map(setSrcDir).map(path => toEntry(path)),
|
|
24
25
|
...production.map(setSrcDir).map(path => toProductionEntry(path)),
|
|
26
|
+
...getAliasInputs(getViteAliases(program), options.cwd),
|
|
25
27
|
];
|
|
26
28
|
if (!usesPassthroughImageService(program))
|
|
27
29
|
inputs.push(toDependency('sharp', { optional: true }));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { Program } from 'oxc-parser';
|
|
2
2
|
export declare const getSrcDir: (program: Program) => string;
|
|
3
3
|
export declare const usesPassthroughImageService: (program: Program) => boolean;
|
|
4
|
+
export declare const getViteAliases: (program: Program) => Record<string, string>;
|
|
@@ -1,6 +1,45 @@
|
|
|
1
|
-
import { collectPropertyValues, hasImportSpecifier } from '../../typescript/ast-helpers.js';
|
|
1
|
+
import { collectPropertyValues, findProperty, getPropertyKey, getStringValue, hasImportSpecifier, } from '../../typescript/ast-helpers.js';
|
|
2
2
|
export const getSrcDir = (program) => {
|
|
3
3
|
const values = collectPropertyValues(program, 'srcDir');
|
|
4
4
|
return values.size > 0 ? Array.from(values)[0] : 'src';
|
|
5
5
|
};
|
|
6
6
|
export const usesPassthroughImageService = (program) => hasImportSpecifier(program, 'astro/config', 'passthroughImageService');
|
|
7
|
+
const findFirstStringArg = (node) => {
|
|
8
|
+
const literal = getStringValue(node);
|
|
9
|
+
if (literal)
|
|
10
|
+
return literal;
|
|
11
|
+
if (node?.type === 'CallExpression' || node?.type === 'NewExpression') {
|
|
12
|
+
for (const arg of node.arguments ?? []) {
|
|
13
|
+
const found = findFirstStringArg(arg);
|
|
14
|
+
if (found)
|
|
15
|
+
return found;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export const getViteAliases = (program) => {
|
|
20
|
+
const aliases = {};
|
|
21
|
+
for (const node of program.body ?? []) {
|
|
22
|
+
if (node.type !== 'ExportDefaultDeclaration')
|
|
23
|
+
continue;
|
|
24
|
+
const decl = node.declaration;
|
|
25
|
+
const root = decl?.type === 'ObjectExpression'
|
|
26
|
+
? decl
|
|
27
|
+
: decl?.type === 'CallExpression' && decl.arguments?.[0]?.type === 'ObjectExpression'
|
|
28
|
+
? decl.arguments[0]
|
|
29
|
+
: undefined;
|
|
30
|
+
const aliasNode = findProperty(findProperty(findProperty(root, 'vite'), 'resolve'), 'alias');
|
|
31
|
+
if (aliasNode?.type !== 'ObjectExpression')
|
|
32
|
+
continue;
|
|
33
|
+
for (const prop of aliasNode.properties ?? []) {
|
|
34
|
+
if (prop.type !== 'Property')
|
|
35
|
+
continue;
|
|
36
|
+
const key = getPropertyKey(prop);
|
|
37
|
+
if (!key)
|
|
38
|
+
continue;
|
|
39
|
+
const raw = findFirstStringArg(prop.value);
|
|
40
|
+
if (raw)
|
|
41
|
+
aliases[key] = raw;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return aliases;
|
|
45
|
+
};
|
|
@@ -17,13 +17,8 @@ const config = [
|
|
|
17
17
|
const isLoadConfig = ({ configFileName, manifest }, dependencies) => {
|
|
18
18
|
if (isFlatConfig(configFileName))
|
|
19
19
|
return false;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const major = version.match(/\d+/);
|
|
23
|
-
if (major && Number.parseInt(major[0], 10) === 9 && dependencies.has('eslint-config-next')) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
20
|
+
if (manifest.getMajor('eslint') === 9 && dependencies.has('eslint-config-next'))
|
|
21
|
+
return false;
|
|
27
22
|
return true;
|
|
28
23
|
};
|
|
29
24
|
const resolveConfig = (localConfig, options) => getInputs(localConfig, options);
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -120,6 +120,7 @@ export declare const Plugins: {
|
|
|
120
120
|
stryker: import("../types/config.ts").Plugin;
|
|
121
121
|
stylelint: import("../types/config.ts").Plugin;
|
|
122
122
|
svelte: import("../types/config.ts").Plugin;
|
|
123
|
+
'sveltejs-package': import("../types/config.ts").Plugin;
|
|
123
124
|
sveltekit: import("../types/config.ts").Plugin;
|
|
124
125
|
svgo: import("../types/config.ts").Plugin;
|
|
125
126
|
svgr: import("../types/config.ts").Plugin;
|
package/dist/plugins/index.js
CHANGED
|
@@ -114,6 +114,7 @@ import { default as storybook } from './storybook/index.js';
|
|
|
114
114
|
import { default as stryker } from './stryker/index.js';
|
|
115
115
|
import { default as stylelint } from './stylelint/index.js';
|
|
116
116
|
import { default as svelte } from './svelte/index.js';
|
|
117
|
+
import { default as sveltejsPackage } from './sveltejs-package/index.js';
|
|
117
118
|
import { default as sveltekit } from './sveltekit/index.js';
|
|
118
119
|
import { default as svgo } from './svgo/index.js';
|
|
119
120
|
import { default as svgr } from './svgr/index.js';
|
|
@@ -262,6 +263,7 @@ export const Plugins = {
|
|
|
262
263
|
stryker,
|
|
263
264
|
stylelint,
|
|
264
265
|
svelte,
|
|
266
|
+
'sveltejs-package': sveltejsPackage,
|
|
265
267
|
sveltekit,
|
|
266
268
|
svgo,
|
|
267
269
|
svgr,
|
|
@@ -7,10 +7,12 @@ const entry = ['emails/**/*.tsx'];
|
|
|
7
7
|
const previewCommands = new Set(['build', 'dev', 'start']);
|
|
8
8
|
const args = {
|
|
9
9
|
binaries: ['email'],
|
|
10
|
-
resolveInputs: parsed => {
|
|
10
|
+
resolveInputs: (parsed, { manifest }) => {
|
|
11
11
|
const inputs = [];
|
|
12
|
-
if (previewCommands.has(parsed._[0]))
|
|
13
|
-
|
|
12
|
+
if (previewCommands.has(parsed._[0])) {
|
|
13
|
+
const dep = (manifest.getMajor('react-email') ?? 0) >= 6 ? '@react-email/ui' : '@react-email/preview-server';
|
|
14
|
+
inputs.push(toDependency(dep));
|
|
15
|
+
}
|
|
14
16
|
if (parsed.dir)
|
|
15
17
|
inputs.push(toEntry(`${parsed.dir}/**/*.tsx`));
|
|
16
18
|
return inputs;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
import { toProductionEntry } from '../../util/input.js';
|
|
1
2
|
import { hasDependency } from '../../util/plugin.js';
|
|
3
|
+
import { getEntryFromAST } from './resolveFromAST.js';
|
|
2
4
|
const title = 'Rslib';
|
|
3
5
|
const enablers = ['@rslib/core'];
|
|
4
6
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
7
|
+
const config = ['rslib*.config.{mjs,ts,js,cjs,mts,cts}'];
|
|
8
|
+
const resolveFromAST = program => {
|
|
9
|
+
const entries = getEntryFromAST(program);
|
|
10
|
+
return [...entries].map(id => toProductionEntry(id, { allowIncludeExports: true }));
|
|
8
11
|
};
|
|
9
12
|
const plugin = {
|
|
10
13
|
title,
|
|
11
14
|
enablers,
|
|
12
15
|
isEnabled,
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
config,
|
|
17
|
+
resolveFromAST,
|
|
15
18
|
};
|
|
16
19
|
export default plugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const DEFAULT_INPUT = "src/lib";
|
|
2
|
+
export declare const DEFAULT_OUTPUT = "dist";
|
|
3
|
+
interface IO {
|
|
4
|
+
input: string;
|
|
5
|
+
output: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const parseScripts: (scripts: Record<string, string | undefined> | undefined) => IO[];
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import parseArgs from 'minimist';
|
|
2
|
+
import { parse } from 'unbash';
|
|
3
|
+
const BIN = 'svelte-package';
|
|
4
|
+
export const DEFAULT_INPUT = 'src/lib';
|
|
5
|
+
export const DEFAULT_OUTPUT = 'dist';
|
|
6
|
+
const parseCommandIO = (args) => {
|
|
7
|
+
const parsed = parseArgs(args, { string: ['i', 'o', 'input', 'output'], alias: { input: ['i'], output: ['o'] } });
|
|
8
|
+
return { input: parsed.input ?? DEFAULT_INPUT, output: parsed.output ?? DEFAULT_OUTPUT };
|
|
9
|
+
};
|
|
10
|
+
const collectFromCommands = (statements, out) => {
|
|
11
|
+
for (const stmt of statements)
|
|
12
|
+
visit(stmt.command, out);
|
|
13
|
+
};
|
|
14
|
+
const visit = (node, out) => {
|
|
15
|
+
switch (node.type) {
|
|
16
|
+
case 'Command':
|
|
17
|
+
if (node.name?.value === BIN)
|
|
18
|
+
out.push(parseCommandIO(node.suffix.map(w => w.value)));
|
|
19
|
+
return;
|
|
20
|
+
case 'AndOr':
|
|
21
|
+
case 'Pipeline':
|
|
22
|
+
for (const n of node.commands)
|
|
23
|
+
visit(n, out);
|
|
24
|
+
return;
|
|
25
|
+
case 'If':
|
|
26
|
+
collectFromCommands(node.clause.commands, out);
|
|
27
|
+
collectFromCommands(node.then.commands, out);
|
|
28
|
+
if (node.else)
|
|
29
|
+
visit(node.else, out);
|
|
30
|
+
return;
|
|
31
|
+
case 'While':
|
|
32
|
+
collectFromCommands(node.clause.commands, out);
|
|
33
|
+
collectFromCommands(node.body.commands, out);
|
|
34
|
+
return;
|
|
35
|
+
case 'For':
|
|
36
|
+
case 'Select':
|
|
37
|
+
case 'Subshell':
|
|
38
|
+
case 'BraceGroup':
|
|
39
|
+
collectFromCommands(node.body.commands, out);
|
|
40
|
+
return;
|
|
41
|
+
case 'CompoundList':
|
|
42
|
+
collectFromCommands(node.commands, out);
|
|
43
|
+
return;
|
|
44
|
+
case 'Function':
|
|
45
|
+
case 'Coproc':
|
|
46
|
+
visit(node.body, out);
|
|
47
|
+
return;
|
|
48
|
+
case 'Statement':
|
|
49
|
+
visit(node.command, out);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
export const parseScripts = (scripts) => {
|
|
53
|
+
const out = [];
|
|
54
|
+
for (const script of Object.values(scripts ?? {})) {
|
|
55
|
+
if (typeof script !== 'string' || !script.includes(BIN))
|
|
56
|
+
continue;
|
|
57
|
+
try {
|
|
58
|
+
const parsed = parse(script);
|
|
59
|
+
if (parsed.commands)
|
|
60
|
+
collectFromCommands(parsed.commands, out);
|
|
61
|
+
}
|
|
62
|
+
catch { }
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { join } from '../../util/path.js';
|
|
2
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
3
|
+
import { DEFAULT_INPUT, DEFAULT_OUTPUT, parseScripts } from './helpers.js';
|
|
4
|
+
const title = '@sveltejs/package';
|
|
5
|
+
const enablers = ['@sveltejs/package'];
|
|
6
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
7
|
+
const resolveSourceMap = ({ cwd, manifest }) => {
|
|
8
|
+
const ios = parseScripts(manifest.scripts);
|
|
9
|
+
const effective = ios.length > 0 ? ios : [{ input: DEFAULT_INPUT, output: DEFAULT_OUTPUT }];
|
|
10
|
+
const seen = new Set();
|
|
11
|
+
const pairs = [];
|
|
12
|
+
for (const { input, output } of effective) {
|
|
13
|
+
const key = `${input}→${output}`;
|
|
14
|
+
if (seen.has(key))
|
|
15
|
+
continue;
|
|
16
|
+
seen.add(key);
|
|
17
|
+
pairs.push({ srcDir: join(cwd, input), outDir: join(cwd, output) });
|
|
18
|
+
}
|
|
19
|
+
return pairs;
|
|
20
|
+
};
|
|
21
|
+
const plugin = {
|
|
22
|
+
title,
|
|
23
|
+
enablers,
|
|
24
|
+
isEnabled,
|
|
25
|
+
resolveSourceMap,
|
|
26
|
+
};
|
|
27
|
+
export default plugin;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Input } from '../../util/input.ts';
|
|
2
|
+
import type { AliasOptions, ViteConfig } from './types.ts';
|
|
2
3
|
export declare const getEnvSpecifier: (env: string) => string;
|
|
4
|
+
export declare const getAliasInputs: (aliasOptions: AliasOptions, cwd: string) => Input[];
|
|
3
5
|
export declare const getExternalReporters: (reporters?: ViteConfig['test']['reporters']) => string[];
|