knip 6.23.0 → 6.25.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/LICENSE +1 -1
- package/dist/ConfigurationChief.d.ts +13 -1
- package/dist/ConfigurationChief.js +3 -0
- package/dist/ProjectPrincipal.d.ts +2 -0
- package/dist/ProjectPrincipal.js +7 -6
- package/dist/WorkspaceWorker.d.ts +3 -1
- package/dist/WorkspaceWorker.js +5 -2
- package/dist/binaries/bash-parser.js +55 -83
- package/dist/binaries/index.js +3 -0
- package/dist/binaries/resolvers/yarn.js +4 -3
- package/dist/compilers/compilers.d.ts +2 -0
- package/dist/compilers/compilers.js +15 -4
- package/dist/compilers/index.d.ts +30 -6
- package/dist/compilers/index.js +25 -10
- package/dist/compilers/less.d.ts +7 -0
- package/dist/compilers/less.js +37 -0
- package/dist/compilers/mdx.d.ts +1 -2
- package/dist/compilers/mdx.js +14 -8
- package/dist/compilers/scss.d.ts +3 -2
- package/dist/compilers/scss.js +17 -14
- package/dist/compilers/shared.d.ts +6 -0
- package/dist/compilers/shared.js +9 -0
- package/dist/compilers/style-preprocessors.d.ts +2 -0
- package/dist/compilers/style-preprocessors.js +41 -0
- package/dist/compilers/stylus.d.ts +7 -0
- package/dist/compilers/stylus.js +36 -0
- package/dist/constants.d.ts +5 -1
- package/dist/constants.js +7 -0
- package/dist/graph/analyze.js +37 -2
- package/dist/graph/build.js +23 -1
- package/dist/graph-explorer/explorer.d.ts +1 -0
- package/dist/graph-explorer/explorer.js +2 -0
- package/dist/graph-explorer/operations/find-all-cycles.d.ts +3 -0
- package/dist/graph-explorer/operations/find-all-cycles.js +43 -0
- package/dist/graph-explorer/operations/find-cycles.js +3 -9
- package/dist/graph-explorer/utils.d.ts +10 -1
- package/dist/graph-explorer/utils.js +53 -0
- package/dist/plugins/astro/compiler-mdx.js +11 -2
- package/dist/plugins/astro/compiler.js +8 -4
- package/dist/plugins/bun/index.js +28 -14
- package/dist/plugins/eve/index.d.ts +3 -0
- package/dist/plugins/eve/index.js +22 -0
- package/dist/plugins/execa/visitors/execa.js +10 -18
- package/dist/plugins/fumadocs/index.d.ts +3 -0
- package/dist/plugins/fumadocs/index.js +18 -0
- package/dist/plugins/github-actions/index.js +3 -2
- package/dist/plugins/graphql-codegen/index.js +9 -7
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.js +4 -0
- package/dist/plugins/jest/index.js +13 -3
- package/dist/plugins/next/index.js +23 -10
- package/dist/plugins/node/index.js +4 -1
- package/dist/plugins/nuxt/index.js +4 -2
- package/dist/plugins/pnpm/index.js +21 -1
- package/dist/plugins/pnpm/types.d.ts +6 -0
- package/dist/plugins/pnpm/types.js +1 -0
- package/dist/plugins/prettier/index.js +19 -3
- package/dist/plugins/prettier/types.d.ts +6 -1
- package/dist/plugins/prisma/compiler.js +3 -0
- package/dist/plugins/rspack/index.js +5 -0
- package/dist/plugins/serverless-framework/index.js +12 -1
- package/dist/plugins/serverless-framework/types.d.ts +5 -2
- package/dist/plugins/stencil/index.js +59 -1
- package/dist/plugins/storybook/index.js +7 -0
- package/dist/plugins/svelte/compiler.d.ts +2 -1
- package/dist/plugins/svelte/compiler.js +8 -1
- package/dist/plugins/tailwind/compiler.js +3 -0
- package/dist/plugins/tailwind/index.js +5 -1
- package/dist/plugins/typedoc/index.js +9 -3
- package/dist/plugins/typedoc/types.d.ts +2 -0
- package/dist/plugins/vite/visitors/importMetaGlob.js +1 -8
- package/dist/plugins/vue/compiler.d.ts +2 -1
- package/dist/plugins/vue/compiler.js +8 -1
- package/dist/plugins/webpack/visitors/requireContext.js +2 -13
- package/dist/plugins/yarn/index.js +13 -4
- package/dist/plugins/yarn/types.d.ts +10 -0
- package/dist/plugins/yarn/types.js +1 -0
- package/dist/plugins/zx/visitors/zx.js +4 -4
- package/dist/reporters/compact.js +1 -2
- package/dist/reporters/cycles.d.ts +3 -0
- package/dist/reporters/cycles.js +79 -0
- package/dist/reporters/index.d.ts +1 -0
- package/dist/reporters/index.js +2 -0
- package/dist/reporters/json.d.ts +3 -0
- package/dist/reporters/json.js +2 -1
- package/dist/reporters/symbols.js +1 -2
- package/dist/reporters/util/util.d.ts +3 -1
- package/dist/reporters/util/util.js +5 -1
- package/dist/schema/configuration.d.ts +40 -6
- package/dist/schema/configuration.js +6 -0
- package/dist/schema/plugins.d.ts +10 -0
- package/dist/schema/plugins.js +2 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +2 -0
- package/dist/types/config.d.ts +10 -0
- package/dist/types/issues.d.ts +3 -0
- package/dist/types/module-graph.d.ts +7 -0
- package/dist/types/package-json.d.ts +4 -1
- package/dist/types.d.ts +1 -1
- package/dist/typescript/SourceFileManager.js +3 -2
- package/dist/typescript/ast-nodes.d.ts +4 -1
- package/dist/typescript/ast-nodes.js +60 -2
- package/dist/typescript/comments.js +22 -3
- package/dist/typescript/get-imports-and-exports.js +10 -0
- package/dist/typescript/glob-imports.d.ts +3 -0
- package/dist/typescript/glob-imports.js +49 -0
- package/dist/typescript/resolve-module-names.d.ts +2 -0
- package/dist/typescript/resolve-module-names.js +35 -1
- package/dist/typescript/visitors/calls.js +4 -6
- package/dist/typescript/visitors/imports.js +8 -8
- package/dist/typescript/visitors/script-visitors.js +4 -4
- package/dist/typescript/visitors/walk.js +6 -1
- package/dist/util/cli-arguments.d.ts +2 -1
- package/dist/util/cli-arguments.js +4 -2
- package/dist/util/create-options.d.ts +32 -5
- package/dist/util/create-options.js +4 -1
- package/dist/util/get-included-issue-types.d.ts +1 -0
- package/dist/util/get-included-issue-types.js +4 -2
- package/dist/util/issue-initializers.js +1 -1
- package/dist/util/load-tsconfig.js +17 -4
- package/dist/util/module-graph.js +1 -0
- package/dist/util/modules.js +25 -4
- package/dist/util/scripts.d.ts +7 -0
- package/dist/util/scripts.js +75 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schema.json +40 -1
package/LICENSE
CHANGED
|
@@ -207,6 +207,11 @@ export declare class ConfigurationChief {
|
|
|
207
207
|
entry?: string | string[] | undefined;
|
|
208
208
|
project?: string | string[] | undefined;
|
|
209
209
|
} | undefined;
|
|
210
|
+
eve?: string | boolean | string[] | {
|
|
211
|
+
config?: string | string[] | undefined;
|
|
212
|
+
entry?: string | string[] | undefined;
|
|
213
|
+
project?: string | string[] | undefined;
|
|
214
|
+
} | undefined;
|
|
210
215
|
execa?: string | boolean | string[] | {
|
|
211
216
|
config?: string | string[] | undefined;
|
|
212
217
|
entry?: string | string[] | undefined;
|
|
@@ -227,6 +232,11 @@ export declare class ConfigurationChief {
|
|
|
227
232
|
entry?: string | string[] | undefined;
|
|
228
233
|
project?: string | string[] | undefined;
|
|
229
234
|
} | undefined;
|
|
235
|
+
fumadocs?: string | boolean | string[] | {
|
|
236
|
+
config?: string | string[] | undefined;
|
|
237
|
+
entry?: string | string[] | undefined;
|
|
238
|
+
project?: string | string[] | undefined;
|
|
239
|
+
} | undefined;
|
|
230
240
|
gatsby?: string | boolean | string[] | {
|
|
231
241
|
config?: string | string[] | undefined;
|
|
232
242
|
entry?: string | string[] | undefined;
|
|
@@ -852,7 +862,7 @@ export declare class ConfigurationChief {
|
|
|
852
862
|
ignoreMembers?: (string | RegExp)[] | undefined;
|
|
853
863
|
ignoreUnresolved?: (string | RegExp)[] | undefined;
|
|
854
864
|
ignoreExportsUsedInFile?: boolean | Record<string, boolean | undefined> | undefined;
|
|
855
|
-
ignoreIssues?: Record<string, ("binaries" | "catalog" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[]> | undefined;
|
|
865
|
+
ignoreIssues?: Record<string, ("binaries" | "catalog" | "cycles" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[]> | undefined;
|
|
856
866
|
includeEntryExports?: boolean | undefined;
|
|
857
867
|
};
|
|
858
868
|
getIgnores(workspaceName: string): {
|
|
@@ -899,10 +909,12 @@ export declare class ConfigurationChief {
|
|
|
899
909
|
drizzle?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
900
910
|
eleventy?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
901
911
|
eslint?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
912
|
+
eve?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
902
913
|
execa?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
903
914
|
expo?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
904
915
|
"expressive-code"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
905
916
|
fast?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
917
|
+
fumadocs?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
906
918
|
gatsby?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
907
919
|
"github-action"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
908
920
|
"github-actions"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
|
|
@@ -34,6 +34,7 @@ const defaultConfig = {
|
|
|
34
34
|
ignoreBinaries: [],
|
|
35
35
|
ignoreDependencies: [],
|
|
36
36
|
ignoreFiles: [],
|
|
37
|
+
cycles: {},
|
|
37
38
|
ignoreIssues: {},
|
|
38
39
|
ignoreMembers: [],
|
|
39
40
|
ignoreUnresolved: [],
|
|
@@ -103,6 +104,7 @@ export class ConfigurationChief {
|
|
|
103
104
|
const ignoreMembers = rawConfig.ignoreMembers ?? [];
|
|
104
105
|
const ignoreUnresolved = rawConfig.ignoreUnresolved ?? [];
|
|
105
106
|
const ignoreExportsUsedInFile = rawConfig.ignoreExportsUsedInFile ?? false;
|
|
107
|
+
const cycles = rawConfig.cycles ?? {};
|
|
106
108
|
const ignoreIssues = rawConfig.ignoreIssues ?? {};
|
|
107
109
|
const ignoreWorkspaces = rawConfig.ignoreWorkspaces ?? defaultConfig.ignoreWorkspaces;
|
|
108
110
|
const isIncludeEntryExports = rawConfig.includeEntryExports ?? this.isIncludeEntryExports;
|
|
@@ -116,6 +118,7 @@ export class ConfigurationChief {
|
|
|
116
118
|
return {
|
|
117
119
|
ignore,
|
|
118
120
|
ignoreFiles,
|
|
121
|
+
cycles,
|
|
119
122
|
ignoreBinaries,
|
|
120
123
|
ignoreDependencies,
|
|
121
124
|
ignoreMembers,
|
|
@@ -4,6 +4,7 @@ import type { AsyncCompilers, SyncCompilers } from './compilers/types.ts';
|
|
|
4
4
|
import type { GetImportsAndExportsOptions, IgnoreExportsUsedInFile, PluginVisitorContext, PluginVisitorObject } from './types/config.ts';
|
|
5
5
|
import type { FileNode, ModuleGraph } from './types/module-graph.ts';
|
|
6
6
|
import type { Paths } from './types/project.ts';
|
|
7
|
+
import type { ResolveGlobPattern } from './typescript/resolve-module-names.ts';
|
|
7
8
|
import { SourceFileManager } from './typescript/SourceFileManager.ts';
|
|
8
9
|
import type { MainOptions } from './util/create-options.ts';
|
|
9
10
|
import type { ToSourceFilePath, WorkspaceManifestHandler } from './util/to-source-path.ts';
|
|
@@ -27,6 +28,7 @@ export declare class ProjectPrincipal {
|
|
|
27
28
|
private findWorkspaceManifestImports;
|
|
28
29
|
fileManager: SourceFileManager;
|
|
29
30
|
private resolveModule;
|
|
31
|
+
resolveGlobPattern: ResolveGlobPattern;
|
|
30
32
|
resolvedFiles: Set<string>;
|
|
31
33
|
deletedFiles: Set<string>;
|
|
32
34
|
private onPathAdded;
|
package/dist/ProjectPrincipal.js
CHANGED
|
@@ -6,7 +6,7 @@ import { DEFAULT_EXTENSIONS } from './constants.js';
|
|
|
6
6
|
import { _getImportsAndExports } from './typescript/get-imports-and-exports.js';
|
|
7
7
|
import { createBunShellVisitor } from './typescript/visitors/script-visitors.js';
|
|
8
8
|
import { buildVisitor } from './typescript/visitors/walk.js';
|
|
9
|
-
import { createCustomModuleResolver } from './typescript/resolve-module-names.js';
|
|
9
|
+
import { createCustomModuleResolver, createGlobAliasResolver } from './typescript/resolve-module-names.js';
|
|
10
10
|
import { SourceFileManager } from './typescript/SourceFileManager.js';
|
|
11
11
|
import { compact } from './util/array.js';
|
|
12
12
|
import { timerify } from './util/Performance.js';
|
|
@@ -21,6 +21,7 @@ export class ProjectPrincipal {
|
|
|
21
21
|
sourceText: '',
|
|
22
22
|
addScript: () => { },
|
|
23
23
|
addImport: () => { },
|
|
24
|
+
addImportGlob: () => { },
|
|
24
25
|
markExportRegistered: () => { },
|
|
25
26
|
};
|
|
26
27
|
pluginVisitorObjects = [];
|
|
@@ -37,6 +38,7 @@ export class ProjectPrincipal {
|
|
|
37
38
|
findWorkspaceManifestImports;
|
|
38
39
|
fileManager;
|
|
39
40
|
resolveModule = () => undefined;
|
|
41
|
+
resolveGlobPattern = pattern => [pattern];
|
|
40
42
|
resolvedFiles = new Set();
|
|
41
43
|
deletedFiles = new Set();
|
|
42
44
|
onPathAdded;
|
|
@@ -90,6 +92,7 @@ export class ProjectPrincipal {
|
|
|
90
92
|
const scopedPaths = this.paths.size > 0 ? Array.from(this.paths, ([scope, paths]) => ({ scope, paths })) : undefined;
|
|
91
93
|
const scopedRootDirs = this.rootDirs.size > 0 ? Array.from(this.rootDirs, ([scope, rootDirs]) => ({ scope, rootDirs })) : undefined;
|
|
92
94
|
this.resolveModule = createCustomModuleResolver({ scopedPaths, scopedRootDirs }, customCompilerExtensions, this.toSourceFilePath, this.findWorkspaceManifestImports, this.tsConfigFile);
|
|
95
|
+
this.resolveGlobPattern = createGlobAliasResolver(scopedPaths);
|
|
93
96
|
}
|
|
94
97
|
readFile(filePath) {
|
|
95
98
|
return this.fileManager.readFile(filePath);
|
|
@@ -130,11 +133,9 @@ export class ProjectPrincipal {
|
|
|
130
133
|
}
|
|
131
134
|
async runAsyncCompilers() {
|
|
132
135
|
const add = timerify(this.fileManager.compileAndAddSourceFile.bind(this.fileManager));
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
await add(filePath);
|
|
137
|
-
}
|
|
136
|
+
for (const filePath of this.projectPaths)
|
|
137
|
+
if (this.asyncCompilers.has(extname(filePath)))
|
|
138
|
+
await add(filePath);
|
|
138
139
|
}
|
|
139
140
|
walkAndAnalyze(analyzeFile) {
|
|
140
141
|
this.resolvedFiles.clear();
|
|
@@ -17,6 +17,7 @@ type WorkspaceManagerOptions = {
|
|
|
17
17
|
rootManifest: Manifest | undefined;
|
|
18
18
|
handleInput: HandleInput;
|
|
19
19
|
findWorkspaceByFilePath: (filePath: string) => Workspace | undefined;
|
|
20
|
+
getManifest: (dir: string) => Manifest | undefined;
|
|
20
21
|
readFile: (filePath: string) => string;
|
|
21
22
|
negatedWorkspacePatterns: string[];
|
|
22
23
|
ignoredWorkspacePatterns: string[];
|
|
@@ -38,6 +39,7 @@ export declare class WorkspaceWorker {
|
|
|
38
39
|
dependencies: DependencySet;
|
|
39
40
|
handleInput: HandleInput;
|
|
40
41
|
findWorkspaceByFilePath: (filePath: string) => Workspace | undefined;
|
|
42
|
+
getManifest: (dir: string) => Manifest | undefined;
|
|
41
43
|
readFile: (filePath: string) => string;
|
|
42
44
|
negatedWorkspacePatterns: string[];
|
|
43
45
|
ignoredWorkspacePatterns: string[];
|
|
@@ -47,7 +49,7 @@ export declare class WorkspaceWorker {
|
|
|
47
49
|
enabledPluginsInAncestors: string[];
|
|
48
50
|
cache: CacheConsultant<CacheItem>;
|
|
49
51
|
configFilesMap: Map<string, Map<PluginName, Set<string>>>;
|
|
50
|
-
constructor({ name, dir, config, manifest, dependencies, rootManifest, negatedWorkspacePatterns, ignoredWorkspacePatterns, enabledPluginsInAncestors, handleInput, findWorkspaceByFilePath, readFile, configFilesMap, options, }: WorkspaceManagerOptions);
|
|
52
|
+
constructor({ name, dir, config, manifest, dependencies, rootManifest, negatedWorkspacePatterns, ignoredWorkspacePatterns, enabledPluginsInAncestors, handleInput, findWorkspaceByFilePath, getManifest, readFile, configFilesMap, options, }: WorkspaceManagerOptions);
|
|
51
53
|
init(): Promise<void>;
|
|
52
54
|
private determineEnabledPlugins;
|
|
53
55
|
private getConfigForPlugin;
|
package/dist/WorkspaceWorker.js
CHANGED
|
@@ -32,6 +32,7 @@ export class WorkspaceWorker {
|
|
|
32
32
|
dependencies;
|
|
33
33
|
handleInput;
|
|
34
34
|
findWorkspaceByFilePath;
|
|
35
|
+
getManifest;
|
|
35
36
|
readFile;
|
|
36
37
|
negatedWorkspacePatterns = [];
|
|
37
38
|
ignoredWorkspacePatterns = [];
|
|
@@ -41,7 +42,7 @@ export class WorkspaceWorker {
|
|
|
41
42
|
enabledPluginsInAncestors;
|
|
42
43
|
cache;
|
|
43
44
|
configFilesMap;
|
|
44
|
-
constructor({ name, dir, config, manifest, dependencies, rootManifest, negatedWorkspacePatterns, ignoredWorkspacePatterns, enabledPluginsInAncestors, handleInput, findWorkspaceByFilePath, readFile, configFilesMap, options, }) {
|
|
45
|
+
constructor({ name, dir, config, manifest, dependencies, rootManifest, negatedWorkspacePatterns, ignoredWorkspacePatterns, enabledPluginsInAncestors, handleInput, findWorkspaceByFilePath, getManifest, readFile, configFilesMap, options, }) {
|
|
45
46
|
this.name = name;
|
|
46
47
|
this.dir = dir;
|
|
47
48
|
this.config = config;
|
|
@@ -54,6 +55,7 @@ export class WorkspaceWorker {
|
|
|
54
55
|
this.configFilesMap = configFilesMap;
|
|
55
56
|
this.handleInput = handleInput;
|
|
56
57
|
this.findWorkspaceByFilePath = findWorkspaceByFilePath;
|
|
58
|
+
this.getManifest = getManifest;
|
|
57
59
|
this.readFile = readFile;
|
|
58
60
|
this.options = options;
|
|
59
61
|
this.cache = new CacheConsultant(`plugins-${name}`, options);
|
|
@@ -211,7 +213,8 @@ export class WorkspaceWorker {
|
|
|
211
213
|
const isProduction = this.options.isProduction;
|
|
212
214
|
const knownBinsOnly = false;
|
|
213
215
|
const rootManifest = this.rootManifest;
|
|
214
|
-
const
|
|
216
|
+
const getManifest = this.getManifest;
|
|
217
|
+
const baseOptions = { manifest, rootManifest, cwd, rootCwd, containingFilePath, knownBinsOnly, getManifest };
|
|
215
218
|
const baseScriptOptions = { ...baseOptions, isProduction, enabledPlugins: this.enabledPlugins };
|
|
216
219
|
const [productionScripts, developmentScripts] = getFilteredScripts(manifest.scripts ?? {});
|
|
217
220
|
const inputsFromManifest = _getInputsFromScripts(Object.values(developmentScripts), baseOptions);
|
|
@@ -5,6 +5,7 @@ import { toBinary, toDeferResolve } from '../util/input.js';
|
|
|
5
5
|
import { extractBinary, isValidBinary } from '../util/modules.js';
|
|
6
6
|
import { relative } from '../util/path.js';
|
|
7
7
|
import { truncate } from '../util/string.js';
|
|
8
|
+
import { walkCommands } from '../util/scripts.js';
|
|
8
9
|
import { resolve as fallbackResolve } from './fallback.js';
|
|
9
10
|
import KnownResolvers from './resolvers/index.js';
|
|
10
11
|
import { resolve as resolverFromPlugins } from './plugins.js';
|
|
@@ -46,93 +47,64 @@ export const getDependenciesFromScript = (script, options) => {
|
|
|
46
47
|
const processScript = (s) => {
|
|
47
48
|
collectFunctionNames(s.commands);
|
|
48
49
|
const pending = [];
|
|
49
|
-
const mainDeps =
|
|
50
|
+
const mainDeps = [];
|
|
51
|
+
for (const statement of s.commands) {
|
|
52
|
+
for (const command of walkCommands(statement.command))
|
|
53
|
+
mainDeps.push(...processCommand(command, pending));
|
|
54
|
+
}
|
|
50
55
|
const expansionDeps = pending.flatMap(inner => processScript(inner));
|
|
51
56
|
return [...mainDeps, ...expansionDeps];
|
|
52
57
|
};
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (binary in KnownResolvers) {
|
|
83
|
-
const resolver = KnownResolvers[binary];
|
|
84
|
-
return resolver(binary, args, { ...options, fromArgs });
|
|
85
|
-
}
|
|
86
|
-
if (pluginArgsMap.has(binary)) {
|
|
87
|
-
return [...resolverFromPlugins(binary, args, { ...options, fromArgs }), ...fromNodeOptions];
|
|
88
|
-
}
|
|
89
|
-
if (spawningBinaries.includes(binary)) {
|
|
90
|
-
const rest = node.suffix
|
|
91
|
-
.filter(w => w.text !== '--')
|
|
92
|
-
.map(w => w.text)
|
|
93
|
-
.join(' ');
|
|
94
|
-
return [toBinary(binary), ...getDependenciesFromScript(rest, options)];
|
|
95
|
-
}
|
|
96
|
-
if (binary in Plugins) {
|
|
97
|
-
const inputs = fallbackResolve(binary, args, { ...options, fromArgs });
|
|
98
|
-
if (options.knownBinsOnly)
|
|
99
|
-
for (const input of inputs)
|
|
100
|
-
input.optional = true;
|
|
101
|
-
return [...inputs, ...fromNodeOptions];
|
|
102
|
-
}
|
|
103
|
-
if (options.knownBinsOnly && !text?.startsWith('.'))
|
|
104
|
-
return [];
|
|
105
|
-
return [...fallbackResolve(binary, args, { ...options, fromArgs }), ...fromNodeOptions];
|
|
106
|
-
}
|
|
107
|
-
case 'AndOr':
|
|
108
|
-
case 'Pipeline':
|
|
109
|
-
return node.commands.flatMap(n => getDependenciesFromNode(n, pending));
|
|
110
|
-
case 'If':
|
|
111
|
-
return [
|
|
112
|
-
...getDependenciesFromStatements(node.clause.commands, pending),
|
|
113
|
-
...getDependenciesFromStatements(node.then.commands, pending),
|
|
114
|
-
...(node.else ? getDependenciesFromNode(node.else, pending) : []),
|
|
115
|
-
];
|
|
116
|
-
case 'While':
|
|
117
|
-
return [
|
|
118
|
-
...getDependenciesFromStatements(node.clause.commands, pending),
|
|
119
|
-
...getDependenciesFromStatements(node.body.commands, pending),
|
|
120
|
-
];
|
|
121
|
-
case 'For':
|
|
122
|
-
case 'Select':
|
|
123
|
-
case 'Subshell':
|
|
124
|
-
case 'BraceGroup':
|
|
125
|
-
return getDependenciesFromStatements(node.body.commands, pending);
|
|
126
|
-
case 'CompoundList':
|
|
127
|
-
return getDependenciesFromStatements(node.commands, pending);
|
|
128
|
-
case 'Function':
|
|
129
|
-
case 'Coproc':
|
|
130
|
-
return getDependenciesFromNode(node.body, pending);
|
|
131
|
-
case 'Statement':
|
|
132
|
-
return getDependenciesFromNode(node.command, pending);
|
|
133
|
-
default:
|
|
134
|
-
return [];
|
|
58
|
+
const processCommand = (node, pending) => {
|
|
59
|
+
const text = node.name?.value;
|
|
60
|
+
const binary = text ? extractBinary(text) : text;
|
|
61
|
+
if (node.name)
|
|
62
|
+
collectExpansionScripts(node.name, pending);
|
|
63
|
+
for (const prefix of node.prefix)
|
|
64
|
+
if (prefix.value)
|
|
65
|
+
collectExpansionScripts(prefix.value, pending);
|
|
66
|
+
for (const suffix of node.suffix)
|
|
67
|
+
collectExpansionScripts(suffix, pending);
|
|
68
|
+
if (!binary || binary === '.' || binary === 'source' || binary === '[')
|
|
69
|
+
return [];
|
|
70
|
+
if (binary.startsWith('-') || binary.startsWith('..'))
|
|
71
|
+
return [];
|
|
72
|
+
if (definedFunctions.has(binary))
|
|
73
|
+
return [];
|
|
74
|
+
const args = node.suffix.map(w => w.value);
|
|
75
|
+
if (['!', 'test'].includes(binary))
|
|
76
|
+
return fromArgs(args);
|
|
77
|
+
const fromNodeOptions = node.prefix
|
|
78
|
+
.filter(a => a.name === 'NODE_OPTIONS' && a.value)
|
|
79
|
+
.map(a => a.value.value)
|
|
80
|
+
.map(arg => parseNodeArgs(arg.split(' ')))
|
|
81
|
+
.filter(args => args.require)
|
|
82
|
+
.flatMap(arg => arg.require)
|
|
83
|
+
.map(id => toDeferResolve(id));
|
|
84
|
+
if (binary in KnownResolvers) {
|
|
85
|
+
const resolver = KnownResolvers[binary];
|
|
86
|
+
return resolver(binary, args, { ...options, fromArgs });
|
|
135
87
|
}
|
|
88
|
+
if (pluginArgsMap.has(binary)) {
|
|
89
|
+
return [...resolverFromPlugins(binary, args, { ...options, fromArgs }), ...fromNodeOptions];
|
|
90
|
+
}
|
|
91
|
+
if (spawningBinaries.includes(binary)) {
|
|
92
|
+
const rest = node.suffix
|
|
93
|
+
.filter(w => w.text !== '--')
|
|
94
|
+
.map(w => w.text)
|
|
95
|
+
.join(' ');
|
|
96
|
+
return [toBinary(binary), ...getDependenciesFromScript(rest, options)];
|
|
97
|
+
}
|
|
98
|
+
if (binary in Plugins) {
|
|
99
|
+
const inputs = fallbackResolve(binary, args, { ...options, fromArgs });
|
|
100
|
+
if (options.knownBinsOnly)
|
|
101
|
+
for (const input of inputs)
|
|
102
|
+
input.optional = true;
|
|
103
|
+
return [...inputs, ...fromNodeOptions];
|
|
104
|
+
}
|
|
105
|
+
if (options.knownBinsOnly && !text?.startsWith('.'))
|
|
106
|
+
return [];
|
|
107
|
+
return [...fallbackResolve(binary, args, { ...options, fromArgs }), ...fromNodeOptions];
|
|
136
108
|
};
|
|
137
109
|
try {
|
|
138
110
|
const parsed = parse(script);
|
package/dist/binaries/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SCRIPT_INTERPOLATION } from '../constants.js';
|
|
1
2
|
import { fromBinary, isBinary, isDependency } from '../util/input.js';
|
|
2
3
|
import { timerify } from '../util/Performance.js';
|
|
3
4
|
import { getDependenciesFromScript } from './bash-parser.js';
|
|
@@ -8,6 +9,8 @@ const getInputsFromScripts = (npmScripts, options) => {
|
|
|
8
9
|
for (const input of results) {
|
|
9
10
|
if (!input.specifier)
|
|
10
11
|
continue;
|
|
12
|
+
if (input.specifier.includes(SCRIPT_INTERPOLATION))
|
|
13
|
+
continue;
|
|
11
14
|
if (isDependency(input) && input.specifier.startsWith('http'))
|
|
12
15
|
continue;
|
|
13
16
|
if (isBinary(input) && !/^\b/.test(fromBinary(input)))
|
|
@@ -49,15 +49,16 @@ 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 { manifest, fromArgs, cwd, rootCwd } = options;
|
|
52
|
+
const { manifest, fromArgs, cwd, rootCwd, getManifest } = 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._;
|
|
56
56
|
if (!command && !binary)
|
|
57
57
|
return [];
|
|
58
|
+
const dirManifest = (dir && getManifest(dir)) || manifest;
|
|
58
59
|
const _childArgs = parsed['--'] && parsed['--'].length > 0 ? fromArgs(parsed['--'], { knownBinsOnly: true }) : [];
|
|
59
60
|
if (command === 'run') {
|
|
60
|
-
if (
|
|
61
|
+
if (dirManifest.scriptNames.has(binary))
|
|
61
62
|
return _childArgs;
|
|
62
63
|
const bin = toBinary(binary, { optional: true });
|
|
63
64
|
if (dir)
|
|
@@ -70,7 +71,7 @@ export const resolve = (_binary, args, options) => {
|
|
|
70
71
|
const argsForDlx = args.filter(arg => arg !== 'dlx');
|
|
71
72
|
return resolveDlx(argsForDlx, options);
|
|
72
73
|
}
|
|
73
|
-
if (
|
|
74
|
+
if (dirManifest.scriptNames.has(command) || commands.includes(command))
|
|
74
75
|
return _childArgs;
|
|
75
76
|
const opts = dir ? { cwd: dir } : {};
|
|
76
77
|
return fromArgs(argsFrom(args, command === 'exec' ? binary : command), opts);
|
|
@@ -2,10 +2,12 @@ import type { CompilerSync } from './types.ts';
|
|
|
2
2
|
export declare const fencedCodeBlockMatcher: RegExp;
|
|
3
3
|
export declare const inlineCodeMatcher: RegExp;
|
|
4
4
|
export declare const scriptExtractor: RegExp;
|
|
5
|
+
export declare const styleExtractor: RegExp;
|
|
5
6
|
export declare const blockCommentMatcher: RegExp;
|
|
6
7
|
export declare const lineCommentMatcher: RegExp;
|
|
7
8
|
export declare const importMatcher: RegExp;
|
|
8
9
|
export declare const importsWithinScripts: CompilerSync;
|
|
9
10
|
export declare const scriptBodies: CompilerSync;
|
|
11
|
+
export declare const getStyleLang: (attrs: string) => string | undefined;
|
|
10
12
|
export declare const frontmatterMatcher: RegExp;
|
|
11
13
|
export declare const importsWithinFrontmatter: (text: string, keys?: string[]) => string;
|
|
@@ -1,26 +1,37 @@
|
|
|
1
1
|
export const fencedCodeBlockMatcher = /```[\s\S]*?```/g;
|
|
2
2
|
export const inlineCodeMatcher = /`[^`]+`/g;
|
|
3
3
|
export const scriptExtractor = /<script\b((?:[^>"']|"[^"]*"|'[^']*')*)>([\s\S]*?)<\/script>/gi;
|
|
4
|
+
export const styleExtractor = /<style\b((?:[^>"']|"[^"]*"|'[^']*')*)>([\s\S]*?)<\/style>/gi;
|
|
5
|
+
const langAttrMatcher = /\blang\s*=\s*["']([^"']+)["']/i;
|
|
4
6
|
export const blockCommentMatcher = /\/\*[\s\S]*?\*\//g;
|
|
5
7
|
export const lineCommentMatcher = /^[ \t]*\/\/.*$/gm;
|
|
6
8
|
export const importMatcher = /import(?:\s*\(\s*['"][^'"]+['"][^)]*\)|(?!\s*\()[^'"]+['"][^'"]+['"])/g;
|
|
7
9
|
export const importsWithinScripts = (text) => {
|
|
8
10
|
const scripts = [];
|
|
9
|
-
|
|
11
|
+
scriptExtractor.lastIndex = 0;
|
|
12
|
+
let scriptMatch;
|
|
13
|
+
while ((scriptMatch = scriptExtractor.exec(text))) {
|
|
14
|
+
const scriptBody = scriptMatch[2];
|
|
10
15
|
const body = scriptBody.replace(blockCommentMatcher, '').replace(lineCommentMatcher, '');
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
let importMatch;
|
|
17
|
+
importMatcher.lastIndex = 0;
|
|
18
|
+
while ((importMatch = importMatcher.exec(body)))
|
|
19
|
+
scripts.push(importMatch[0]);
|
|
13
20
|
}
|
|
14
21
|
return scripts.join(';\n');
|
|
15
22
|
};
|
|
16
23
|
export const scriptBodies = (text) => {
|
|
17
24
|
const scripts = [];
|
|
18
|
-
|
|
25
|
+
scriptExtractor.lastIndex = 0;
|
|
26
|
+
let match;
|
|
27
|
+
while ((match = scriptExtractor.exec(text))) {
|
|
28
|
+
const body = match[2];
|
|
19
29
|
if (body)
|
|
20
30
|
scripts.push(body);
|
|
21
31
|
}
|
|
22
32
|
return scripts.join(';\n');
|
|
23
33
|
};
|
|
34
|
+
export const getStyleLang = (attrs) => attrs.match(langAttrMatcher)?.[1]?.toLowerCase();
|
|
24
35
|
export const frontmatterMatcher = /^---\r?\n([\s\S]*?)\r?\n---/;
|
|
25
36
|
export const importsWithinFrontmatter = (text, keys = []) => {
|
|
26
37
|
const frontmatter = text.match(frontmatterMatcher)?.[1];
|
|
@@ -153,6 +153,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
153
153
|
entry?: string | string[] | undefined;
|
|
154
154
|
project?: string | string[] | undefined;
|
|
155
155
|
} | undefined;
|
|
156
|
+
eve?: string | boolean | string[] | {
|
|
157
|
+
config?: string | string[] | undefined;
|
|
158
|
+
entry?: string | string[] | undefined;
|
|
159
|
+
project?: string | string[] | undefined;
|
|
160
|
+
} | undefined;
|
|
156
161
|
execa?: string | boolean | string[] | {
|
|
157
162
|
config?: string | string[] | undefined;
|
|
158
163
|
entry?: string | string[] | undefined;
|
|
@@ -173,6 +178,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
173
178
|
entry?: string | string[] | undefined;
|
|
174
179
|
project?: string | string[] | undefined;
|
|
175
180
|
} | undefined;
|
|
181
|
+
fumadocs?: string | boolean | string[] | {
|
|
182
|
+
config?: string | string[] | undefined;
|
|
183
|
+
entry?: string | string[] | undefined;
|
|
184
|
+
project?: string | string[] | undefined;
|
|
185
|
+
} | undefined;
|
|
176
186
|
gatsby?: string | boolean | string[] | {
|
|
177
187
|
config?: string | string[] | undefined;
|
|
178
188
|
entry?: string | string[] | undefined;
|
|
@@ -789,7 +799,7 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
789
799
|
project?: string | string[] | undefined;
|
|
790
800
|
} | undefined;
|
|
791
801
|
$schema?: string | undefined;
|
|
792
|
-
rules?: Partial<Record<"binaries" | "catalog" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved", "error" | "off" | "warn">> | undefined;
|
|
802
|
+
rules?: Partial<Record<"binaries" | "catalog" | "cycles" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved", "error" | "off" | "warn">> | undefined;
|
|
793
803
|
entry?: string | string[] | undefined;
|
|
794
804
|
project?: string | string[] | undefined;
|
|
795
805
|
paths?: Record<string, string[]> | undefined;
|
|
@@ -800,15 +810,19 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
800
810
|
ignoreMembers?: (string | RegExp)[] | undefined;
|
|
801
811
|
ignoreUnresolved?: (string | RegExp)[] | undefined;
|
|
802
812
|
ignoreExportsUsedInFile?: boolean | Record<string, boolean | undefined> | undefined;
|
|
803
|
-
ignoreIssues?: Record<string, ("binaries" | "catalog" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[]> | undefined;
|
|
813
|
+
ignoreIssues?: Record<string, ("binaries" | "catalog" | "cycles" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[]> | undefined;
|
|
814
|
+
cycles?: {
|
|
815
|
+
allow?: string[][] | undefined;
|
|
816
|
+
dynamicImports?: boolean | undefined;
|
|
817
|
+
} | undefined;
|
|
804
818
|
ignoreWorkspaces?: string[] | undefined;
|
|
805
819
|
includeEntryExports?: boolean | undefined;
|
|
806
820
|
compilers?: Record<string, true | CompilerAsync | CompilerSync> | undefined;
|
|
807
821
|
tags?: string[] | undefined;
|
|
808
822
|
treatConfigHintsAsErrors?: boolean | undefined;
|
|
809
823
|
treatTagHintsAsErrors?: boolean | undefined;
|
|
810
|
-
include?: ("binaries" | "catalog" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[] | undefined;
|
|
811
|
-
exclude?: ("binaries" | "catalog" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[] | undefined;
|
|
824
|
+
include?: ("binaries" | "catalog" | "cycles" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[] | undefined;
|
|
825
|
+
exclude?: ("binaries" | "catalog" | "cycles" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[] | undefined;
|
|
812
826
|
workspaces?: Record<string, {
|
|
813
827
|
angular?: string | boolean | string[] | {
|
|
814
828
|
config?: string | string[] | undefined;
|
|
@@ -960,6 +974,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
960
974
|
entry?: string | string[] | undefined;
|
|
961
975
|
project?: string | string[] | undefined;
|
|
962
976
|
} | undefined;
|
|
977
|
+
eve?: string | boolean | string[] | {
|
|
978
|
+
config?: string | string[] | undefined;
|
|
979
|
+
entry?: string | string[] | undefined;
|
|
980
|
+
project?: string | string[] | undefined;
|
|
981
|
+
} | undefined;
|
|
963
982
|
execa?: string | boolean | string[] | {
|
|
964
983
|
config?: string | string[] | undefined;
|
|
965
984
|
entry?: string | string[] | undefined;
|
|
@@ -980,6 +999,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
980
999
|
entry?: string | string[] | undefined;
|
|
981
1000
|
project?: string | string[] | undefined;
|
|
982
1001
|
} | undefined;
|
|
1002
|
+
fumadocs?: string | boolean | string[] | {
|
|
1003
|
+
config?: string | string[] | undefined;
|
|
1004
|
+
entry?: string | string[] | undefined;
|
|
1005
|
+
project?: string | string[] | undefined;
|
|
1006
|
+
} | undefined;
|
|
983
1007
|
gatsby?: string | boolean | string[] | {
|
|
984
1008
|
config?: string | string[] | undefined;
|
|
985
1009
|
entry?: string | string[] | undefined;
|
|
@@ -1605,11 +1629,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
1605
1629
|
ignoreMembers?: (string | RegExp)[] | undefined;
|
|
1606
1630
|
ignoreUnresolved?: (string | RegExp)[] | undefined;
|
|
1607
1631
|
ignoreExportsUsedInFile?: boolean | Record<string, boolean | undefined> | undefined;
|
|
1608
|
-
ignoreIssues?: Record<string, ("binaries" | "catalog" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[]> | undefined;
|
|
1632
|
+
ignoreIssues?: Record<string, ("binaries" | "catalog" | "cycles" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[]> | undefined;
|
|
1609
1633
|
includeEntryExports?: boolean | undefined;
|
|
1610
1634
|
}> | undefined;
|
|
1611
1635
|
syncCompilers: Record<string, true | CompilerSync>;
|
|
1612
1636
|
asyncCompilers: Record<string, CompilerAsync>;
|
|
1613
1637
|
};
|
|
1614
|
-
export declare const getIncludedCompilers: (syncCompilers: RawSyncCompilers, asyncCompilers: AsyncCompilers, dependencies: DependencySet) => Compilers;
|
|
1638
|
+
export declare const getIncludedCompilers: (syncCompilers: RawSyncCompilers, asyncCompilers: AsyncCompilers, dependencies: DependencySet, onReferencedDependency?: (packageName: string) => void) => Compilers;
|
|
1615
1639
|
export declare const getCompilerExtensions: (compilers: [SyncCompilers, AsyncCompilers]) => string[];
|
package/dist/compilers/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import LESS from './less.js';
|
|
1
2
|
import MDX from './mdx.js';
|
|
2
3
|
import SCSS from './scss.js';
|
|
4
|
+
import STYLUS from './stylus.js';
|
|
3
5
|
const isAsyncCompiler = (fn) => (fn ? fn.constructor.name === 'AsyncFunction' : false);
|
|
4
6
|
export const normalizeCompilerExtension = (ext) => ext.replace(/^\.*/, '.');
|
|
5
7
|
export const partitionCompilers = (rawLocalConfig) => {
|
|
@@ -26,16 +28,29 @@ export const partitionCompilers = (rawLocalConfig) => {
|
|
|
26
28
|
}
|
|
27
29
|
return { ...rawLocalConfig, syncCompilers, asyncCompilers };
|
|
28
30
|
};
|
|
29
|
-
const compilers =
|
|
30
|
-
['.mdx', MDX
|
|
31
|
-
['.sass',
|
|
32
|
-
['.
|
|
33
|
-
]
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
for (const
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
const compilers = [
|
|
32
|
+
{ extensions: ['.mdx'], ...MDX },
|
|
33
|
+
{ extensions: ['.sass', '.scss'], ...SCSS },
|
|
34
|
+
{ extensions: ['.less'], ...LESS },
|
|
35
|
+
{ extensions: ['.styl', '.stylus'], ...STYLUS },
|
|
36
|
+
];
|
|
37
|
+
export const getIncludedCompilers = (syncCompilers, asyncCompilers, dependencies, onReferencedDependency) => {
|
|
38
|
+
for (const { extensions, dependencies: compilerDependencies, compiler } of compilers) {
|
|
39
|
+
let hasCompilerDependency = false;
|
|
40
|
+
for (const dependency of compilerDependencies) {
|
|
41
|
+
if (dependencies.has(dependency)) {
|
|
42
|
+
hasCompilerDependency = true;
|
|
43
|
+
if (onReferencedDependency)
|
|
44
|
+
onReferencedDependency(dependency);
|
|
45
|
+
else
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
for (const extension of extensions) {
|
|
50
|
+
const existingCompiler = syncCompilers.get(extension);
|
|
51
|
+
if (existingCompiler === true || (existingCompiler === undefined && hasCompilerDependency)) {
|
|
52
|
+
syncCompilers.set(extension, compiler);
|
|
53
|
+
}
|
|
39
54
|
}
|
|
40
55
|
}
|
|
41
56
|
return [syncCompilers, asyncCompilers];
|