Empty files break sourcemap
See original GitHub issueOccasionally you have a step (in my case, typescript compilation) that generates an empty file. This causes concat to fail.
<root>/applications/gulp-tools/node_modules/gulp-concat/node_modules/concat-with-sourcemaps/node_modules/source-map/lib/source-map/source-map-generator.js:273
throw new Error('Invalid mapping: ' + JSON.stringify({
^
Error: Invalid mapping: {"generated":{"line":1,"column":0},"original":{"line":1,"column":0},"name":null}
at SourceMapGenerator_validateMapping [as _validateMapping] (<root>/applications/gulp-tools/node_modules/gulp-concat/node_modules/concat-with-sourcemaps/node_modules/source-map/lib/source-map/source-map-generator.js:273:15)
at SourceMapGenerator_addMapping [as addMapping] (<root>/applications/gulp-tools/node_modules/gulp-concat/node_modules/concat-with-sourcemaps/node_modules/source-map/lib/source-map/source-map-generator.js:102:12)
at Concat.add (<root>/applications/gulp-tools/node_modules/gulp-concat/node_modules/concat-with-sourcemaps/index.js:75:25)
at Stream.bufferContents (<root>/applications/gulp-tools/node_modules/gulp-concat/index.js:35:12)
at Stream.stream.write (<root>/applications/gulp-tools/node_modules/gulp-concat/node_modules/through/index.js:26:11)
at write (_stream_readable.js:583:24)
at flow (_stream_readable.js:592:7)
at CompileStream.pipeOnReadable (_stream_readable.js:624:5)
at CompileStream.EventEmitter.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:408:10)
at emitReadable (_stream_readable.js:404:5)
at readableAddChunk (_stream_readable.js:165:9)
at CompileStream.Readable.push (_stream_readable.js:127:10)
at emit (<root>/applications/gulp-tools/node_modules/gulp-typescript/release/project.js:245:22)
at sortedEmit (<root>/applications/gulp-tools/node_modules/gulp-typescript/release/project.js:267:17)
at Project.compile (<root>/applications/gulp-tools/node_modules/gulp-typescript/release/project.js:273:17)
at CompileStream.compile (<root>/applications/gulp-tools/node_modules/gulp-typescript/release/main.js:53:23)
at CompileStream.end (<root>/applications/gulp-tools/node_modules/gulp-typescript/release/main.js:63:14)
at DestroyableTransform.onend (<root>/applications/gulp-tools/node_modules/gulp-sourcemaps/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:523:10)
at DestroyableTransform.g (events.js:180:16)
at DestroyableTransform.EventEmitter.emit (events.js:117:20)
at <root>/applications/gulp-tools/node_modules/gulp-sourcemaps/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:965:16
at process._tickDomainCallback (node.js:459:13)
Here is an example of the task that causes this failure.
var ts = require('gulp-typescript');
var concat = require('gulp-concat');
var sourcemaps = require('gulp-sourcemaps');
gulp.task('compile-ts', function () {
var compile = gulp.src(conf.tscSources)
.pipe(sourcemaps.init())
.pipe(ts({
declarationFiles: true,
noExternalResolve: true,
sortOutput: true,
target: 'ES5'
}));
return compile.js
.pipe(concat('app.js'))
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest(conf.distDir));
});
While it’s relatively trivial to filter empty files from a stream I believe not doing so shouldn’t cause concat to tank.
Issue Analytics
- State:
- Created 9 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
names array empty for all files #9627 - Sourcemap - GitHub
All of my map files have the names array empty. I would expect that to have been populated. This has been an issue...
Read more >4 Reasons Why Your Source Maps are Broken - Sentry Blog
4 Reasons Why Your Source Maps are Broken · Missing or incorrect source map directive · Missing original source files · Bad source...
Read more >How to get Chrome to reload source maps? - Stack Overflow
Open the source map in a browser tab and do a hard reload (depending on OS, try CTRL + F5 ). This refreshes...
Read more >Options - Babel.js
Options. Primary options; Config Loading options; Plugin and Preset configuration; Config Merging options; Source Map options; Misc options ...
Read more >Emitting source maps - Learn TypeScript
Generating source map files ... A source map file maps from the transpiled JavaScript file to the ... The execution breaks on the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@floridoo could you elaborate on this fix you made please. I am running into the issue and not sure what exactly went wrong.
Thanks @floridoo