Closed chuckdumont closed 6 years ago
@chuckdumont Hmm, it seems more like a bug. I'm not entirely sure what should be done to solve this. @jscheid was working on source maps support, maybe he can shed some light here.
I also have this issue. Here is my configuration:
new ClosureCompilerPlugin({ compiler: { language_in: 'ECMASCRIPT6', language_out: 'ECMASCRIPT5', compilation_level: 'SIMPLE_OPTIMIZATIONS', create_source_map: true } })
Still problem exists @jscheid , is there any solution for this or do you recommend to move away from closure compiler ?
thanks
Find these lines:
outputSourceMap.sources = [];
outputSourceMap.sources.push(task.file);
and add debug output before:
console.log("outputSourceMap.sources=", outputSourceMap.sources, "task.file=", task.file);
Post the result here and it might shed some light on what the problem is.
this is the result
outputSourceMap.sources= [
' [synthetic:base] ',
' [synthetic:util/defines] ',
' [synthetic:util/defineproperty] ',
' [synthetic:util/global] ',
' [synthetic:es6/symbol] ',
' [synthetic:es6/util/makeiterator] ',
' [synthetic:es6/util/inherits] ',
' [synthetic:util/polyfill] ',
' [synthetic:es6/promise] ',
' [synthetic:util/checkstringargs] ',
' [synthetic:es6/string/startswith] ',
' [synthetic:es6/object/is] ',
' [synthetic:es6/array/includes] ',
' [synthetic:es6/string/includes] ',
' [synthetic:es6/util/iteratorfromarray] ',
' [synthetic:es6/array/keys] ',
' [synthetic:es6/array/values] ',
' [synthetic:es6/number/isfinite] ',
' [synthetic:es6/number/isinteger] ',
' [synthetic:util/owns] ',
' [synthetic:es6/object/assign] ',
' [synthetic:es6/object/getownpropertysymbols] ',
'stdin',
' [synthetic:1] ',
' [synthetic:2] ',
' [synthetic:3] ',
' [synthetic:4] ',
' [synthetic:5] ',
' [synthetic:7] ',
' [synthetic:6] ',
' [synthetic:8] ' ] task.file= server/app.js
so i did the following
// outputSourceMap.sources = [];
outputSourceMap.sources.unshift(task.file);
i commented out the new array and add my task file at the beginning of the array
At least it compiles now without error, but of course my sourcemap have all these elements i don't need and i can also not see my ts files
hope this helps
there's a similar issue some time ago here https://github.com/TypeStrong/ts-loader/issues/81
I was able to fix the problem with the following:
// outputSourceMap.sources = []
// outputSoruceMap.push(task.file)
outputSourceMap.sources = outputSourceMap.sources.map(source => source === 'stdin' ? task.file : source);
@zeronone Are you sure it's not
outputSourceMap.sources = outputSourceMap.sources.map(source => source === 'stdin' ? task.file : source);
As you're code doesn't change the outputSourceMap.sources
@Ninerian Oops sorry, copy paste mistake. Edited the post.
Is this issue still present?
I believe this issue was resolved with the above referenced pull request.
Cool, closing then. Thanks.
Here's my config:
Following is the full stack trace:
And the version of closure.
The problem seems to be with the following code in index.js:
The plugin is replacing the sources array produced by closure with a single element array containing the input filename. The problem is that the original sources array contains more than one element (10 in my case) and these sources elements are referenced by the mappings, so when SourceMapGenerator.fromSourceMap() is subsequently called to generate a source map file from this source map, then references to the removed sources array elements cause the exception.
Following is the contents of the sources array generated by the compiler before it is overwritten by the above code:
Are there any compiler options I can try to work around this problem?