Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ interface TSInstance {
files: TSFiles;
languageService?: typescript.LanguageService;
version?: number;
dependencyGraph: any;
}

interface TSInstances {
Expand Down Expand Up @@ -193,7 +194,8 @@ function ensureTypeScriptInstance(loaderOptions: LoaderOptions, loader: any): {
loaderOptions,
files,
languageService: null,
version: 0
version: 0,
dependencyGraph: {}
};

var compilerOptions: typescript.CompilerOptions = {
Expand Down Expand Up @@ -293,7 +295,7 @@ function ensureTypeScriptInstance(loaderOptions: LoaderOptions, loader: any): {
loader._module.errors,
formatErrors(diagnostics, instance, {file: configFilePath || 'tsconfig.json'}));

return { instance: instances[loaderOptions.instance] = { compiler, compilerOptions, loaderOptions, files }};
return { instance: instances[loaderOptions.instance] = { compiler, compilerOptions, loaderOptions, files, dependencyGraph: {} }};
}

// Load initial files (core lib files, any files specified in tsconfig.json)
Expand Down Expand Up @@ -395,6 +397,9 @@ function ensureTypeScriptInstance(loaderOptions: LoaderOptions, loader: any): {

resolvedModules.push(resolutionResult);
}

instance.dependencyGraph[containingFile] = resolvedModules.filter(m => m != null).map(m => m.resolvedFileName);

return resolvedModules;
}
};
Expand Down Expand Up @@ -486,11 +491,11 @@ function ensureTypeScriptInstance(loaderOptions: LoaderOptions, loader: any): {
callback();
});

// manually update changed declaration files
// manually update changed files
loader._compiler.plugin("watch-run", (watching, cb) => {
var mtimes = watching.compiler.watchFileSystem.watcher.mtimes;
Object.keys(mtimes)
.filter(filePath => !!filePath.match(/\.d\.ts$/))
.filter(filePath => !!filePath.match(/\.tsx?$|\.jsx?$/))
.forEach(filePath => {
filePath = path.normalize(filePath);
var file = instance.files[filePath];
Expand Down Expand Up @@ -567,16 +572,25 @@ function loader(contents) {
else {
let langService = instance.languageService;

// Emit Javascript
var output = langService.getEmitOutput(filePath);

// Make this file dependent on *all* definition files in the program
this.clearDependencies();
this.addDependency(filePath);

let allDefinitionFiles = Object.keys(instance.files).filter(filePath => /\.d\.ts$/.test(filePath));
allDefinitionFiles.forEach(this.addDependency.bind(this));
this._module.meta.tsLoaderDefinitionFileVersions = allDefinitionFiles.map(filePath => filePath+'@'+instance.files[filePath].version);

// Emit Javascript
var output = langService.getEmitOutput(filePath);
// Additionally make this file dependent on all imported files
let additionalDependencies = instance.dependencyGraph[filePath];
if (additionalDependencies) {
additionalDependencies.forEach(this.addDependency.bind(this))
}

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

var outputFile = output.outputFiles.filter(file => !!file.name.match(/\.js(x?)$/)).pop();
if (outputFile) { outputText = outputFile.text }
Expand Down
2 changes: 1 addition & 1 deletion test/aliasResolution/expectedOutput-1.6/patch0/output.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Asset Size Chunks Chunk Names
bundle.js 1.56 kB 0 [emitted] main
chunk {0} bundle.js (main) 110 bytes [rendered]
[0] ./.test/aliasResolution/app.ts 79 bytes {0} [1 error]
[0] ./.test/aliasResolution/app.ts 79 bytes {0} [built] [1 error]
[1] ./.test/aliasResolution/common/components/myComponent.ts 31 bytes {0} [built]

ERROR in ./.test/aliasResolution/app.ts
Expand Down
2 changes: 1 addition & 1 deletion test/aliasResolution/expectedOutput-1.7/patch0/output.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Asset Size Chunks Chunk Names
bundle.js 1.56 kB 0 [emitted] main
chunk {0} bundle.js (main) 110 bytes [rendered]
[0] ./.test/aliasResolution/app.ts 79 bytes {0} [1 error]
[0] ./.test/aliasResolution/app.ts 79 bytes {0} [built] [1 error]
[1] ./.test/aliasResolution/common/components/myComponent.ts 31 bytes {0} [built]

ERROR in ./.test/aliasResolution/app.ts
Expand Down
2 changes: 1 addition & 1 deletion test/aliasResolution/expectedOutput-1.8/patch0/output.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Asset Size Chunks Chunk Names
bundle.js 1.59 kB 0 [emitted] main
chunk {0} bundle.js (main) 138 bytes [rendered]
[0] ./.test/aliasResolution/app.ts 93 bytes {0} [1 error]
[0] ./.test/aliasResolution/app.ts 93 bytes {0} [built] [1 error]
[1] ./.test/aliasResolution/common/components/myComponent.ts 45 bytes {0} [built]

ERROR in ./.test/aliasResolution/app.ts
Expand Down
2 changes: 1 addition & 1 deletion test/aliasResolution/expectedOutput-1.9/patch0/output.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Asset Size Chunks Chunk Names
bundle.js 1.59 kB 0 [emitted] main
chunk {0} bundle.js (main) 138 bytes [rendered]
[0] ./.test/aliasResolution/app.ts 93 bytes {0} [1 error]
[0] ./.test/aliasResolution/app.ts 93 bytes {0} [built] [1 error]
[1] ./.test/aliasResolution/common/components/myComponent.ts 45 bytes {0} [built]

ERROR in ./.test/aliasResolution/app.ts
Expand Down
2 changes: 1 addition & 1 deletion test/dependencyErrors/expectedOutput-1.6/patch0/output.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Asset Size Chunks Chunk Names
bundle.js 1.74 kB 0 [emitted] main
chunk {0} bundle.js (main) 204 bytes [rendered]
[0] ./.test/dependencyErrors/app.ts 80 bytes {0} [1 error]
[0] ./.test/dependencyErrors/app.ts 80 bytes {0} [built] [1 error]
[1] ./.test/dependencyErrors/dep1.ts 62 bytes {0} [built]
[2] ./.test/dependencyErrors/dep2.ts 62 bytes {0}

Expand Down
2 changes: 1 addition & 1 deletion test/dependencyErrors/expectedOutput-1.7/patch0/output.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Asset Size Chunks Chunk Names
bundle.js 1.74 kB 0 [emitted] main
chunk {0} bundle.js (main) 204 bytes [rendered]
[0] ./.test/dependencyErrors/app.ts 80 bytes {0} [1 error]
[0] ./.test/dependencyErrors/app.ts 80 bytes {0} [built] [1 error]
[1] ./.test/dependencyErrors/dep1.ts 62 bytes {0} [built]
[2] ./.test/dependencyErrors/dep2.ts 62 bytes {0}

Expand Down
2 changes: 1 addition & 1 deletion test/dependencyErrors/expectedOutput-1.8/patch0/output.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Asset Size Chunks Chunk Names
bundle.js 1.78 kB 0 [emitted] main
chunk {0} bundle.js (main) 246 bytes [rendered]
[0] ./.test/dependencyErrors/app.ts 94 bytes {0} [1 error]
[0] ./.test/dependencyErrors/app.ts 94 bytes {0} [built] [1 error]
[1] ./.test/dependencyErrors/dep1.ts 76 bytes {0} [built]
[2] ./.test/dependencyErrors/dep2.ts 76 bytes {0}

Expand Down
2 changes: 1 addition & 1 deletion test/dependencyErrors/expectedOutput-1.9/patch0/output.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Asset Size Chunks Chunk Names
bundle.js 1.78 kB 0 [emitted] main
chunk {0} bundle.js (main) 246 bytes [rendered]
[0] ./.test/dependencyErrors/app.ts 94 bytes {0} [1 error]
[0] ./.test/dependencyErrors/app.ts 94 bytes {0} [built] [1 error]
[1] ./.test/dependencyErrors/dep1.ts 76 bytes {0} [built]
[2] ./.test/dependencyErrors/dep2.ts 76 bytes {0}

Expand Down
2 changes: 1 addition & 1 deletion test/issue81/expectedOutput-1.8/bundle.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/simpleDependency/expectedOutput-1.6/patch0/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
bundle.js 1.71 kB 0 [emitted] main
chunk {0} bundle.js (main) 155 bytes [rendered]
[0] ./.test/simpleDependency/app.ts 37 bytes {0} [1 error]
[1] ./.test/simpleDependency/dep.ts 56 bytes {0}
[1] ./.test/simpleDependency/dep.ts 56 bytes {0} [built]
[2] ./.test/simpleDependency/deeperDep.ts 62 bytes {0} [built]

ERROR in ./.test/simpleDependency/app.ts
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Asset Size Chunks Chunk Names
bundle.js 1.71 kB 0 [emitted] main
chunk {0} bundle.js (main) 155 bytes [rendered]
[0] ./.test/simpleDependency/app.ts 37 bytes {0}
[1] ./.test/simpleDependency/dep.ts 56 bytes {0}
[2] ./.test/simpleDependency/deeperDep.ts 62 bytes {0} [built]
2 changes: 1 addition & 1 deletion test/simpleDependency/expectedOutput-1.6/patch1/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
bundle.js 1.71 kB 0 [emitted] main
chunk {0} bundle.js (main) 155 bytes [rendered]
[0] ./.test/simpleDependency/app.ts 37 bytes {0}
[1] ./.test/simpleDependency/dep.ts 56 bytes {0}
[1] ./.test/simpleDependency/dep.ts 56 bytes {0} [built]
[2] ./.test/simpleDependency/deeperDep.ts 62 bytes {0} [built]
2 changes: 1 addition & 1 deletion test/simpleDependency/expectedOutput-1.7/patch0/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
bundle.js 1.71 kB 0 [emitted] main
chunk {0} bundle.js (main) 155 bytes [rendered]
[0] ./.test/simpleDependency/app.ts 37 bytes {0} [1 error]
[1] ./.test/simpleDependency/dep.ts 56 bytes {0}
[1] ./.test/simpleDependency/dep.ts 56 bytes {0} [built]
[2] ./.test/simpleDependency/deeperDep.ts 62 bytes {0} [built]

ERROR in ./.test/simpleDependency/app.ts
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Asset Size Chunks Chunk Names
bundle.js 1.71 kB 0 [emitted] main
chunk {0} bundle.js (main) 155 bytes [rendered]
[0] ./.test/simpleDependency/app.ts 37 bytes {0}
[1] ./.test/simpleDependency/dep.ts 56 bytes {0}
[2] ./.test/simpleDependency/deeperDep.ts 62 bytes {0} [built]
2 changes: 1 addition & 1 deletion test/simpleDependency/expectedOutput-1.7/patch1/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
bundle.js 1.71 kB 0 [emitted] main
chunk {0} bundle.js (main) 155 bytes [rendered]
[0] ./.test/simpleDependency/app.ts 37 bytes {0}
[1] ./.test/simpleDependency/dep.ts 56 bytes {0}
[1] ./.test/simpleDependency/dep.ts 56 bytes {0} [built]
[2] ./.test/simpleDependency/deeperDep.ts 62 bytes {0} [built]
2 changes: 1 addition & 1 deletion test/simpleDependency/expectedOutput-1.8/patch0/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
bundle.js 1.75 kB 0 [emitted] main
chunk {0} bundle.js (main) 197 bytes [rendered]
[0] ./.test/simpleDependency/app.ts 51 bytes {0} [1 error]
[1] ./.test/simpleDependency/dep.ts 70 bytes {0}
[1] ./.test/simpleDependency/dep.ts 70 bytes {0} [built]
[2] ./.test/simpleDependency/deeperDep.ts 76 bytes {0} [built]

ERROR in ./.test/simpleDependency/app.ts
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Asset Size Chunks Chunk Names
bundle.js 1.75 kB 0 [emitted] main
chunk {0} bundle.js (main) 197 bytes [rendered]
[0] ./.test/simpleDependency/app.ts 51 bytes {0}
[1] ./.test/simpleDependency/dep.ts 70 bytes {0}
[2] ./.test/simpleDependency/deeperDep.ts 76 bytes {0} [built]
2 changes: 1 addition & 1 deletion test/simpleDependency/expectedOutput-1.8/patch1/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
bundle.js 1.75 kB 0 [emitted] main
chunk {0} bundle.js (main) 197 bytes [rendered]
[0] ./.test/simpleDependency/app.ts 51 bytes {0}
[1] ./.test/simpleDependency/dep.ts 70 bytes {0}
[1] ./.test/simpleDependency/dep.ts 70 bytes {0} [built]
[2] ./.test/simpleDependency/deeperDep.ts 76 bytes {0} [built]
2 changes: 1 addition & 1 deletion test/simpleDependency/expectedOutput-1.9/patch0/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
bundle.js 1.75 kB 0 [emitted] main
chunk {0} bundle.js (main) 197 bytes [rendered]
[0] ./.test/simpleDependency/app.ts 51 bytes {0} [1 error]
[1] ./.test/simpleDependency/dep.ts 70 bytes {0}
[1] ./.test/simpleDependency/dep.ts 70 bytes {0} [built]
[2] ./.test/simpleDependency/deeperDep.ts 76 bytes {0} [built]

ERROR in ./.test/simpleDependency/app.ts
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Asset Size Chunks Chunk Names
bundle.js 1.75 kB 0 [emitted] main
chunk {0} bundle.js (main) 197 bytes [rendered]
[0] ./.test/simpleDependency/app.ts 51 bytes {0}
[1] ./.test/simpleDependency/dep.ts 70 bytes {0}
[2] ./.test/simpleDependency/deeperDep.ts 76 bytes {0} [built]
2 changes: 1 addition & 1 deletion test/simpleDependency/expectedOutput-1.9/patch1/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
bundle.js 1.75 kB 0 [emitted] main
chunk {0} bundle.js (main) 197 bytes [rendered]
[0] ./.test/simpleDependency/app.ts 51 bytes {0}
[1] ./.test/simpleDependency/dep.ts 70 bytes {0}
[1] ./.test/simpleDependency/dep.ts 70 bytes {0} [built]
[2] ./.test/simpleDependency/deeperDep.ts 76 bytes {0} [built]