Skip to content

Commit 587c6bb

Browse files
committedNov 11, 2023
Respect ignore option for entry paths from manifest
1 parent a77aa07 commit 587c6bb

File tree

6 files changed

+16
-10
lines changed

6 files changed

+16
-10
lines changed
 

‎src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export const main = async (unresolvedConfiguration: CommandLineOptions) => {
160160

161161
const sharedGlobOptions = { cwd, workingDir: dir, gitignore, ignore: worker.getIgnorePatterns() };
162162

163-
const entryPathsFromManifest = await getEntryPathFromManifest(cwd, dir, manifest);
163+
const entryPathsFromManifest = await getEntryPathFromManifest(manifest, sharedGlobOptions);
164164
debugLogArray(name, 'Entry paths in package.json', entryPathsFromManifest);
165165
principal.addEntryPaths(entryPathsFromManifest);
166166

‎src/util/glob.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const glob = async ({ cwd, workingDir = cwd, patterns, ignore = [], gitignore =
4444

4545
const ignorePatterns = compact([...ignore, ...GLOBAL_IGNORE_PATTERNS]);
4646

47-
debugLogObject(relativePath || ROOT_WORKSPACE_NAME, `Glob options`, { cwd, globPatterns, ignorePatterns });
47+
debugLogObject(relativePath || ROOT_WORKSPACE_NAME, `Glob options`, { cwd, globPatterns, ignorePatterns, gitignore });
4848

4949
return globby(globPatterns, {
5050
cwd,

‎src/util/modules.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ export const getPackageFromDefinitelyTyped = (typedDependency: string) => {
3939
return typedDependency;
4040
};
4141

42-
export const getEntryPathFromManifest = (cwd: string, dir: string, manifest: PackageJson) => {
42+
export const getEntryPathFromManifest = (
43+
manifest: PackageJson,
44+
sharedGlobOptions: { cwd: string; workingDir: string; gitignore: boolean; ignore: string[] }
45+
) => {
4346
const { main, bin, exports } = manifest;
4447

4548
const entryPaths: Set<string> = new Set();
@@ -55,8 +58,11 @@ export const getEntryPathFromManifest = (cwd: string, dir: string, manifest: Pac
5558
getStringValues(exports).forEach(item => entryPaths.add(item));
5659
}
5760

58-
// Glob, as we only want source files that exist and not (generated) files that are .gitignore'd
59-
return _glob({ cwd, workingDir: dir, patterns: Array.from(entryPaths) });
61+
// Use glob, as we only want source files that:
62+
// - exist
63+
// - are not (generated) files that are .gitignore'd
64+
// - do not match configured `ignore` patterns
65+
return _glob({ ...sharedGlobOptions, patterns: Array.from(entryPaths) });
6066
};
6167

6268
// Strip `?search` and other proprietary directives from the specifier (e.g. https://webpack.js.org/concepts/loaders/)

‎test/helpers/baseArguments.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const baseArguments = {
22
cwd: '.',
3-
gitignore: false,
3+
gitignore: true,
44
isStrict: false,
55
isProduction: false,
66
isIgnoreInternal: false,

‎test/unresolved-rtl.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test('Report unresolved imports (rtl)', async () => {
1515

1616
assert.deepEqual(counters, {
1717
...baseCounters,
18-
processed: 2,
19-
total: 2,
18+
processed: 1,
19+
total: 1,
2020
});
2121
});

‎test/unresolved.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test('Report unresolved imports', async () => {
2121
...baseCounters,
2222
unlisted: 2,
2323
unresolved: 1,
24-
processed: 2,
25-
total: 2,
24+
processed: 1,
25+
total: 1,
2626
});
2727
});

0 commit comments

Comments
 (0)
Please sign in to comment.