knip 5.48.0 → 5.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/graph/build.js +56 -26
- package/dist/plugins/ava/index.js +1 -1
- package/dist/plugins/cucumber/index.js +1 -1
- package/dist/plugins/cypress/index.js +1 -1
- package/dist/plugins/github-actions/index.js +1 -1
- package/dist/plugins/jest/index.js +1 -1
- package/dist/plugins/ladle/index.js +1 -1
- package/dist/plugins/mocha/index.js +2 -2
- package/dist/plugins/node/index.js +1 -1
- package/dist/plugins/preconstruct/index.js +1 -1
- package/dist/plugins/react-cosmos/index.js +1 -1
- package/dist/plugins/react-router/index.js +1 -1
- package/dist/plugins/storybook/index.js +1 -1
- package/dist/plugins/tanstack-router/index.js +1 -1
- package/dist/plugins/unbuild/index.js +1 -1
- package/dist/plugins/vitest/index.js +1 -1
- package/dist/util/glob-core.js +1 -1
- package/dist/util/input.d.ts +1 -0
- package/dist/util/object.d.ts +0 -1
- package/dist/util/object.js +0 -16
- package/dist/util/package-json.d.ts +1 -3
- package/dist/util/package-json.js +28 -5
- package/dist/util/to-source-path.js +9 -12
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/graph/build.js
CHANGED
|
@@ -69,9 +69,10 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
69
69
|
const ignore = worker.getIgnorePatterns();
|
|
70
70
|
const sharedGlobOptions = { cwd, dir, gitignore };
|
|
71
71
|
collector.addIgnorePatterns(ignore.map(pattern => join(cwd, pattern)));
|
|
72
|
-
const entryPathsFromManifest = await getEntryPathsFromManifest(manifest, {
|
|
73
|
-
for (const
|
|
74
|
-
inputs.add(
|
|
72
|
+
const entryPathsFromManifest = await getEntryPathsFromManifest(manifest, { cwd: dir, ignore });
|
|
73
|
+
for (const filePath of entryPathsFromManifest) {
|
|
74
|
+
inputs.add(toProductionEntry(toSourceFilePath(filePath) ?? filePath));
|
|
75
|
+
}
|
|
75
76
|
const principal = factory.createPrincipal({
|
|
76
77
|
cwd: dir,
|
|
77
78
|
paths: config.paths,
|
|
@@ -88,18 +89,32 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
88
89
|
});
|
|
89
90
|
const inputsFromPlugins = await worker.runPlugins();
|
|
90
91
|
for (const id of inputsFromPlugins)
|
|
91
|
-
inputs.add(id);
|
|
92
|
+
inputs.add(Object.assign(id, { skipExportsAnalysis: true }));
|
|
92
93
|
enabledPluginsStore.set(name, worker.enabledPlugins);
|
|
93
|
-
const
|
|
94
|
-
const
|
|
94
|
+
const entryPatterns = new Set();
|
|
95
|
+
const entryPatternsSkipExports = new Set();
|
|
96
|
+
const productionPatterns = new Set();
|
|
97
|
+
const productionPatternsSkipExports = new Set();
|
|
95
98
|
const projectFilePatterns = new Set();
|
|
96
99
|
for (const input of inputs) {
|
|
97
100
|
const specifier = input.specifier;
|
|
98
101
|
if (isEntry(input)) {
|
|
99
|
-
|
|
102
|
+
const relativePath = isAbsolute(specifier) ? relative(dir, specifier) : specifier;
|
|
103
|
+
if (!input.skipExportsAnalysis) {
|
|
104
|
+
entryPatterns.add(relativePath);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
entryPatternsSkipExports.add(relativePath);
|
|
108
|
+
}
|
|
100
109
|
}
|
|
101
110
|
else if (isProductionEntry(input)) {
|
|
102
|
-
|
|
111
|
+
const relativePath = isAbsolute(specifier) ? relative(dir, specifier) : specifier;
|
|
112
|
+
if (!input.skipExportsAnalysis) {
|
|
113
|
+
productionPatterns.add(relativePath);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
productionPatternsSkipExports.add(relativePath);
|
|
117
|
+
}
|
|
103
118
|
}
|
|
104
119
|
else if (isProject(input)) {
|
|
105
120
|
projectFilePatterns.add(isAbsolute(specifier) ? relative(dir, specifier) : specifier);
|
|
@@ -109,11 +124,11 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
109
124
|
const resolvedFilePath = getReferencedInternalFilePath(input, ws);
|
|
110
125
|
if (resolvedFilePath) {
|
|
111
126
|
if (isDeferResolveProductionEntry(input)) {
|
|
112
|
-
|
|
127
|
+
productionPatternsSkipExports.add(resolvedFilePath);
|
|
113
128
|
}
|
|
114
129
|
else if (isDeferResolveEntry(input)) {
|
|
115
130
|
if (!isProduction || !input.optional)
|
|
116
|
-
|
|
131
|
+
entryPatternsSkipExports.add(resolvedFilePath);
|
|
117
132
|
}
|
|
118
133
|
else {
|
|
119
134
|
principal.addEntryPath(resolvedFilePath, { skipExportsAnalysis: true });
|
|
@@ -122,21 +137,27 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
122
137
|
}
|
|
123
138
|
}
|
|
124
139
|
if (isProduction) {
|
|
125
|
-
const negatedEntryPatterns =
|
|
140
|
+
const negatedEntryPatterns = [...entryPatterns, ...entryPatternsSkipExports].map(negate);
|
|
126
141
|
{
|
|
127
|
-
const label = 'entry';
|
|
142
|
+
const label = 'entry paths';
|
|
128
143
|
const patterns = worker.getProductionEntryFilePatterns(negatedEntryPatterns);
|
|
129
144
|
const workspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns, gitignore: false, label });
|
|
130
145
|
principal.addEntryPaths(workspaceEntryPaths);
|
|
131
146
|
}
|
|
132
147
|
{
|
|
133
|
-
const label = 'production
|
|
134
|
-
const patterns = Array.from(
|
|
148
|
+
const label = 'production entry paths from plugins (skip exports analysis)';
|
|
149
|
+
const patterns = Array.from(productionPatternsSkipExports);
|
|
135
150
|
const pluginWorkspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns, label });
|
|
136
151
|
principal.addEntryPaths(pluginWorkspaceEntryPaths, { skipExportsAnalysis: true });
|
|
137
152
|
}
|
|
138
153
|
{
|
|
139
|
-
const label = '
|
|
154
|
+
const label = 'production entry paths from plugins';
|
|
155
|
+
const patterns = Array.from(productionPatterns);
|
|
156
|
+
const pluginWorkspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns, label });
|
|
157
|
+
principal.addEntryPaths(pluginWorkspaceEntryPaths);
|
|
158
|
+
}
|
|
159
|
+
{
|
|
160
|
+
const label = 'project paths';
|
|
140
161
|
const patterns = worker.getProductionProjectFilePatterns(negatedEntryPatterns);
|
|
141
162
|
const workspaceProjectPaths = await _glob({ ...sharedGlobOptions, patterns, label });
|
|
142
163
|
for (const projectPath of workspaceProjectPaths)
|
|
@@ -145,33 +166,42 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
145
166
|
}
|
|
146
167
|
else {
|
|
147
168
|
{
|
|
148
|
-
const label = 'entry';
|
|
169
|
+
const label = 'entry paths';
|
|
149
170
|
const patterns = worker.getEntryFilePatterns();
|
|
150
171
|
const workspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns, gitignore: false, label });
|
|
151
172
|
principal.addEntryPaths(workspaceEntryPaths);
|
|
152
173
|
}
|
|
153
174
|
{
|
|
154
|
-
const label = '
|
|
155
|
-
const patterns = worker.
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
175
|
+
const label = 'entry paths from plugins (skip exports analysis)';
|
|
176
|
+
const patterns = worker.getPluginEntryFilePatterns([
|
|
177
|
+
...entryPatternsSkipExports,
|
|
178
|
+
...productionPatternsSkipExports,
|
|
179
|
+
]);
|
|
180
|
+
const pluginWorkspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns, label });
|
|
181
|
+
principal.addEntryPaths(pluginWorkspaceEntryPaths, { skipExportsAnalysis: true });
|
|
159
182
|
}
|
|
160
183
|
{
|
|
161
|
-
const label = '
|
|
162
|
-
const patterns = worker.getPluginEntryFilePatterns([...
|
|
184
|
+
const label = 'entry paths from plugins';
|
|
185
|
+
const patterns = worker.getPluginEntryFilePatterns([...entryPatterns, ...productionPatterns]);
|
|
163
186
|
const pluginWorkspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns, label });
|
|
164
|
-
principal.addEntryPaths(pluginWorkspaceEntryPaths
|
|
187
|
+
principal.addEntryPaths(pluginWorkspaceEntryPaths);
|
|
188
|
+
}
|
|
189
|
+
{
|
|
190
|
+
const label = 'project paths';
|
|
191
|
+
const patterns = worker.getProjectFilePatterns([...productionPatternsSkipExports, ...projectFilePatterns]);
|
|
192
|
+
const workspaceProjectPaths = await _glob({ ...sharedGlobOptions, patterns, label });
|
|
193
|
+
for (const projectPath of workspaceProjectPaths)
|
|
194
|
+
principal.addProjectPath(projectPath);
|
|
165
195
|
}
|
|
166
196
|
{
|
|
167
|
-
const label = '
|
|
197
|
+
const label = 'project paths from plugins';
|
|
168
198
|
const patterns = worker.getPluginProjectFilePatterns();
|
|
169
199
|
const pluginWorkspaceProjectPaths = await _glob({ ...sharedGlobOptions, patterns, label });
|
|
170
200
|
for (const projectPath of pluginWorkspaceProjectPaths)
|
|
171
201
|
principal.addProjectPath(projectPath);
|
|
172
202
|
}
|
|
173
203
|
{
|
|
174
|
-
const label = 'plugin configuration';
|
|
204
|
+
const label = 'plugin configuration paths (skip exports analysis)';
|
|
175
205
|
const patterns = worker.getPluginConfigPatterns();
|
|
176
206
|
const configurationEntryPaths = await _glob({ ...sharedGlobOptions, patterns, label });
|
|
177
207
|
principal.addEntryPaths(configurationEntryPaths, { skipExportsAnalysis: true });
|
|
@@ -19,7 +19,7 @@ const entry = [
|
|
|
19
19
|
const resolveEntryPaths = localConfig => {
|
|
20
20
|
if (typeof localConfig === 'function')
|
|
21
21
|
localConfig = localConfig();
|
|
22
|
-
return (localConfig?.files ?? entry).map(toEntry);
|
|
22
|
+
return (localConfig?.files ?? entry).map(id => toEntry(id));
|
|
23
23
|
};
|
|
24
24
|
const resolveConfig = async (localConfig, options) => {
|
|
25
25
|
if (typeof localConfig === 'function')
|
|
@@ -6,7 +6,7 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
|
6
6
|
const config = ['cucumber.{json,yaml,yml,js,cjs,mjs}'];
|
|
7
7
|
const entry = ['features/**/*.@(js|cjs|mjs)'];
|
|
8
8
|
const resolveEntryPaths = config => {
|
|
9
|
-
return (config?.import ? config.import : []).map(toEntry);
|
|
9
|
+
return (config?.import ? config.import : []).map(id => toEntry(id));
|
|
10
10
|
};
|
|
11
11
|
const resolveConfig = config => {
|
|
12
12
|
const formatters = config?.format ? config.format : [];
|
|
@@ -19,7 +19,7 @@ const resolveEntryPaths = async (localConfig) => {
|
|
|
19
19
|
return [
|
|
20
20
|
...(specPatterns.length > 0 ? specPatterns : TEST_FILE_PATTERNS),
|
|
21
21
|
...(supportFiles.length > 0 ? supportFiles : SUPPORT_FILE_PATTERNS),
|
|
22
|
-
].map(toEntry);
|
|
22
|
+
].map(id => toEntry(id));
|
|
23
23
|
};
|
|
24
24
|
const resolveConfig = async (config, options) => {
|
|
25
25
|
const inputs = await resolveDependencies(config, options);
|
|
@@ -41,7 +41,7 @@ const resolveConfig = async (config, options) => {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
return [...inputs, ...getActionDependencies(config, options).map(toEntry)];
|
|
44
|
+
return [...inputs, ...getActionDependencies(config, options).map(id => toEntry(id))];
|
|
45
45
|
};
|
|
46
46
|
export default {
|
|
47
47
|
title,
|
|
@@ -81,7 +81,7 @@ const resolveEntryPaths = async (localConfig, options) => {
|
|
|
81
81
|
const rootDir = localConfig.rootDir ?? configFileDir;
|
|
82
82
|
const replaceRootDir = (name) => name.replace(/<rootDir>/, rootDir);
|
|
83
83
|
if (localConfig.testMatch)
|
|
84
|
-
return localConfig.testMatch.map(replaceRootDir).map(toEntry);
|
|
84
|
+
return localConfig.testMatch.map(replaceRootDir).map(id => toEntry(id));
|
|
85
85
|
return entry.map(id => toEntry(id));
|
|
86
86
|
};
|
|
87
87
|
const resolveConfig = async (localConfig, options) => {
|
|
@@ -14,7 +14,7 @@ const resolveEntryPaths = (localConfig, options) => {
|
|
|
14
14
|
const localStories = typeof localConfig.stories === 'string' ? [localConfig.stories] : localConfig.stories;
|
|
15
15
|
const viteConfig = localConfig.viteConfig ? [toAbsolute(localConfig.viteConfig, options.cwd)] : [];
|
|
16
16
|
const patterns = [...restEntry, ...(localStories ?? stories), ...viteConfig];
|
|
17
|
-
return patterns.map(toEntry);
|
|
17
|
+
return patterns.map(id => toEntry(id));
|
|
18
18
|
};
|
|
19
19
|
const resolveConfig = async (localConfig, options) => {
|
|
20
20
|
if (localConfig.viteConfig) {
|
|
@@ -7,11 +7,11 @@ const config = ['.mocharc.{js,cjs,json,jsonc,yml,yaml}', 'package.json'];
|
|
|
7
7
|
const entry = ['**/test/*.{js,cjs,mjs}'];
|
|
8
8
|
const resolveEntryPaths = localConfig => {
|
|
9
9
|
const entryPatterns = localConfig.spec ? [localConfig.spec].flat() : [];
|
|
10
|
-
return [...entryPatterns].map(toEntry);
|
|
10
|
+
return [...entryPatterns].map(id => toEntry(id));
|
|
11
11
|
};
|
|
12
12
|
const resolveConfig = localConfig => {
|
|
13
13
|
const require = localConfig.require ? [localConfig.require].flat() : [];
|
|
14
|
-
return [...require].map(toEntry);
|
|
14
|
+
return [...require].map(id => toEntry(id));
|
|
15
15
|
};
|
|
16
16
|
const args = {
|
|
17
17
|
nodeImportArgs: true,
|
|
@@ -8,7 +8,7 @@ const resolveEntryPaths = localConfig => {
|
|
|
8
8
|
const entries = [toProductionEntry('server.js')];
|
|
9
9
|
if (scripts && Object.keys(scripts).some(script => /(?<=^|\s)node\s(.*)--test/.test(scripts[script]))) {
|
|
10
10
|
const patterns = ['**/*{.,-,_}test.?(c|m)js', '**/test-*.?(c|m)js', '**/test.?(c|m)js', '**/test/**/*.?(c|m)js'];
|
|
11
|
-
entries.push(...patterns.map(toEntry));
|
|
11
|
+
entries.push(...patterns.map(id => toEntry(id)));
|
|
12
12
|
}
|
|
13
13
|
return entries;
|
|
14
14
|
};
|
|
@@ -5,7 +5,7 @@ const enablers = ['@preconstruct/cli'];
|
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
6
|
const config = ['package.json'];
|
|
7
7
|
const resolveEntryPaths = async (config) => {
|
|
8
|
-
return (config.entrypoints ?? []).map(toEntry);
|
|
8
|
+
return (config.entrypoints ?? []).map(id => toEntry(id));
|
|
9
9
|
};
|
|
10
10
|
export default {
|
|
11
11
|
title,
|
|
@@ -16,7 +16,7 @@ const resolveEntryPaths = async (localConfig) => {
|
|
|
16
16
|
join(fixturesDir ?? '', `**/*.${fixtureFileSuffix ?? 'fixture'}.${ext}`),
|
|
17
17
|
join(fixturesDir ?? '', `**/${fixtureFileSuffix ?? 'fixture'}.${ext}`),
|
|
18
18
|
];
|
|
19
|
-
return [...entries, ...decoratorEntry].map(toEntry);
|
|
19
|
+
return [...entries, ...decoratorEntry].map(id => toEntry(id));
|
|
20
20
|
};
|
|
21
21
|
const resolveConfig = async (localConfig) => {
|
|
22
22
|
return (localConfig?.plugins ?? []).map(toDeferResolve);
|
|
@@ -21,7 +21,7 @@ const resolveEntryPaths = async (localConfig, options) => {
|
|
|
21
21
|
...(options.config.entry ?? restEntry),
|
|
22
22
|
...(relativePatterns && relativePatterns.length > 0 ? relativePatterns : stories),
|
|
23
23
|
];
|
|
24
|
-
return patterns.map(toEntry);
|
|
24
|
+
return patterns.map(id => toEntry(id));
|
|
25
25
|
};
|
|
26
26
|
const resolveConfig = async (localConfig) => {
|
|
27
27
|
const addons = localConfig.addons?.map(addon => (typeof addon === 'string' ? addon : addon.name)) ?? [];
|
|
@@ -2,7 +2,7 @@ import { toEntry } from '../../util/input.js';
|
|
|
2
2
|
import { extname, join } from '../../util/path.js';
|
|
3
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
4
|
import { getCustomConfig } from './resolveFromAST.js';
|
|
5
|
-
const title = '
|
|
5
|
+
const title = 'TanStack Router';
|
|
6
6
|
const enablers = ['@tanstack/react-router', '@tanstack/router-plugin', '@tanstack/router-cli'];
|
|
7
7
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
8
8
|
const config = [
|
|
@@ -84,7 +84,7 @@ export const resolveConfig = async (localConfig, options) => {
|
|
|
84
84
|
const dir = join(options.configFileDir, cfg.test?.root ?? '.');
|
|
85
85
|
const deps = (typeof entry === 'string' ? [entry] : Object.values(entry))
|
|
86
86
|
.map(specifier => join(dir, specifier))
|
|
87
|
-
.map(toEntry);
|
|
87
|
+
.map(id => toEntry(id));
|
|
88
88
|
for (const dependency of deps)
|
|
89
89
|
inputs.add(dependency);
|
|
90
90
|
}
|
package/dist/util/glob-core.js
CHANGED
|
@@ -187,7 +187,7 @@ export async function glob(patterns, options) {
|
|
|
187
187
|
const ignore = cachedIgnores || compact(_ignore);
|
|
188
188
|
const { dir, label, ...fgOptions } = { ...options, ignore };
|
|
189
189
|
const paths = await fg.glob(patterns, fgOptions);
|
|
190
|
-
debugLogObject(relative(options.cwd, dir) || ROOT_WORKSPACE_NAME, label ? `Finding ${label}
|
|
190
|
+
debugLogObject(relative(options.cwd, dir) || ROOT_WORKSPACE_NAME, label ? `Finding ${label}` : 'Finding paths', () => ({ patterns, ...fgOptions, ignore: cachedIgnores ? `// identical to ${dir}` : ignore, paths }));
|
|
191
191
|
if (willCache)
|
|
192
192
|
cachedGlobIgnores.set(options.dir, ignore);
|
|
193
193
|
return paths;
|
package/dist/util/input.d.ts
CHANGED
package/dist/util/object.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export declare const getValuesByKeyDeep: (obj: any, key: string) => unknown[];
|
|
2
2
|
export declare const findByKeyDeep: <T>(obj: any, key: string) => T[];
|
|
3
|
-
export declare const getStringValues: (obj: any) => string[];
|
|
4
3
|
export declare const getKeysByValue: <T>(obj: T, value: unknown) => (keyof T)[];
|
|
5
4
|
export declare const get: <T>(obj: T, path: string) => any;
|
package/dist/util/object.js
CHANGED
|
@@ -32,22 +32,6 @@ export const findByKeyDeep = (obj, key) => {
|
|
|
32
32
|
}
|
|
33
33
|
return objects;
|
|
34
34
|
};
|
|
35
|
-
export const getStringValues = (obj) => {
|
|
36
|
-
if (typeof obj === 'string')
|
|
37
|
-
return [obj];
|
|
38
|
-
let values = [];
|
|
39
|
-
for (const prop in obj) {
|
|
40
|
-
if (obj[prop]) {
|
|
41
|
-
if (typeof obj[prop] === 'string') {
|
|
42
|
-
values.push(obj[prop]);
|
|
43
|
-
}
|
|
44
|
-
else if (typeof obj[prop] === 'object') {
|
|
45
|
-
values = values.concat(getStringValues(obj[prop]));
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return values;
|
|
50
|
-
};
|
|
51
35
|
export const getKeysByValue = (obj, value) => {
|
|
52
36
|
const keys = [];
|
|
53
37
|
for (const key in obj) {
|
|
@@ -7,10 +7,8 @@ interface ExtendedPackageJson extends PackageJson {
|
|
|
7
7
|
}
|
|
8
8
|
export declare const load: (filePath: string) => Promise<ExtendedPackageJson>;
|
|
9
9
|
export declare const save: (filePath: string, content: ExtendedPackageJson) => Promise<void>;
|
|
10
|
-
export declare const getEntryPathsFromManifest: (manifest: PackageJson,
|
|
10
|
+
export declare const getEntryPathsFromManifest: (manifest: PackageJson, options: {
|
|
11
11
|
cwd: string;
|
|
12
|
-
dir: string;
|
|
13
|
-
gitignore: boolean;
|
|
14
12
|
ignore: string[];
|
|
15
13
|
}) => Promise<string[]>;
|
|
16
14
|
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { _glob } from './glob.js';
|
|
3
|
-
import { getStringValues } from './object.js';
|
|
4
3
|
const INDENT = Symbol.for('indent');
|
|
5
4
|
const NEWLINE = Symbol.for('newline');
|
|
6
5
|
const DEFAULT_NEWLINE = '\n';
|
|
@@ -19,6 +18,23 @@ const parseJson = (raw) => {
|
|
|
19
18
|
}
|
|
20
19
|
return result;
|
|
21
20
|
};
|
|
21
|
+
const getEntriesFromExports = (obj) => {
|
|
22
|
+
if (typeof obj === 'string')
|
|
23
|
+
return [obj];
|
|
24
|
+
let values = [];
|
|
25
|
+
for (const prop in obj) {
|
|
26
|
+
if (typeof obj[prop] === 'string') {
|
|
27
|
+
values.push(obj[prop]);
|
|
28
|
+
}
|
|
29
|
+
else if (obj[prop] === null) {
|
|
30
|
+
values.push(`!${prop}`);
|
|
31
|
+
}
|
|
32
|
+
else if (typeof obj[prop] === 'object') {
|
|
33
|
+
values = values.concat(getEntriesFromExports(obj[prop]));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return values;
|
|
37
|
+
};
|
|
22
38
|
export const load = async (filePath) => {
|
|
23
39
|
const file = await readFile(filePath, 'utf8');
|
|
24
40
|
return parseJson(file);
|
|
@@ -30,7 +46,7 @@ export const save = async (filePath, content) => {
|
|
|
30
46
|
const fileContent = `${JSON.stringify(content, null, space)}\n`.replace(/\n/g, EOL);
|
|
31
47
|
await writeFile(filePath, fileContent);
|
|
32
48
|
};
|
|
33
|
-
export const getEntryPathsFromManifest = (manifest,
|
|
49
|
+
export const getEntryPathsFromManifest = (manifest, options) => {
|
|
34
50
|
const { main, module, browser, bin, exports, types, typings } = manifest;
|
|
35
51
|
const entryPaths = new Set();
|
|
36
52
|
if (typeof main === 'string')
|
|
@@ -47,12 +63,19 @@ export const getEntryPathsFromManifest = (manifest, sharedGlobOptions) => {
|
|
|
47
63
|
entryPaths.add(id);
|
|
48
64
|
}
|
|
49
65
|
if (exports) {
|
|
50
|
-
for (const item of
|
|
51
|
-
|
|
66
|
+
for (const item of getEntriesFromExports(exports)) {
|
|
67
|
+
if (item === './*')
|
|
68
|
+
continue;
|
|
69
|
+
const expanded = item
|
|
70
|
+
.replace(/\/\*$/, '/**')
|
|
71
|
+
.replace(/\/\*\./, '/**/*.')
|
|
72
|
+
.replace(/\/\*\//, '/**/');
|
|
73
|
+
entryPaths.add(expanded);
|
|
74
|
+
}
|
|
52
75
|
}
|
|
53
76
|
if (typeof types === 'string')
|
|
54
77
|
entryPaths.add(types);
|
|
55
78
|
if (typeof typings === 'string')
|
|
56
79
|
entryPaths.add(typings);
|
|
57
|
-
return _glob({
|
|
80
|
+
return _glob({ patterns: Array.from(entryPaths), ...options, gitignore: false, label: 'package.json entry paths' });
|
|
58
81
|
};
|
|
@@ -14,25 +14,22 @@ export const augmentWorkspace = (workspace, dir, compilerOptions) => {
|
|
|
14
14
|
};
|
|
15
15
|
export const getToSourcePathHandler = (chief) => {
|
|
16
16
|
const toSourceMapCache = new Map();
|
|
17
|
-
|
|
17
|
+
return (filePath) => {
|
|
18
18
|
if (!isInternal(filePath) || hasJSExt.test(filePath) || hasTSExt.test(filePath))
|
|
19
19
|
return;
|
|
20
20
|
if (toSourceMapCache.has(filePath))
|
|
21
21
|
return toSourceMapCache.get(filePath);
|
|
22
22
|
const workspace = chief.findWorkspaceByFilePath(filePath);
|
|
23
|
-
if (workspace) {
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return srcFilePath;
|
|
32
|
-
}
|
|
23
|
+
if (workspace?.srcDir && workspace.outDir) {
|
|
24
|
+
if (filePath.startsWith(workspace.outDir)) {
|
|
25
|
+
const pattern = filePath.replace(workspace.outDir, workspace.srcDir).replace(matchExt, defaultExtensions);
|
|
26
|
+
const [srcFilePath] = fastGlob.sync(pattern);
|
|
27
|
+
toSourceMapCache.set(filePath, srcFilePath);
|
|
28
|
+
if (srcFilePath && srcFilePath !== filePath) {
|
|
29
|
+
debugLog('*', `Source mapping ${toRelative(filePath)} → ${toRelative(srcFilePath)}`);
|
|
30
|
+
return srcFilePath;
|
|
33
31
|
}
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
34
|
};
|
|
37
|
-
return toSourcePath;
|
|
38
35
|
};
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.
|
|
1
|
+
export declare const version = "5.49.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.
|
|
1
|
+
export const version = '5.49.0';
|