Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-loader

Package Overview
Dependencies
Maintainers
3
Versions
165
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-loader - npm Package Compare versions

Comparing version 9.0.2 to 9.1.0

6

CHANGELOG.md
# Changelog
## v9.1.0
* [Use caches for module resolution and type reference directives when using compiler default functions](https://github.com/TypeStrong/ts-loader/pull/1287) - thanks @sheetalkamat - uses: https://github.com/microsoft/TypeScript/pull/43700
## v9.0.2
* [Remove usage of loader-utils](https://github.com/TypeStrong/ts-loader/pull/1287) - thanks @jonwallsten
* [Remove usage of loader-utils](https://github.com/TypeStrong/ts-loader/pull/1288) - thanks @jonwallsten

@@ -7,0 +11,0 @@ ## v9.0.1

@@ -46,3 +46,3 @@ /// <reference types="node" />

}
export interface WatchHost extends typescript.WatchCompilerHostOfFilesAndCompilerOptions<typescript.EmitAndSemanticDiagnosticsBuilderProgram> {
export interface WatchHost extends typescript.WatchCompilerHostOfFilesAndCompilerOptions<typescript.EmitAndSemanticDiagnosticsBuilderProgram>, HostMayBeCacheable {
invokeFileWatcher: WatchFactory['invokeFileWatcher'];

@@ -107,2 +107,26 @@ updateRootFileNames(): void;

}
interface CacheWithRedirects<T> {
ownMap: Map<string, T>;
redirectsMap: Map<typescript.Path, Map<string, T>>;
getOrCreateMapOfCacheRedirects(redirectedReference: typescript.ResolvedProjectReference | undefined): Map<string, T>;
clear(): void;
setOwnOptions(newOptions: typescript.CompilerOptions): void;
setOwnMap(newOwnMap: Map<string, T>): void;
}
interface PerModuleNameCache {
get(directory: string): typescript.ResolvedModuleWithFailedLookupLocations | undefined;
set(directory: string, result: typescript.ResolvedModuleWithFailedLookupLocations): void;
}
export interface ModuleResolutionCache extends typescript.ModuleResolutionCache {
directoryToModuleNameMap: CacheWithRedirects<Map<string, typescript.ResolvedModuleWithFailedLookupLocations>>;
moduleNameToDirectoryMap: CacheWithRedirects<PerModuleNameCache>;
clear(): void;
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 {

@@ -115,2 +139,4 @@ compiler: typeof typescript;

rootFileNames: Set<string>;
moduleResolutionCache?: ModuleResolutionCache;
typeReferenceResolutionCache?: TypeReferenceDirectiveResolutionCache;
/**

@@ -364,2 +390,3 @@ * a cache of all the files

}
export {};
//# sourceMappingURL=interfaces.d.ts.map

@@ -121,10 +121,10 @@ "use strict";

function makeResolvers(compiler, compilerOptions, moduleResolutionHost, customResolveTypeReferenceDirective, customResolveModuleName, resolveSync, appendTsTsxSuffixesIfRequired, scriptRegex, instance) {
const resolveTypeReferenceDirective = makeResolveTypeReferenceDirective(compiler, compilerOptions, moduleResolutionHost, customResolveTypeReferenceDirective);
const resolveTypeReferenceDirectives = (typeDirectiveNames, containingFile, _redirectedReference) => typeDirectiveNames.map(directive => resolveTypeReferenceDirective(directive, containingFile, _redirectedReference).resolvedTypeReferenceDirective);
const resolveModuleName = makeResolveModuleName(compiler, compilerOptions, moduleResolutionHost, customResolveModuleName);
const resolveModuleNames = (moduleNames, containingFile, _reusedNames, _redirectedReference) => {
const resolvedModules = moduleNames.map(moduleName => resolveModule(resolveSync, resolveModuleName, appendTsTsxSuffixesIfRequired, scriptRegex, moduleName, containingFile));
const resolveModuleName = makeResolveModuleName(compiler, compilerOptions, moduleResolutionHost, customResolveModuleName, instance);
const resolveModuleNames = (moduleNames, containingFile, _reusedNames, redirectedReference) => {
const resolvedModules = moduleNames.map(moduleName => resolveModule(resolveSync, resolveModuleName, appendTsTsxSuffixesIfRequired, scriptRegex, moduleName, containingFile, redirectedReference));
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);
return {

@@ -244,4 +244,3 @@ resolveTypeReferenceDirectives,

const { moduleResolutionHost, resolveModuleNames, resolveTypeReferenceDirectives, } = makeResolversAndModuleResolutionHost(scriptRegex, loader, instance, fileName => files.has(filePathKeyMapper(fileName)) ||
compiler.sys.fileExists(fileName),
/*enabledCaching*/ false);
compiler.sys.fileExists(fileName), instance.loaderOptions.experimentalFileCaching);
const watchHost = {

@@ -316,2 +315,44 @@ rootFiles: getRootFileNames(),

const missingFileModifiedTime = new Date(0);
function identity(x) {
return x;
}
function toLowerCase(x) {
return x.toLowerCase();
}
const fileNameLowerCaseRegExp = /[^\u0130\u0131\u00DFa-z0-9\\/:\-_\. ]+/g;
function toFileNameLowerCase(x) {
return fileNameLowerCaseRegExp.test(x)
? x.replace(fileNameLowerCaseRegExp, toLowerCase)
: x;
}
function createGetCanonicalFileName(instance) {
return utils_1.useCaseSensitiveFileNames(instance.compiler, instance.loaderOptions)
? identity
: toFileNameLowerCase;
}
function createModuleResolutionCache(instance, moduleResolutionHost) {
const cache = instance.compiler.createModuleResolutionCache(moduleResolutionHost.getCurrentDirectory(), createGetCanonicalFileName(instance), instance.compilerOptions);
// Add new API optional methods
if (!cache.clear) {
cache.clear = () => {
cache.directoryToModuleNameMap.clear();
cache.moduleNameToDirectoryMap.clear();
};
}
if (!cache.update) {
cache.update = options => {
if (!options.configFile)
return;
const ref = {
sourceFile: options.configFile,
commandLine: { options },
};
cache.directoryToModuleNameMap.setOwnMap(cache.directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref));
cache.moduleNameToDirectoryMap.setOwnMap(cache.moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref));
cache.directoryToModuleNameMap.setOwnOptions(options);
cache.moduleNameToDirectoryMap.setOwnOptions(options);
};
}
return cache;
}
/**

@@ -325,5 +366,3 @@ * Create the TypeScript Watch host

getCurrentDirectory: compiler.sys.getCurrentDirectory,
getCanonicalFileName: utils_1.useCaseSensitiveFileNames(compiler, instance.loaderOptions)
? s => s
: s => s.toLowerCase(),
getCanonicalFileName: createGetCanonicalFileName(instance),
getNewLine: () => compiler.sys.newLine,

@@ -382,2 +421,11 @@ };

...moduleResolutionHost,
createProgram: (rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences) => {
var _a, _b, _c, _d;
(_a = instance.moduleResolutionCache) === null || _a === void 0 ? void 0 : _a.update(options || {});
(_b = instance.typeReferenceResolutionCache) === null || _b === void 0 ? void 0 : _b.update(options || {});
const result = sysHost.createProgram(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences);
(_c = instance.typeReferenceResolutionCache) === null || _c === void 0 ? void 0 : _c.update(instance.compilerOptions);
(_d = instance.moduleResolutionCache) === null || _d === void 0 ? void 0 : _d.update(instance.compilerOptions);
return result;
},
resolveModuleNames,

@@ -660,5 +708,13 @@ resolveTypeReferenceDirectives,

exports.getSolutionErrors = getSolutionErrors;
function makeResolveTypeReferenceDirective(compiler, compilerOptions, moduleResolutionHost, customResolveTypeReferenceDirective) {
function makeResolveTypeReferenceDirective(compiler, compilerOptions, moduleResolutionHost, customResolveTypeReferenceDirective, instance) {
var _a, _b;
if (customResolveTypeReferenceDirective === undefined) {
return (directive, containingFile, redirectedReference) => compiler.resolveTypeReferenceDirective(directive, containingFile, compilerOptions, moduleResolutionHost, redirectedReference);
// Until the api is published
if (compiler.createTypeReferenceDirectiveResolutionCache &&
!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);
}

@@ -671,3 +727,3 @@ return (directive, containingFile) => customResolveTypeReferenceDirective(directive, containingFile, compilerOptions, moduleResolutionHost, compiler.resolveTypeReferenceDirective);

}
function resolveModule(resolveSync, resolveModuleName, appendTsTsxSuffixesIfRequired, scriptRegex, moduleName, containingFile) {
function resolveModule(resolveSync, resolveModuleName, appendTsTsxSuffixesIfRequired, scriptRegex, moduleName, containingFile, redirectedReference) {
let resolutionResult;

@@ -684,9 +740,9 @@ try {

catch (e) { }
const tsResolution = resolveModuleName(moduleName, containingFile);
const tsResolution = resolveModuleName(moduleName, containingFile, redirectedReference);
if (tsResolution.resolvedModule !== undefined) {
const resolvedFileName = path.normalize(tsResolution.resolvedModule.resolvedFileName);
const tsResolutionResult = {
...tsResolution.resolvedModule,
originalFileName: resolvedFileName,
resolvedFileName,
isExternalLibraryImport: tsResolution.resolvedModule.isExternalLibraryImport,
};

@@ -702,5 +758,8 @@ return resolutionResult === undefined ||

}
function makeResolveModuleName(compiler, compilerOptions, moduleResolutionHost, customResolveModuleName) {
function makeResolveModuleName(compiler, compilerOptions, moduleResolutionHost, customResolveModuleName, instance) {
if (customResolveModuleName === undefined) {
return (moduleName, containingFile) => compiler.resolveModuleName(moduleName, containingFile, compilerOptions, moduleResolutionHost);
if (!instance.moduleResolutionCache) {
instance.moduleResolutionCache = createModuleResolutionCache(instance, moduleResolutionHost);
}
return (moduleName, containingFile, redirectedReference) => compiler.resolveModuleName(moduleName, containingFile, compilerOptions, moduleResolutionHost, instance.moduleResolutionCache, redirectedReference);
}

@@ -707,0 +766,0 @@ return (moduleName, containingFile) => customResolveModuleName(moduleName, containingFile, compilerOptions, moduleResolutionHost, compiler.resolveModuleName);

5

dist/watch-run.js

@@ -18,4 +18,7 @@ "use strict";

return (compiler, callback) => {
var _a, _b;
var _a, _b, _c, _d, _e, _f;
(_b = (_a = instance.servicesHost) === null || _a === void 0 ? void 0 : _a.clearCache) === null || _b === void 0 ? void 0 : _b.call(_a);
(_d = (_c = instance.watchHost) === null || _c === void 0 ? void 0 : _c.clearCache) === null || _d === void 0 ? void 0 : _d.call(_c);
(_e = instance.moduleResolutionCache) === null || _e === void 0 ? void 0 : _e.clear();
(_f = instance.typeReferenceResolutionCache) === null || _f === void 0 ? void 0 : _f.clear();
const promises = [];

@@ -22,0 +25,0 @@ if (instance.loaderOptions.transpileOnly) {

{
"name": "ts-loader",
"version": "9.0.2",
"version": "9.1.0",
"description": "TypeScript loader for webpack",

@@ -5,0 +5,0 @@ "main": "index.js",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc