Skip to content

Commit

Permalink
Skip loading files at configuration level
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Jan 22, 2019
1 parent b39b38d commit ea9bad7
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,16 @@ export function register (opts: Options = {}): Register {

// Require the TypeScript compiler and configuration.
const cwd = process.cwd()
const { compilerOptions, project, skipProject } = options
const { compilerOptions, project, skipProject, files } = options
const typeCheck = options.typeCheck === true || options.transpileOnly !== true
const compiler = require.resolve(options.compiler || 'typescript', { paths: [cwd] })
const ts: typeof _ts = require(compiler)
const transformers = options.transformers || undefined
const readFile = options.readFile || ts.sys.readFile
const fileExists = options.fileExists || ts.sys.fileExists
const config = readConfig(cwd, ts, fileExists, readFile, compilerOptions, project, skipProject)
const config = readConfig(cwd, ts, fileExists, readFile, compilerOptions, project, skipProject, files)
const configDiagnosticList = filterDiagnostics(config.errors, ignoreDiagnostics)
const extensions = ['.ts', '.tsx']
const fileNames = options.files ? config.fileNames : []

const diagnosticHost: _ts.FormatDiagnosticsHost = {
getNewLine: () => EOL,
Expand Down Expand Up @@ -241,7 +240,7 @@ export function register (opts: Options = {}): Register {
}

// Initialize files from TypeScript into project.
for (const path of fileNames) memoryCache.versions[path] = 1
for (const path of config.fileNames) memoryCache.versions[path] = 1

/**
* Get the extension for a transpiled file.
Expand Down Expand Up @@ -454,15 +453,16 @@ function readConfig (
fileExists: (path: string) => boolean,
readFile: (path: string) => string | undefined,
compilerOptions?: object,
project?: string | null,
noProject?: boolean | null
project?: string,
skipProject?: boolean | null,
includeFiles?: boolean | null
): _ts.ParsedCommandLine {
let config: any = { compilerOptions: {} }
let basePath = normalizeSlashes(cwd)
let configFileName: string | undefined = undefined

// Read project configuration when available.
if (!noProject) {
if (!skipProject) {
configFileName = project
? normalizeSlashes(resolve(cwd, project))
: ts.findConfigFile(normalizeSlashes(cwd), fileExists)
Expand All @@ -481,8 +481,10 @@ function readConfig (
}

// Remove resolution of "files".
config.files = []
config.includes = []
if (!includeFiles) {
config.files = []
config.includes = []
}

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

0 comments on commit ea9bad7

Please sign in to comment.