ts-project-loader
Advanced tools
Comparing version 0.1.1 to 0.1.2
# Changelog | ||
## v0.1.2 | ||
- Fix to reuse loader instance per not only config file but compiler instance | ||
## v0.1.1 | ||
@@ -4,0 +8,0 @@ |
@@ -21,3 +21,3 @@ "use strict"; | ||
const ReplaceWatchFileSystem_1 = require("./webpack/ReplaceWatchFileSystem"); | ||
const loaderInstances = {}; | ||
const allLoaderInstances = new WeakMap(); | ||
const thisNameHeader = `[${"ts-project-loader" /* ThisName */}] `; | ||
@@ -113,6 +113,12 @@ function validateOptions(options) { | ||
} | ||
function getInstance(configPath) { | ||
return loaderInstances[configPath || '']; | ||
function getInstance(loader, configPath) { | ||
const loaderInstances = allLoaderInstances.get(loader._compiler); | ||
return loaderInstances && loaderInstances[configPath || '']; | ||
} | ||
function setInstance(configPath, instance) { | ||
function setInstance(loader, configPath, instance) { | ||
let loaderInstances = allLoaderInstances.get(loader._compiler); | ||
if (!loaderInstances) { | ||
loaderInstances = {}; | ||
allLoaderInstances.set(loader._compiler, loaderInstances); | ||
} | ||
loaderInstances[configPath || ''] = instance; | ||
@@ -127,3 +133,3 @@ return instance; | ||
const configPath = tsc_1.findConfigFile((name) => host.directoryExists(name), (name) => host.fileExists(name), path.dirname(resourcePath), configFile); | ||
let instance = getInstance(configPath); | ||
let instance = getInstance(loader, configPath); | ||
if (!instance) { | ||
@@ -142,3 +148,3 @@ const handlers = makeHandlers(loader, options); | ||
const fs = tscBuildConfig.wrappedFs && tscBuildConfig.wrappedFs.makeInputFileSystem(loader.fs, tscBuildConfig); | ||
instance = setInstance(configPath, { | ||
instance = setInstance(loader, configPath, { | ||
tscBuildConfig, handlers, fs, compilers: [] | ||
@@ -145,0 +151,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
declare const _default: "0.1.1"; | ||
declare const _default: "0.1.2"; | ||
export default _default; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = '0.1.1'; | ||
exports.default = '0.1.2'; |
@@ -41,3 +41,3 @@ { | ||
"types": "./dist/index.d.ts", | ||
"version": "0.1.1" | ||
"version": "0.1.2" | ||
} |
@@ -8,3 +8,3 @@ [](https://www.npmjs.com/package/ts-project-loader) | ||
ts-project-loader compiles all TypeScript files in the project on the request only for the first TS file, not for each TS files. Because the TypeScript compilation is executed only once (per project), this will reduce total compilation time a little. | ||
ts-project-loader compiles all TypeScript files in the project on the request only for the first TS file, not for each TS files. Because the TypeScript compilation is executed only once (per project and compiler instance), this will reduce total compilation time a little. | ||
@@ -11,0 +11,0 @@ ts-project-loader is based on `tsc2webpack` project, and is more easier-to-use because ts-project-loader is simply a webpack loader. |
81550
1830