Skip to content

Commit ea9bad7

Browse files
committed
Skip loading files at configuration level
1 parent b39b38d commit ea9bad7

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/index.ts

+11-9
Original file line numberDiff line numberDiff line change
@@ -203,17 +203,16 @@ export function register (opts: Options = {}): Register {
203203

204204
// Require the TypeScript compiler and configuration.
205205
const cwd = process.cwd()
206-
const { compilerOptions, project, skipProject } = options
206+
const { compilerOptions, project, skipProject, files } = options
207207
const typeCheck = options.typeCheck === true || options.transpileOnly !== true
208208
const compiler = require.resolve(options.compiler || 'typescript', { paths: [cwd] })
209209
const ts: typeof _ts = require(compiler)
210210
const transformers = options.transformers || undefined
211211
const readFile = options.readFile || ts.sys.readFile
212212
const fileExists = options.fileExists || ts.sys.fileExists
213-
const config = readConfig(cwd, ts, fileExists, readFile, compilerOptions, project, skipProject)
213+
const config = readConfig(cwd, ts, fileExists, readFile, compilerOptions, project, skipProject, files)
214214
const configDiagnosticList = filterDiagnostics(config.errors, ignoreDiagnostics)
215215
const extensions = ['.ts', '.tsx']
216-
const fileNames = options.files ? config.fileNames : []
217216

218217
const diagnosticHost: _ts.FormatDiagnosticsHost = {
219218
getNewLine: () => EOL,
@@ -241,7 +240,7 @@ export function register (opts: Options = {}): Register {
241240
}
242241

243242
// Initialize files from TypeScript into project.
244-
for (const path of fileNames) memoryCache.versions[path] = 1
243+
for (const path of config.fileNames) memoryCache.versions[path] = 1
245244

246245
/**
247246
* Get the extension for a transpiled file.
@@ -454,15 +453,16 @@ function readConfig (
454453
fileExists: (path: string) => boolean,
455454
readFile: (path: string) => string | undefined,
456455
compilerOptions?: object,
457-
project?: string | null,
458-
noProject?: boolean | null
456+
project?: string,
457+
skipProject?: boolean | null,
458+
includeFiles?: boolean | null
459459
): _ts.ParsedCommandLine {
460460
let config: any = { compilerOptions: {} }
461461
let basePath = normalizeSlashes(cwd)
462462
let configFileName: string | undefined = undefined
463463

464464
// Read project configuration when available.
465-
if (!noProject) {
465+
if (!skipProject) {
466466
configFileName = project
467467
? normalizeSlashes(resolve(cwd, project))
468468
: ts.findConfigFile(normalizeSlashes(cwd), fileExists)
@@ -481,8 +481,10 @@ function readConfig (
481481
}
482482

483483
// Remove resolution of "files".
484-
config.files = []
485-
config.includes = []
484+
if (!includeFiles) {
485+
config.files = []
486+
config.includes = []
487+
}
486488

487489
// Override default configuration options `ts-node` requires.
488490
config.compilerOptions = Object.assign({}, config.compilerOptions, compilerOptions, TS_NODE_COMPILER_OPTIONS)

0 commit comments

Comments
 (0)