ts-loader
Advanced tools
Comparing version 8.3.0 to 8.4.0
# Changelog | ||
## v8.4.0 | ||
* [fix: cater for change in resolveTypeReferenceDirective API in 4.7](https://github.com/TypeStrong/ts-loader/pull/1446) - thanks @dragomirtitian | ||
* This is a backport from v9.2.7 for webpack 4 compatibility | ||
## v8.3.0 | ||
@@ -4,0 +9,0 @@ |
@@ -53,3 +53,3 @@ "use strict"; | ||
const { languageService, loaderOptions, compiler, program } = instance; | ||
const errors = utils_1.formatErrors(program === undefined | ||
const errors = (0, utils_1.formatErrors)(program === undefined | ||
? languageService.getCompilerOptionsDiagnostics() | ||
@@ -99,6 +99,6 @@ : program.getOptionsDiagnostics(), loaderOptions, instance.colors, compiler, { file: configFilePath || 'tsconfig.json' }, compilation.compiler.context); | ||
modifiedFiles.size) { | ||
const reverseDependencyGraph = utils_1.populateReverseDependencyGraph(instance); | ||
const reverseDependencyGraph = (0, utils_1.populateReverseDependencyGraph)(instance); | ||
// check all modified files, and all dependants | ||
for (const modifiedFileName of modifiedFiles.keys()) { | ||
for (const fileName of utils_1.collectAllDependants(reverseDependencyGraph, modifiedFileName).keys()) { | ||
for (const fileName of (0, utils_1.collectAllDependants)(reverseDependencyGraph, modifiedFileName).keys()) { | ||
const fileToCheckForErrors = files.get(fileName) || otherFiles.get(fileName); | ||
@@ -117,3 +117,3 @@ addFileToCheckForErrors(fileName, fileToCheckForErrors); | ||
function addFileToCheckForErrors(filePath, file) { | ||
if (!utils_1.isReferencedFile(instance, filePath)) { | ||
if (!(0, utils_1.isReferencedFile)(instance, filePath)) { | ||
filesToCheckForErrors.set(filePath, file); | ||
@@ -129,3 +129,3 @@ } | ||
// I’m pretty sure this will never be undefined here | ||
const program = utils_1.ensureProgram(instance); | ||
const program = (0, utils_1.ensureProgram)(instance); | ||
for (const [filePath, { fileName }] of filesToCheckForErrors.entries()) { | ||
@@ -154,3 +154,3 @@ if (fileName.match(filePathRegex) === null) { | ||
// append errors | ||
const formattedErrors = utils_1.formatErrors(errors, loaderOptions, instance.colors, compiler, { module }, compilation.compiler.context); | ||
const formattedErrors = (0, utils_1.formatErrors)(errors, loaderOptions, instance.colors, compiler, { module }, compilation.compiler.context); | ||
formattedErrors.forEach(error => { | ||
@@ -169,3 +169,3 @@ if (module.addError) { | ||
// otherwise it's a more generic error | ||
const formattedErrors = utils_1.formatErrors(errors, loaderOptions, instance.colors, compiler, { file: fileName }, compilation.compiler.context); | ||
const formattedErrors = (0, utils_1.formatErrors)(errors, loaderOptions, instance.colors, compiler, { file: fileName }, compilation.compiler.context); | ||
compilation.errors.push(...formattedErrors); | ||
@@ -189,3 +189,3 @@ } | ||
// append errors | ||
const formattedErrors = utils_1.formatErrors(perFileDiagnostics, loaderOptions, instance.colors, compiler, { module }, compilation.compiler.context); | ||
const formattedErrors = (0, utils_1.formatErrors)(perFileDiagnostics, loaderOptions, instance.colors, compiler, { module }, compilation.compiler.context); | ||
formattedErrors.forEach(error => { | ||
@@ -204,3 +204,3 @@ if (module.addError) { | ||
// otherwise it's a more generic error | ||
const formattedErrors = utils_1.formatErrors(perFileDiagnostics, loaderOptions, instance.colors, compiler, { file: path.resolve(perFileDiagnostics[0].file.fileName) }, compilation.compiler.context); | ||
const formattedErrors = (0, utils_1.formatErrors)(perFileDiagnostics, loaderOptions, instance.colors, compiler, { file: path.resolve(perFileDiagnostics[0].file.fileName) }, compilation.compiler.context); | ||
compilation.errors.push(...formattedErrors); | ||
@@ -210,3 +210,3 @@ } | ||
// Add global solution errors | ||
compilation.errors.push(...utils_1.formatErrors(diagnostics.global, instance.loaderOptions, instance.colors, instance.compiler, { file: 'tsconfig.json' }, compilation.compiler.context)); | ||
compilation.errors.push(...(0, utils_1.formatErrors)(diagnostics.global, instance.loaderOptions, instance.colors, instance.compiler, { file: 'tsconfig.json' }, compilation.compiler.context)); | ||
} | ||
@@ -221,3 +221,3 @@ /** | ||
} | ||
addDeclarationFilesAsAsset(instances_1.getEmitOutput(instance, fileName), compilation); | ||
addDeclarationFilesAsAsset((0, instances_1.getEmitOutput)(instance, fileName), compilation); | ||
} | ||
@@ -250,3 +250,3 @@ } | ||
// Ensure emit is complete | ||
instances_1.getEmitFromWatchHost(instance); | ||
(0, instances_1.getEmitFromWatchHost)(instance); | ||
if (instance.watchHost.tsbuildinfo) { | ||
@@ -277,3 +277,3 @@ outputFileToAsset(instance.watchHost.tsbuildinfo, compilation); | ||
function removeCompilationTSLoaderErrors(compilation, loaderOptions) { | ||
compilation.errors = compilation.errors.filter(error => error.loaderSource !== utils_1.tsLoaderSource(loaderOptions)); | ||
compilation.errors = compilation.errors.filter(error => error.loaderSource !== (0, utils_1.tsLoaderSource)(loaderOptions)); | ||
} | ||
@@ -291,9 +291,9 @@ function removeModuleTSLoaderError(module, loaderOptions) { | ||
Array.from(errors || []) | ||
.filter((error) => error.loaderSource !== utils_1.tsLoaderSource(loaderOptions)) | ||
.filter((error) => error.loaderSource !== (0, utils_1.tsLoaderSource)(loaderOptions)) | ||
.forEach(error => module.addError(error)); | ||
} | ||
else { | ||
module.errors = module.errors.filter(error => error.loaderSource !== utils_1.tsLoaderSource(loaderOptions)); | ||
module.errors = module.errors.filter(error => error.loaderSource !== (0, utils_1.tsLoaderSource)(loaderOptions)); | ||
} | ||
} | ||
//# sourceMappingURL=after-compile.js.map |
@@ -47,3 +47,3 @@ "use strict"; | ||
skipLibCheck: true, | ||
suppressOutputPathCheck: true, | ||
suppressOutputPathCheck: true, // This is why: https://github.com/Microsoft/TypeScript/issues/7363 | ||
}); | ||
@@ -50,0 +50,0 @@ // if `module` is not specified and not using ES6+ target, default to CJS module output |
@@ -20,3 +20,3 @@ "use strict"; | ||
if (configFile.error !== undefined) { | ||
configFileError = utils_1.formatErrors([configFile.error], loaderOptions, colors, compiler, { file: configFilePath }, loader.context)[0]; | ||
configFileError = (0, utils_1.formatErrors)([configFile.error], loaderOptions, colors, compiler, { file: configFilePath }, loader.context)[0]; | ||
} | ||
@@ -85,3 +85,3 @@ } | ||
function getConfigParseResult(compiler, configFile, basePath, configFilePath, loaderOptions) { | ||
const configParseResult = compiler.parseJsonConfigFileContent(configFile.config, Object.assign(Object.assign({}, compiler.sys), { useCaseSensitiveFileNames: utils_1.useCaseSensitiveFileNames(compiler, loaderOptions) }), basePath, getCompilerOptionsToExtend(compiler, loaderOptions, basePath, configFilePath || 'tsconfig.json')); | ||
const configParseResult = compiler.parseJsonConfigFileContent(configFile.config, Object.assign(Object.assign({}, compiler.sys), { useCaseSensitiveFileNames: (0, utils_1.useCaseSensitiveFileNames)(compiler, loaderOptions) }), basePath, getCompilerOptionsToExtend(compiler, loaderOptions, basePath, configFilePath || 'tsconfig.json')); | ||
if (!loaderOptions.projectReferences) { | ||
@@ -99,7 +99,7 @@ configParseResult.projectReferences = undefined; | ||
function getParsedCommandLine(compiler, loaderOptions, configFilePath) { | ||
const result = compiler.getParsedCommandLineOfConfigFile(configFilePath, getCompilerOptionsToExtend(compiler, loaderOptions, path.dirname(configFilePath), configFilePath), Object.assign(Object.assign({}, compiler.sys), { useCaseSensitiveFileNames: utils_1.useCaseSensitiveFileNames(compiler, loaderOptions), | ||
const result = compiler.getParsedCommandLineOfConfigFile(configFilePath, getCompilerOptionsToExtend(compiler, loaderOptions, path.dirname(configFilePath), configFilePath), Object.assign(Object.assign({}, compiler.sys), { useCaseSensitiveFileNames: (0, utils_1.useCaseSensitiveFileNames)(compiler, loaderOptions), | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
onUnRecoverableConfigFileDiagnostic: () => { } }), extendedConfigCache); | ||
if (result) { | ||
result.options = compilerSetup_1.getCompilerOptions(result, compiler); | ||
result.options = (0, compilerSetup_1.getCompilerOptions)(result, compiler); | ||
} | ||
@@ -106,0 +106,0 @@ return result; |
@@ -16,3 +16,3 @@ "use strict"; | ||
const options = getLoaderOptions(this); | ||
const instanceOrError = instances_1.getTypeScriptInstance(options, this); | ||
const instanceOrError = (0, instances_1.getTypeScriptInstance)(options, this); | ||
if (instanceOrError.error !== undefined) { | ||
@@ -23,12 +23,12 @@ callback(new Error(instanceOrError.error.message)); | ||
const instance = instanceOrError.instance; | ||
instances_1.buildSolutionReferences(instance, this); | ||
(0, instances_1.buildSolutionReferences)(instance, this); | ||
successLoader(this, contents, callback, instance); | ||
} | ||
function successLoader(loaderContext, contents, callback, instance) { | ||
instances_1.initializeInstance(loaderContext, instance); | ||
instances_1.reportTranspileErrors(instance, loaderContext); | ||
(0, instances_1.initializeInstance)(loaderContext, instance); | ||
(0, instances_1.reportTranspileErrors)(instance, loaderContext); | ||
const rawFilePath = path.normalize(loaderContext.resourcePath); | ||
const filePath = instance.loaderOptions.appendTsSuffixTo.length > 0 || | ||
instance.loaderOptions.appendTsxSuffixTo.length > 0 | ||
? utils_1.appendSuffixesIfMatch({ | ||
? (0, utils_1.appendSuffixesIfMatch)({ | ||
'.ts': instance.loaderOptions.appendTsSuffixTo, | ||
@@ -47,3 +47,3 @@ '.tsx': instance.loaderOptions.appendTsxSuffixTo, | ||
setModuleMeta(loaderContext, instance, fileVersion); | ||
const additionalGuidance = utils_1.isReferencedFile(instance, filePath) | ||
const additionalGuidance = (0, utils_1.isReferencedFile)(instance, filePath) | ||
? ' The most common cause for this is having errors when building referenced projects.' | ||
@@ -184,3 +184,3 @@ : !instance.loaderOptions.allowTsInNodeModules && | ||
}, loaderOptions); | ||
options.ignoreDiagnostics = utils_1.arrify(options.ignoreDiagnostics).map(Number); | ||
options.ignoreDiagnostics = (0, utils_1.arrify)(options.ignoreDiagnostics).map(Number); | ||
options.logLevel = options.logLevel.toUpperCase(); | ||
@@ -204,3 +204,3 @@ options.instance = instanceName; | ||
if (file !== undefined) { | ||
if (!utils_1.isReferencedFile(instance, filePath)) { | ||
if (!(0, utils_1.isReferencedFile)(instance, filePath)) { | ||
instance.otherFiles.delete(key); | ||
@@ -216,3 +216,3 @@ instance.files.set(key, file); | ||
file = { fileName: filePath, version: 0 }; | ||
if (!utils_1.isReferencedFile(instance, filePath)) { | ||
if (!(0, utils_1.isReferencedFile)(instance, filePath)) { | ||
instance.files.set(key, file); | ||
@@ -232,3 +232,3 @@ instance.changedFilesList = true; | ||
// See https://github.com/TypeStrong/ts-loader/issues/943 | ||
if (!utils_1.isReferencedFile(instance, filePath) && | ||
if (!(0, utils_1.isReferencedFile)(instance, filePath) && | ||
!instance.rootFileNames.has(filePath) && | ||
@@ -269,3 +269,3 @@ // however, be careful not to add files from node_modules unless | ||
var _a; | ||
const outputFiles = instances_1.getEmitOutput(instance, filePath); | ||
const outputFiles = (0, instances_1.getEmitOutput)(instance, filePath); | ||
loaderContext.clearDependencies(); | ||
@@ -280,3 +280,3 @@ loaderContext.addDependency(rawFilePath); | ||
// Make this file dependent on *all* definition files in the program | ||
if (!utils_1.isReferencedFile(instance, filePath)) { | ||
if (!(0, utils_1.isReferencedFile)(instance, filePath)) { | ||
for (const { fileName: defFilePath } of instance.files.values()) { | ||
@@ -297,3 +297,3 @@ if (defFilePath.match(constants.dtsDtsxOrDtsDtsxMapRegex) && | ||
// the real dependency that webpack should watch is the JS output file. | ||
addDependency(instances_1.getInputFileNameFromOutput(instance, path.resolve(resolvedFileName)) || | ||
addDependency((0, instances_1.getInputFileNameFromOutput)(instance, path.resolve(resolvedFileName)) || | ||
originalFileName); | ||
@@ -305,3 +305,3 @@ } | ||
'@' + | ||
(utils_1.isReferencedFile(instance, defFilePath) | ||
((0, utils_1.isReferencedFile)(instance, defFilePath) | ||
? instance | ||
@@ -333,3 +333,3 @@ .solutionBuilderHost.getInputFileStamp(defFilePath) | ||
const resolvedFilePath = instance.filePathKeyMapper(filePath); | ||
if (!utils_1.isReferencedFile(instance, filePath)) { | ||
if (!(0, utils_1.isReferencedFile)(instance, filePath)) { | ||
if (instance.configParseResult.fileNames.some(f => instance.filePathKeyMapper(f) === resolvedFilePath)) { | ||
@@ -398,3 +398,3 @@ addDependenciesFromProjectReferences(instance, instance.configFilePath, instance.configParseResult.projectReferences, addDependency); | ||
function getTranspilationEmit(fileName, contents, instance, loaderContext) { | ||
if (utils_1.isReferencedFile(instance, fileName)) { | ||
if ((0, utils_1.isReferencedFile)(instance, fileName)) { | ||
const outputFiles = instance.solutionBuilderHost.getOutputFilesFromReferencedProjectInput(fileName); | ||
@@ -414,3 +414,3 @@ addDependenciesFromSolutionBuilder(instance, fileName, file => loaderContext.addDependency(path.resolve(file))); | ||
if (!instance.loaderOptions.happyPackMode) { | ||
const errors = utils_1.formatErrors(diagnostics, instance.loaderOptions, instance.colors, instance.compiler, { module }, loaderContext.context); | ||
const errors = (0, utils_1.formatErrors)(diagnostics, instance.loaderOptions, instance.colors, instance.compiler, { module }, loaderContext.context); | ||
/** | ||
@@ -417,0 +417,0 @@ * Since webpack 5, the `errors` property is deprecated, |
@@ -26,6 +26,6 @@ "use strict"; | ||
function getTypeScriptInstance(loaderOptions, loader) { | ||
const existing = instance_cache_1.getTSInstanceFromCache(loader._compiler, loaderOptions.instance); | ||
const existing = (0, instance_cache_1.getTSInstanceFromCache)(loader._compiler, loaderOptions.instance); | ||
if (existing) { | ||
if (!existing.initialSetupPending) { | ||
utils_1.ensureProgram(existing); | ||
(0, utils_1.ensureProgram)(existing); | ||
} | ||
@@ -37,6 +37,6 @@ return { instance: existing }; | ||
const log = logger.makeLogger(loaderOptions, colors); | ||
const compiler = compilerSetup_1.getCompiler(loaderOptions, log); | ||
const compiler = (0, compilerSetup_1.getCompiler)(loaderOptions, log); | ||
if (compiler.errorMessage !== undefined) { | ||
return { | ||
error: utils_1.makeError(loaderOptions, colors.red(compiler.errorMessage), undefined), | ||
error: (0, utils_1.makeError)(loaderOptions, colors.red(compiler.errorMessage), undefined), | ||
}; | ||
@@ -52,3 +52,3 @@ } | ||
const fileNameLowerCaseRegExp = /[^\u0130\u0131\u00DFa-z0-9\\/:\-_\. ]+/g; | ||
return utils_1.useCaseSensitiveFileNames(compiler, loaderOptions) | ||
return (0, utils_1.useCaseSensitiveFileNames)(compiler, loaderOptions) | ||
? pathResolve | ||
@@ -77,7 +77,7 @@ : toFileNameLowerCase; | ||
function successfulTypeScriptInstance(loaderOptions, loader, log, colors, compiler, compilerCompatible, compilerDetailsLogMessage) { | ||
const configFileAndPath = config_1.getConfigFile(compiler, colors, loader, loaderOptions, compilerCompatible, log, compilerDetailsLogMessage); | ||
const configFileAndPath = (0, config_1.getConfigFile)(compiler, colors, loader, loaderOptions, compilerCompatible, log, compilerDetailsLogMessage); | ||
if (configFileAndPath.configFileError !== undefined) { | ||
const { message, file } = configFileAndPath.configFileError; | ||
return { | ||
error: utils_1.makeError(loaderOptions, colors.red('error while reading tsconfig.json:' + constants_1.EOL + message), file), | ||
error: (0, utils_1.makeError)(loaderOptions, colors.red('error while reading tsconfig.json:' + constants_1.EOL + message), file), | ||
}; | ||
@@ -92,3 +92,3 @@ } | ||
// Reuse the instance if config file for project references is shared. | ||
instance_cache_1.setTSInstanceInCache(loader._compiler, loaderOptions.instance, existing); | ||
(0, instance_cache_1.setTSInstanceInCache)(loader._compiler, loaderOptions.instance, existing); | ||
return { instance: existing }; | ||
@@ -99,5 +99,5 @@ } | ||
const basePath = loaderOptions.context || path.dirname(configFilePath || ''); | ||
const configParseResult = config_1.getConfigParseResult(compiler, configFile, basePath, configFilePath, loaderOptions); | ||
const configParseResult = (0, config_1.getConfigParseResult)(compiler, configFile, basePath, configFilePath, loaderOptions); | ||
if (configParseResult.errors.length > 0 && !loaderOptions.happyPackMode) { | ||
const errors = utils_1.formatErrors(configParseResult.errors, loaderOptions, colors, compiler, { file: configFilePath }, loader.context); | ||
const errors = (0, utils_1.formatErrors)(configParseResult.errors, loaderOptions, colors, compiler, { file: configFilePath }, loader.context); | ||
/** | ||
@@ -114,6 +114,6 @@ * Since webpack 5, the `errors` property is deprecated, | ||
return { | ||
error: utils_1.makeError(loaderOptions, colors.red('error while parsing tsconfig.json'), configFilePath), | ||
error: (0, utils_1.makeError)(loaderOptions, colors.red('error while parsing tsconfig.json'), configFilePath), | ||
}; | ||
} | ||
const compilerOptions = compilerSetup_1.getCompilerOptions(configParseResult, compiler); | ||
const compilerOptions = (0, compilerSetup_1.getCompilerOptions)(configParseResult, compiler); | ||
const rootFileNames = new Set(); | ||
@@ -124,3 +124,3 @@ const files = new Map(); | ||
loaderOptions.appendTsxSuffixTo.length > 0 | ||
? (filePath) => utils_1.appendSuffixesIfMatch({ | ||
? (filePath) => (0, utils_1.appendSuffixesIfMatch)({ | ||
'.ts': loaderOptions.appendTsSuffixTo, | ||
@@ -153,3 +153,3 @@ '.tsx': loaderOptions.appendTsxSuffixTo, | ||
}; | ||
instance_cache_1.setTSInstanceInCache(loader._compiler, loaderOptions.instance, transpileInstance); | ||
(0, instance_cache_1.setTSInstanceInCache)(loader._compiler, loaderOptions.instance, transpileInstance); | ||
return { instance: transpileInstance }; | ||
@@ -175,3 +175,3 @@ } | ||
return { | ||
error: utils_1.makeError(loaderOptions, colors.red(`A file specified in tsconfig.json could not be found: ${normalizedFilePath}`), normalizedFilePath), | ||
error: (0, utils_1.makeError)(loaderOptions, colors.red(`A file specified in tsconfig.json could not be found: ${normalizedFilePath}`), normalizedFilePath), | ||
}; | ||
@@ -198,3 +198,3 @@ } | ||
}; | ||
instance_cache_1.setTSInstanceInCache(loader._compiler, loaderOptions.instance, instance); | ||
(0, instance_cache_1.setTSInstanceInCache)(loader._compiler, loaderOptions.instance, instance); | ||
return { instance }; | ||
@@ -218,3 +218,3 @@ } | ||
// add makeAfterCompile with addAssets = true to emit assets and report errors | ||
loader._compiler.hooks.afterCompile.tapAsync('ts-loader', after_compile_1.makeAfterCompile(instance, instance.configFilePath)); | ||
loader._compiler.hooks.afterCompile.tapAsync('ts-loader', (0, after_compile_1.makeAfterCompile)(instance, instance.configFilePath)); | ||
} | ||
@@ -226,3 +226,3 @@ : (loader, instance) => { | ||
// and all files will always be checked. | ||
const cachedMakeAfterCompile = after_compile_1.makeAfterCompile(instance, instance.configFilePath); | ||
const cachedMakeAfterCompile = (0, after_compile_1.makeAfterCompile)(instance, instance.configFilePath); | ||
// compilation is actually of type webpack.compilation.Compilation, but afterProcessAssets | ||
@@ -260,3 +260,3 @@ // only exists in webpack5 and at the time of writing ts-loader is built using webpack4 | ||
catch (err) { | ||
throw new Error(`Failed to load customTransformers from "${instance.loaderOptions.getCustomTransformers}": ${err.message}`); | ||
throw new Error(`Failed to load customTransformers from "${instance.loaderOptions.getCustomTransformers}": ${err instanceof Error ? err.message : ''}`); | ||
} | ||
@@ -281,3 +281,3 @@ if (typeof customerTransformers !== 'function') { | ||
addAssetHooks(loader, instance); | ||
loader._compiler.hooks.watchRun.tapAsync('ts-loader', watch_run_1.makeWatchRun(instance, loader)); | ||
loader._compiler.hooks.watchRun.tapAsync('ts-loader', (0, watch_run_1.makeWatchRun)(instance, loader)); | ||
} | ||
@@ -292,3 +292,3 @@ } | ||
// If there is api available for watch, use it instead of language service | ||
instance.watchHost = servicesHost_1.makeWatchHost(getScriptRegexp(instance), loader, instance, instance.configParseResult.projectReferences); | ||
instance.watchHost = (0, servicesHost_1.makeWatchHost)(getScriptRegexp(instance), loader, instance, instance.configParseResult.projectReferences); | ||
instance.watchOfFilesAndCompilerOptions = instance.compiler.createWatchProgram(instance.watchHost); | ||
@@ -300,3 +300,3 @@ instance.builderProgram = instance.watchOfFilesAndCompilerOptions.getProgram(); | ||
else { | ||
instance.servicesHost = servicesHost_1.makeServicesHost(getScriptRegexp(instance), loader, instance, instance.configParseResult.projectReferences); | ||
instance.servicesHost = (0, servicesHost_1.makeServicesHost)(getScriptRegexp(instance), loader, instance, instance.configParseResult.projectReferences); | ||
instance.languageService = instance.compiler.createLanguageService(instance.servicesHost, instance.compiler.createDocumentRegistry()); | ||
@@ -306,3 +306,3 @@ instance.transformers = getCustomTransformers(instance.languageService.getProgram()); | ||
addAssetHooks(loader, instance); | ||
loader._compiler.hooks.watchRun.tapAsync('ts-loader', watch_run_1.makeWatchRun(instance, loader)); | ||
loader._compiler.hooks.watchRun.tapAsync('ts-loader', (0, watch_run_1.makeWatchRun)(instance, loader)); | ||
} | ||
@@ -332,5 +332,5 @@ } | ||
if (!instance.loaderOptions.happyPackMode) { | ||
const solutionErrors = servicesHost_1.getSolutionErrors(instance, loader.context); | ||
const solutionErrors = (0, servicesHost_1.getSolutionErrors)(instance, loader.context); | ||
const diagnostics = instance.program.getOptionsDiagnostics(); | ||
const errors = utils_1.formatErrors(diagnostics, instance.loaderOptions, instance.colors, instance.compiler, { file: instance.configFilePath || 'tsconfig.json' }, loader.context); | ||
const errors = (0, utils_1.formatErrors)(diagnostics, instance.loaderOptions, instance.colors, instance.compiler, { file: instance.configFilePath || 'tsconfig.json' }, loader.context); | ||
/** | ||
@@ -350,3 +350,3 @@ * Since webpack 5, the `errors` property is deprecated, | ||
function buildSolutionReferences(instance, loader) { | ||
if (!utils_1.supportsSolutionBuild(instance)) { | ||
if (!(0, utils_1.supportsSolutionBuild)(instance)) { | ||
return; | ||
@@ -358,3 +358,3 @@ } | ||
const scriptRegex = getScriptRegexp(instance); | ||
instance.solutionBuilderHost = servicesHost_1.makeSolutionBuilderHost(scriptRegex, loader, instance); | ||
instance.solutionBuilderHost = (0, servicesHost_1.makeSolutionBuilderHost)(scriptRegex, loader, instance); | ||
const solutionBuilder = instance.compiler.createSolutionBuilderWithWatch(instance.solutionBuilderHost, instance.configParseResult.projectReferences.map(ref => ref.path), { verbose: true }); | ||
@@ -425,3 +425,3 @@ solutionBuilder.build(); | ||
function getOutputFileNames(instance, configFile, inputFileName) { | ||
const ignoreCase = !utils_1.useCaseSensitiveFileNames(instance.compiler, instance.loaderOptions); | ||
const ignoreCase = !(0, utils_1.useCaseSensitiveFileNames)(instance.compiler, instance.loaderOptions); | ||
if (instance.compiler.getOutputFileNames) { | ||
@@ -457,3 +457,3 @@ return instance.compiler.getOutputFileNames(configFile, inputFileName, ignoreCase); | ||
} | ||
const program = utils_1.ensureProgram(instance); | ||
const program = (0, utils_1.ensureProgram)(instance); | ||
return (program && | ||
@@ -472,3 +472,3 @@ program.getResolvedProjectReferences && | ||
function getEmitFromWatchHost(instance, filePath) { | ||
const program = utils_1.ensureProgram(instance); | ||
const program = (0, utils_1.ensureProgram)(instance); | ||
const builderProgram = instance.builderProgram; | ||
@@ -519,6 +519,6 @@ if (builderProgram && program) { | ||
} | ||
if (utils_1.isReferencedFile(instance, filePath)) { | ||
if ((0, utils_1.isReferencedFile)(instance, filePath)) { | ||
return instance.solutionBuilderHost.getOutputFilesFromReferencedProjectInput(filePath); | ||
} | ||
const program = utils_1.ensureProgram(instance); | ||
const program = (0, utils_1.ensureProgram)(instance); | ||
if (program !== undefined) { | ||
@@ -525,0 +525,0 @@ const sourceFile = program.getSourceFile(filePath); |
@@ -151,9 +151,3 @@ import type * as typescript from 'typescript'; | ||
update(compilerOptions: typescript.CompilerOptions): void; | ||
getPackageJsonInfoCache?(): any; | ||
} | ||
export interface TypeReferenceDirectiveResolutionCache { | ||
getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: typescript.ResolvedProjectReference): Map<string, typescript.ResolvedTypeReferenceDirectiveWithFailedLookupLocations>; | ||
clear(): void; | ||
update(compilerOptions: typescript.CompilerOptions): void; | ||
} | ||
export interface TSInstance { | ||
@@ -167,3 +161,3 @@ compiler: typeof typescript; | ||
moduleResolutionCache?: ModuleResolutionCache; | ||
typeReferenceResolutionCache?: TypeReferenceDirectiveResolutionCache; | ||
typeReferenceResolutionCache?: typescript.TypeReferenceDirectiveResolutionCache; | ||
/** | ||
@@ -263,4 +257,14 @@ * a cache of all the files | ||
} | ||
export interface TSCommon { | ||
resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: typescript.CompilerOptions, host: typescript.ModuleResolutionHost, redirectedReference?: typescript.ResolvedProjectReference, cache?: typescript.TypeReferenceDirectiveResolutionCache, resolutionMode?: typescript.SourceFile['impliedNodeFormat']): typescript.ResolvedTypeReferenceDirectiveWithFailedLookupLocations; | ||
} | ||
/** | ||
* Compiler APIs we use that are marked internal and not included in TypeScript's public API declarations | ||
* @internal | ||
*/ | ||
export interface TSInternal { | ||
getModeForFileReference?: (ref: typescript.FileReference | string, containingFileMode: typescript.SourceFile['impliedNodeFormat']) => typescript.SourceFile['impliedNodeFormat']; | ||
} | ||
export declare type Severity = 'error' | 'warning'; | ||
export {}; | ||
//# sourceMappingURL=interfaces.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
// make a (sync) resolver that follows webpack's rules | ||
const resolveSync = resolver_1.makeResolver(loader._compiler.options); | ||
const resolveSync = (0, resolver_1.makeResolver)(loader._compiler.options); | ||
const moduleResolutionHost = { | ||
@@ -31,3 +31,3 @@ trace: logData => instance.log.log(logData), | ||
readDirectory, | ||
useCaseSensitiveFileNames: () => utils_1.useCaseSensitiveFileNames(compiler, instance.loaderOptions), | ||
useCaseSensitiveFileNames: () => (0, utils_1.useCaseSensitiveFileNames)(compiler, instance.loaderOptions), | ||
getNewLine: () => newLine, | ||
@@ -42,3 +42,3 @@ getDefaultLibFileName: options => compiler.getDefaultLibFilePath(options), | ||
return (instance.compiler.sys.readFile(filePath, encoding) || | ||
utils_1.fsReadFile(filePath, encoding)); | ||
(0, utils_1.fsReadFile)(filePath, encoding)); | ||
} | ||
@@ -64,3 +64,3 @@ function directoryExists(directoryName) { | ||
const { moduleResolutionHost, resolveModuleNames, resolveTypeReferenceDirectives, } = makeResolversAndModuleResolutionHost(scriptRegex, loader, instance, filePathToCheck => compiler.sys.fileExists(filePathToCheck) || | ||
utils_1.fsReadFile(filePathToCheck) !== undefined, instance.loaderOptions.experimentalFileCaching); | ||
(0, utils_1.fsReadFile)(filePathToCheck) !== undefined, instance.loaderOptions.experimentalFileCaching); | ||
const servicesHost = Object.assign(Object.assign({ getProjectVersion: () => `${instance.version}`, getProjectReferences: () => projectReferences, getScriptFileNames: () => [...files.values()] | ||
@@ -118,7 +118,8 @@ .map(({ fileName }) => fileName) | ||
const resolvedModules = moduleNames.map(moduleName => resolveModule(resolveSync, resolveModuleName, appendTsTsxSuffixesIfRequired, scriptRegex, moduleName, containingFile, redirectedReference)); | ||
utils_1.populateDependencyGraph(resolvedModules, instance, containingFile); | ||
(0, utils_1.populateDependencyGraph)(resolvedModules, instance, containingFile); | ||
return resolvedModules; | ||
}; | ||
const resolveTypeReferenceDirective = makeResolveTypeReferenceDirective(compiler, compilerOptions, moduleResolutionHost, customResolveTypeReferenceDirective, instance); | ||
const resolveTypeReferenceDirectives = (typeDirectiveNames, containingFile, redirectedReference) => typeDirectiveNames.map(directive => resolveTypeReferenceDirective(directive, containingFile, redirectedReference).resolvedTypeReferenceDirective); | ||
const resolveTypeReferenceDirectives = (typeDirectiveNames, containingFile, redirectedReference, options, containingFileMode // new impliedNodeFormat is accepted by compilerHost | ||
) => typeDirectiveNames.map(directive => resolveTypeReferenceDirective(directive, containingFile, options, redirectedReference, containingFileMode).resolvedTypeReferenceDirective); | ||
return { | ||
@@ -195,3 +196,3 @@ resolveTypeReferenceDirectives, | ||
if (existing !== undefined) { | ||
utils_1.unorderedRemoveItem(existing.callbacks, callback); | ||
(0, utils_1.unorderedRemoveItem)(existing.callbacks, callback); | ||
if (!existing.callbacks.length) { | ||
@@ -312,3 +313,3 @@ callbacks.delete(key); | ||
function createGetCanonicalFileName(instance) { | ||
return utils_1.useCaseSensitiveFileNames(instance.compiler, instance.loaderOptions) | ||
return (0, utils_1.useCaseSensitiveFileNames)(instance.compiler, instance.loaderOptions) | ||
? identity | ||
@@ -455,3 +456,3 @@ : toFileNameLowerCase; | ||
}, getParsedCommandLine: file => { | ||
const config = config_1.getParsedCommandLine(compiler, instance.loaderOptions, file); | ||
const config = (0, config_1.getParsedCommandLine)(compiler, instance.loaderOptions, file); | ||
configFileInfo.set(filePathKeyMapper(file), { config }); | ||
@@ -549,3 +550,3 @@ return config; | ||
inputFileName: path.resolve(inputFile), | ||
outputNames: instances_1.getOutputFileNames(instance, configInfo.config, inputFile), | ||
outputNames: (0, instances_1.getOutputFileNames)(instance, configInfo.config, inputFile), | ||
})); | ||
@@ -673,3 +674,3 @@ configInfo.tsbuildInfoFile = instance.compiler | ||
instance.solutionBuilderHost.diagnostics.transpileErrors.length) { | ||
instance.solutionBuilderHost.diagnostics.transpileErrors.forEach(([filePath, errors]) => solutionErrors.push(...utils_1.formatErrors(errors, instance.loaderOptions, instance.colors, instance.compiler, { file: filePath ? undefined : 'tsconfig.json' }, context))); | ||
instance.solutionBuilderHost.diagnostics.transpileErrors.forEach(([filePath, errors]) => solutionErrors.push(...(0, utils_1.formatErrors)(errors, instance.loaderOptions, instance.colors, instance.compiler, { file: filePath ? undefined : 'tsconfig.json' }, context))); | ||
} | ||
@@ -683,11 +684,20 @@ return solutionErrors; | ||
// Until the api is published | ||
if (compiler.createTypeReferenceDirectiveResolutionCache && | ||
if (compiler.createTypeReferenceDirectiveResolutionCache !== undefined && | ||
!instance.typeReferenceResolutionCache) { | ||
instance.typeReferenceResolutionCache = compiler.createTypeReferenceDirectiveResolutionCache(moduleResolutionHost.getCurrentDirectory(), createGetCanonicalFileName(instance), instance.compilerOptions, (_b = (_a = instance.moduleResolutionCache) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.call(_a)); | ||
} | ||
return (directive, containingFile, redirectedReference) => | ||
// Until the api is published | ||
compiler.resolveTypeReferenceDirective(directive, containingFile, compilerOptions, moduleResolutionHost, redirectedReference, instance.typeReferenceResolutionCache); | ||
return (typeDirectiveName, containingFile, options, redirectedReference, containingFileMode) => { | ||
// Copy-pasted from https://github.com/TypeStrong/ts-node/blob/9f789d0d91c6eba30ac7f7aad45194a23b44f159/src/resolver-functions.ts#L139 | ||
const nameIsString = typeof typeDirectiveName === 'string'; | ||
const mode = nameIsString | ||
? undefined | ||
: compiler.getModeForFileReference(typeDirectiveName, containingFileMode); | ||
const strName = nameIsString | ||
? typeDirectiveName | ||
: typeDirectiveName.fileName.toLowerCase(); | ||
return compiler.resolveTypeReferenceDirective(strName, containingFile, options, moduleResolutionHost, redirectedReference, undefined, mode); | ||
}; | ||
} | ||
return (directive, containingFile) => customResolveTypeReferenceDirective(directive, containingFile, compilerOptions, moduleResolutionHost, compiler.resolveTypeReferenceDirective); | ||
return (directive, containingFile) => customResolveTypeReferenceDirective(directive, // unsure whether we should evolve this further | ||
containingFile, compilerOptions, moduleResolutionHost, compiler.resolveTypeReferenceDirective); | ||
} | ||
@@ -694,0 +704,0 @@ function isJsImplementationOfTypings(resolvedModule, tsResolution) { |
@@ -160,3 +160,3 @@ "use strict"; | ||
const inputFileName = instance.solutionBuilderHost && | ||
instances_1.getInputFileNameFromOutput(instance, fileKey); | ||
(0, instances_1.getInputFileNameFromOutput)(instance, fileKey); | ||
const containingFileKey = inputFileName | ||
@@ -167,3 +167,3 @@ ? instance.filePathKeyMapper(inputFileName) | ||
const key = instance.filePathKeyMapper(instance.solutionBuilderHost | ||
? instances_1.getInputFileNameFromOutput(instance, resolvedFileName) || | ||
? (0, instances_1.getInputFileNameFromOutput)(instance, resolvedFileName) || | ||
resolvedFileName | ||
@@ -170,0 +170,0 @@ : resolvedFileName); |
@@ -79,3 +79,3 @@ "use strict"; | ||
const text = JSON.parse(source); | ||
servicesHost_1.updateFileWithText(instance, key, filePath, () => text); | ||
(0, servicesHost_1.updateFileWithText)(instance, key, filePath, () => text); | ||
resolve(); | ||
@@ -86,3 +86,3 @@ } | ||
else { | ||
servicesHost_1.updateFileWithText(instance, key, filePath, nFilePath => utils_1.fsReadFile(nFilePath) || ''); | ||
(0, servicesHost_1.updateFileWithText)(instance, key, filePath, nFilePath => (0, utils_1.fsReadFile)(nFilePath) || ''); | ||
resolve(); | ||
@@ -89,0 +89,0 @@ } |
{ | ||
"name": "ts-loader", | ||
"version": "8.3.0", | ||
"version": "8.4.0", | ||
"description": "TypeScript loader for webpack", | ||
@@ -99,3 +99,3 @@ "main": "index.js", | ||
"rimraf": "^2.6.2", | ||
"typescript": "^4.0.0", | ||
"typescript": "^4.6.3", | ||
"webpack": "^4.5.0", | ||
@@ -102,0 +102,0 @@ "webpack-cli": "^3.1.1" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
251588
3061