Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor perf optimisation for loaderoptions #412

Merged
merged 9 commits into from
Dec 15, 2016
Merged
Prev Previous commit
Next Next commit
renames, use readfile constently
  • Loading branch information
johnnyreilly committed Dec 15, 2016
commit 4b83fbaee83a3661674ec6a5387644b397fe43c7
2 changes: 1 addition & 1 deletion src/after-compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 52,8 @@ function provideCompilerOptionDiagnosticErrorsToWebpack(
instance: interfaces.TSInstance,
configFilePath: string
) {
const { languageService, loaderOptions, compiler } = instance;
if (getCompilerOptionDiagnostics) {
const { languageService, loaderOptions, compiler } = instance;
utils.registerWebpackErrors(
compilation.errors,
utils.formatErrors(
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 154,7 @@ function getEmit(

loader._module.meta.tsLoaderDefinitionFileVersions = allDefinitionFiles
.concat(additionalDependencies)
.map(fp => fp '@' (instance.files[fp] || { version: '?' }).version);
.map(filePath => filePath '@' (instance.files[filePath] || { version: '?' }).version);

const outputFile = output.outputFiles.filter(outputFile => !!outputFile.name.match(constants.jsJsx)).pop();
const outputText = (outputFile) ? outputFile.text : undefined;
Expand Down
7 changes: 3 additions & 4 deletions src/instances.ts
Original file line number Diff line number Diff line change
@@ -1,5 1,4 @@
import path = require('path');
import fs = require('fs');
require('colors');

import afterCompile = require('./after-compile');
Expand Down Expand Up @@ -75,10 74,10 @@ export function getTypeScriptInstance(
let filePath: string;
try {
const filesToLoad = configParseResult.fileNames;
filesToLoad.forEach(fp => {
filePath = path.normalize(fp);
filesToLoad.forEach(filePath => {
filePath = path.normalize(filePath);
files[filePath] = {
text: fs.readFileSync(filePath, 'utf-8'),
text: utils.readFile(filePath),
version: 0
};
});
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 125,7 @@ export function collectAllDependencies(
directDependencies.forEach(dependencyFilePath => {
if (!collected[dependencyFilePath]) {
collectAllDependencies(dependencyGraph, dependencyFilePath, collected)
.forEach(fPath => result[fPath] = true);
.forEach(filePath => result[filePath] = true);
}
});
}
Expand Down