Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Closure compiler exception when sourceMap set to true in tsconfig.json #25

Open
gregmagolan opened this issue Oct 8, 2017 · 4 comments

Comments

@gregmagolan
Copy link

Turning on sourceMap in src/tsconfig.json results in an exception during closure compile:

java.lang.IllegalArgumentException: a source must have a name
	at com.google.javascript.jscomp.SourceFile.<init>(SourceFile.java:106)
	at com.google.javascript.jscomp.SourceFile$OnDisk.<init>(SourceFile.java:606)
	at com.google.javascript.jscomp.SourceFile$Builder.buildFromPath(SourceFile.java:508)
	at com.google.javascript.jscomp.SourceFile.fromPath(SourceFile.java:413)
	at com.google.javascript.jscomp.SourceMapResolver.getRelativePath(SourceMapResolver.java:72)
	at com.google.javascript.jscomp.Compiler.getSourceMapping(Compiler.java:3009)
	at com.google.javascript.jscomp.SourceMap.addMapping(SourceMap.java:164)
	at com.google.javascript.jscomp.CodePrinter$MappedCodePrinter.generateSourceMap(CodePrinter.java:141)
	at com.google.javascript.jscomp.CodePrinter.toSource(CodePrinter.java:904)
	at com.google.javascript.jscomp.CodePrinter.access$300(CodePrinter.java:42)
	at com.google.javascript.jscomp.CodePrinter$Builder.build(CodePrinter.java:828)
	at com.google.javascript.jscomp.Compiler.toSource(Compiler.java:2471)
	at com.google.javascript.jscomp.Compiler.access$700(Compiler.java:101)
	at com.google.javascript.jscomp.Compiler$14.call(Compiler.java:2430)
	at com.google.javascript.jscomp.Compiler$14.call(Compiler.java:2391)
	at com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread(CompilerExecutor.java:128)
	at com.google.javascript.jscomp.Compiler.runInCompilerThread(Compiler.java:860)
	at com.google.javascript.jscomp.Compiler.toSource(Compiler.java:2390)
	at com.google.javascript.jscomp.Compiler$10.call(Compiler.java:2285)
	at com.google.javascript.jscomp.Compiler$10.call(Compiler.java:2267)
	at com.google.javascript.jscomp.CompilerExecutor$2.call(CompilerExecutor.java:101)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
error Command failed with exit code 254.
error Command failed with exit code 1.

I tracked this down to coming from an invalid entry in the sources array in built/src/basic.ngfactory.js.map:

{
  "version": 3,
  "file": "basic.ngfactory.js",
  "sourceRoot": "",
  "sources": [
    "../../src/basic.ngfactory.ts",
    "file:///ng://.../closure-demo/src/basic.ng.html",
    "../../"
  ],
  "names": [],
  "mappings": ";;;;;;;;;;;uDCAA,...,CAAA"
}

The value "../../" in sources ends up creating a null or empty fileName value in the SourceFile ctor which throws the exception. This seems to have been introduced with 5.0.0-rc.0. Could not reproduce with 5.0.0-beta.7. The same "../../" entry is in basic.ngfactory.js.map with 5.0.0-beta.7 but the mappings must be different as the same closure compiler does not throw an exception.

@alexeagle
Copy link
Contributor

@chuckjaz does this look like the source map problem you've been resolving?

@chuckjaz
Copy link

chuckjaz commented Oct 23, 2017

No but it looks like a compiler bug in that we shouldn't be emitting a file without a valid name. Can you a related bug in angular/angular?

@alexeagle
Copy link
Contributor

Also I wonder why we don't see this problem internally.

@tbosch
Copy link

tbosch commented Oct 27, 2017

@alexeagle internally we use inline sourcemaps.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants