UNPKG

22.9 kBSource Map (JSON)View Raw
1{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":";;;AAAA,+BAA8C;AAE9C,mCAOiB;AAEjB,iDAAmD;AACnD,2CAAmE;AACnE,iCAKgB;AAEhB;;GAEG;AACH,MAAM,wBAAwB,GAAG;IAC/B,SAAS,EAAE,IAAI;IACf,eAAe,EAAE,KAAK;IACtB,aAAa,EAAE,IAAI;IACnB,WAAW,EAAE,KAAK;IAClB,MAAM,EAAE,KAAK;IACb,MAAM,EAAE,UAAU;CACnB,CAAC;AAEF;;GAEG;AACH,SAAS,SAAS,CAAC,EAAY,EAAE,MAA6B;IAC5D,sDAAsD;IACtD,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC;IAC1B,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;IAChC,OAAO,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC;IACrC,OAAO,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC;IACrC,OAAO,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC;IAE1C,iDAAiD;IACjD,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE;QACvC,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC;KAC7C;IAED,qGAAqG;IACrG,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE;QACvC,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;KAChD;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,gBAAgB;AAChB,SAAgB,iBAAiB,CAAC,UAAyB;;IACzD,MAAM,GAAG,GAAG,IAAA,cAAO,EACjB,MAAA,MAAA,MAAA,UAAU,CAAC,GAAG,mCAAI,UAAU,CAAC,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aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC;IAC3B,uEAAuE;IACvE,gIAAgI;IAChI,MAAM,OAAO,GAAG,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,CAAC,MAAM,CAAC,CAAC,CAAC,0FAA0F;IAEhI,uBAAuB;IAEvB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AACjE,CAAC;AA3BD,kDA2BC","sourcesContent":["import { resolve, dirname, join } from 'path';\nimport type * as _ts from 'typescript';\nimport {\n CreateOptions,\n DEFAULTS,\n OptionBasePaths,\n RegisterOptions,\n TSCommon,\n TsConfigOptions,\n} from './index';\nimport type { TSInternal } from './ts-compiler-types';\nimport { createTsInternals } from './ts-internals';\nimport { getDefaultTsconfigJsonForNodeVersion } from './tsconfigs';\nimport {\n assign,\n attemptRequireWithV8CompileCache,\n createProjectLocalResolveHelper,\n getBasePathForProjectLocalDependencyResolution,\n} from './util';\n\n/**\n * TypeScript compiler option values required by `ts-node` which cannot be overridden.\n */\nconst TS_NODE_COMPILER_OPTIONS = {\n sourceMap: true,\n inlineSourceMap: false,\n inlineSources: true,\n declaration: false,\n noEmit: false,\n outDir: '.ts-node',\n};\n\n/*\n * Do post-processing on config options to support `ts-node`.\n */\nfunction fixConfig(ts: TSCommon, config: _ts.ParsedCommandLine) {\n // Delete options that *should not* be passed through.\n delete config.options.out;\n delete config.options.outFile;\n delete config.options.composite;\n delete config.options.declarationDir;\n delete config.options.declarationMap;\n delete config.options.emitDeclarationOnly;\n\n // Target ES5 output by default (instead of ES3).\n if (config.options.target === undefined) {\n config.options.target = ts.ScriptTarget.ES5;\n }\n\n // Target CommonJS modules by default (instead of magically switching to ES6 when the target is ES6).\n if (config.options.module === undefined) {\n config.options.module = ts.ModuleKind.CommonJS;\n }\n\n return config;\n}\n\n/** @internal */\nexport function findAndReadConfig(rawOptions: CreateOptions) {\n const cwd = resolve(\n rawOptions.cwd ?? rawOptions.dir ?? DEFAULTS.cwd ?? process.cwd()\n );\n const compilerName = rawOptions.compiler ?? DEFAULTS.compiler;\n\n // Compute minimum options to read the config file.\n let projectLocalResolveDir = getBasePathForProjectLocalDependencyResolution(\n undefined,\n rawOptions.projectSearchDir,\n rawOptions.project,\n cwd\n );\n let { compiler, ts } = resolveAndLoadCompiler(\n compilerName,\n projectLocalResolveDir\n );\n\n // Read config file and merge new options between env and CLI options.\n const { configFilePath, config, tsNodeOptionsFromTsconfig, optionBasePaths } =\n readConfig(cwd, ts, rawOptions);\n\n const options = assign<RegisterOptions>(\n {},\n DEFAULTS,\n tsNodeOptionsFromTsconfig || {},\n { optionBasePaths },\n rawOptions\n );\n options.require = [\n ...(tsNodeOptionsFromTsconfig.require || []),\n ...(rawOptions.require || []),\n ];\n\n // Re-resolve the compiler in case it has changed.\n // Compiler is loaded relative to tsconfig.json, so tsconfig discovery may cause us to load a\n // different compiler than we did above, even if the name has not changed.\n if (configFilePath) {\n projectLocalResolveDir = getBasePathForProjectLocalDependencyResolution(\n configFilePath,\n rawOptions.projectSearchDir,\n rawOptions.project,\n cwd\n );\n ({ compiler } = resolveCompiler(\n options.compiler,\n optionBasePaths.compiler ?? projectLocalResolveDir\n ));\n }\n\n return {\n options,\n config,\n projectLocalResolveDir,\n optionBasePaths,\n configFilePath,\n cwd,\n compiler,\n };\n}\n\n/**\n * Load TypeScript configuration. Returns the parsed TypeScript config and\n * any `ts-node` options specified in the config file.\n *\n * Even when a tsconfig.json is not loaded, this function still handles merging\n * compilerOptions from various sources: API, environment variables, etc.\n *\n * @internal\n */\nexport function readConfig(\n cwd: string,\n ts: TSCommon,\n rawApiOptions: CreateOptions\n): {\n /**\n * Path of tsconfig file if one was loaded\n */\n configFilePath: string | undefined;\n /**\n * Parsed TypeScript configuration with compilerOptions merged from all other sources (env vars, etc)\n */\n config: _ts.ParsedCommandLine;\n /**\n * ts-node options pulled from `tsconfig.json`, NOT merged with any other sources. Merging must happen outside\n * this function.\n */\n tsNodeOptionsFromTsconfig: TsConfigOptions;\n optionBasePaths: OptionBasePaths;\n} {\n // Ordered [a, b, c] where config a extends b extends c\n const configChain: Array<{\n config: any;\n basePath: string;\n configPath: string;\n }> = [];\n let config: any = { compilerOptions: {} };\n let basePath = cwd;\n let configFilePath: string | undefined = undefined;\n const projectSearchDir = resolve(cwd, rawApiOptions.projectSearchDir ?? cwd);\n\n const {\n fileExists = ts.sys.fileExists,\n readFile = ts.sys.readFile,\n skipProject = DEFAULTS.skipProject,\n project = DEFAULTS.project,\n tsTrace = DEFAULTS.tsTrace,\n } = rawApiOptions;\n\n // Read project configuration when available.\n if (!skipProject) {\n if (project) {\n const resolved = resolve(cwd, project);\n const nested = join(resolved, 'tsconfig.json');\n configFilePath = fileExists(nested) ? nested : resolved;\n } else {\n configFilePath = ts.findConfigFile(projectSearchDir, fileExists);\n }\n\n if (configFilePath) {\n let pathToNextConfigInChain = configFilePath;\n const tsInternals = createTsInternals(ts);\n const errors: Array<_ts.Diagnostic> = [];\n\n // Follow chain of \"extends\"\n while (true) {\n const result = ts.readConfigFile(pathToNextConfigInChain, readFile);\n\n // Return diagnostics.\n if (result.error) {\n return {\n configFilePath,\n config: { errors: [result.error], fileNames: [], options: {} },\n tsNodeOptionsFromTsconfig: {},\n optionBasePaths: {},\n };\n }\n\n const c = result.config;\n const bp = dirname(pathToNextConfigInChain);\n configChain.push({\n config: c,\n basePath: bp,\n configPath: pathToNextConfigInChain,\n });\n\n if (c.extends == null) break;\n const resolvedExtendedConfigPath = tsInternals.getExtendsConfigPath(\n c.extends,\n {\n fileExists,\n readDirectory: ts.sys.readDirectory,\n readFile,\n useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,\n trace: tsTrace,\n },\n bp,\n errors,\n (ts as unknown as TSInternal).createCompilerDiagnostic\n );\n if (errors.length) {\n return {\n configFilePath,\n config: { errors, fileNames: [], options: {} },\n tsNodeOptionsFromTsconfig: {},\n optionBasePaths: {},\n };\n }\n if (resolvedExtendedConfigPath == null) break;\n pathToNextConfigInChain = resolvedExtendedConfigPath;\n }\n\n ({ config, basePath } = configChain[0]);\n }\n }\n\n // Merge and fix ts-node options that come from tsconfig.json(s)\n const tsNodeOptionsFromTsconfig: TsConfigOptions = {};\n const optionBasePaths: OptionBasePaths = {};\n for (let i = configChain.length - 1; i >= 0; i--) {\n const { config, basePath, configPath } = configChain[i];\n const options = filterRecognizedTsConfigTsNodeOptions(\n config['ts-node']\n ).recognized;\n\n // Some options are relative to the config file, so must be converted to absolute paths here\n if (options.require) {\n // Modules are found relative to the tsconfig file, not the `dir` option\n const tsconfigRelativeResolver = createProjectLocalResolveHelper(\n dirname(configPath)\n );\n options.require = options.require.map((path: string) =>\n tsconfigRelativeResolver(path, false)\n );\n }\n if (options.scopeDir) {\n options.scopeDir = resolve(basePath, options.scopeDir!);\n }\n\n // Downstream code uses the basePath; we do not do that here.\n if (options.moduleTypes) {\n optionBasePaths.moduleTypes = basePath;\n }\n if (options.transpiler != null) {\n optionBasePaths.transpiler = basePath;\n }\n if (options.compiler != null) {\n optionBasePaths.compiler = basePath;\n }\n if (options.swc != null) {\n optionBasePaths.swc = basePath;\n }\n\n assign(tsNodeOptionsFromTsconfig, options);\n }\n\n // Remove resolution of \"files\".\n const files =\n rawApiOptions.files ?? tsNodeOptionsFromTsconfig.files ?? DEFAULTS.files;\n\n // Only if a config file is *not* loaded, load an implicit configuration from @tsconfig/bases\n const skipDefaultCompilerOptions = configFilePath != null;\n const defaultCompilerOptionsForNodeVersion = skipDefaultCompilerOptions\n ? undefined\n : {\n ...getDefaultTsconfigJsonForNodeVersion(ts).compilerOptions,\n types: ['node'],\n };\n\n // Merge compilerOptions from all sources\n config.compilerOptions = Object.assign(\n {},\n // automatically-applied options from @tsconfig/bases\n defaultCompilerOptionsForNodeVersion,\n // tsconfig.json \"compilerOptions\"\n config.compilerOptions,\n // from env var\n DEFAULTS.compilerOptions,\n // tsconfig.json \"ts-node\": \"compilerOptions\"\n tsNodeOptionsFromTsconfig.compilerOptions,\n // passed programmatically\n rawApiOptions.compilerOptions,\n // overrides required by ts-node, cannot be changed\n TS_NODE_COMPILER_OPTIONS\n );\n\n const fixedConfig = fixConfig(\n ts,\n ts.parseJsonConfigFileContent(\n config,\n {\n fileExists,\n readFile,\n // Only used for globbing \"files\", \"include\", \"exclude\"\n // When `files` option disabled, we want to avoid the fs calls\n readDirectory: files ? ts.sys.readDirectory : () => [],\n useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,\n },\n basePath,\n undefined,\n configFilePath\n )\n );\n\n return {\n configFilePath,\n config: fixedConfig,\n tsNodeOptionsFromTsconfig,\n optionBasePaths,\n };\n}\n\n/**\n * Load the typescript compiler. It is required to load the tsconfig but might\n * be changed by the tsconfig, so we have to do this twice.\n * @internal\n */\nexport function resolveAndLoadCompiler(\n name: string | undefined,\n relativeToPath: string\n) {\n const { compiler } = resolveCompiler(name, relativeToPath);\n const ts = loadCompiler(compiler);\n return { compiler, ts };\n}\n\nfunction resolveCompiler(name: string | undefined, relativeToPath: string) {\n const projectLocalResolveHelper =\n createProjectLocalResolveHelper(relativeToPath);\n const compiler = projectLocalResolveHelper(name || 'typescript', true);\n return { compiler };\n}\n\n/** @internal */\nexport function loadCompiler(compiler: string): TSCommon {\n return attemptRequireWithV8CompileCache(require, compiler);\n}\n\n/**\n * Given the raw \"ts-node\" sub-object from a tsconfig, return an object with only the properties\n * recognized by \"ts-node\"\n */\nfunction filterRecognizedTsConfigTsNodeOptions(jsonObject: any): {\n recognized: TsConfigOptions;\n unrecognized: any;\n} {\n if (jsonObject == null) return { recognized: {}, unrecognized: {} };\n const {\n compiler,\n compilerHost,\n compilerOptions,\n emit,\n files,\n ignore,\n ignoreDiagnostics,\n logError,\n preferTsExts,\n pretty,\n require,\n skipIgnore,\n transpileOnly,\n typeCheck,\n transpiler,\n scope,\n scopeDir,\n moduleTypes,\n experimentalReplAwait,\n swc,\n experimentalResolver,\n esm,\n experimentalSpecifierResolution,\n experimentalTsImportSpecifiers,\n ...unrecognized\n } = jsonObject as TsConfigOptions;\n const filteredTsConfigOptions = {\n compiler,\n compilerHost,\n compilerOptions,\n emit,\n experimentalReplAwait,\n files,\n ignore,\n ignoreDiagnostics,\n logError,\n preferTsExts,\n pretty,\n require,\n skipIgnore,\n transpileOnly,\n typeCheck,\n transpiler,\n scope,\n scopeDir,\n moduleTypes,\n swc,\n experimentalResolver,\n esm,\n experimentalSpecifierResolution,\n experimentalTsImportSpecifiers,\n };\n // Use the typechecker to make sure this implementation has the correct set of properties\n const catchExtraneousProps: keyof TsConfigOptions =\n null as any as keyof typeof filteredTsConfigOptions;\n const catchMissingProps: keyof typeof filteredTsConfigOptions =\n null as any as keyof TsConfigOptions;\n return { recognized: filteredTsConfigOptions, unrecognized };\n}\n\n/** @internal */\nexport const ComputeAsCommonRootOfFiles = Symbol();\n\n/**\n * Some TS compiler options have defaults which are not provided by TS's config parsing functions.\n * This function centralizes the logic for computing those defaults.\n * @internal\n */\nexport function getTsConfigDefaults(\n config: _ts.ParsedCommandLine,\n basePath: string,\n _files: string[] | undefined,\n _include: string[] | undefined,\n _exclude: string[] | undefined\n) {\n const { composite = false } = config.options;\n let rootDir: string | typeof ComputeAsCommonRootOfFiles =\n config.options.rootDir!;\n if (rootDir == null) {\n if (composite) rootDir = basePath;\n // Return this symbol to avoid computing from `files`, which would require fs calls\n else rootDir = ComputeAsCommonRootOfFiles;\n }\n const { outDir = rootDir } = config.options;\n // Docs are wrong: https://www.typescriptlang.org/tsconfig#include\n // Docs say **, but it's actually **/*; compiler throws error for **\n const include = _files ? [] : ['**/*'];\n const files = _files ?? [];\n // Docs are misleading: https://www.typescriptlang.org/tsconfig#exclude\n // Docs say it excludes node_modules, bower_components, jspm_packages, but actually those are excluded via behavior of \"include\"\n const exclude = _exclude ?? [outDir]; // TODO technically, outDir is absolute path, but exclude should be relative glob pattern?\n\n // TODO compute baseUrl\n\n return { rootDir, outDir, include, files, exclude, composite };\n}\n"]}
\No newline at end of file