source code not inlined in sourcemap files
With the following directory structure:
Source:
./src
└ main
└ webapp
└ src
├ file1.ts
└ file2.ts
when I execute the following 'test' task:
gulp.task('test', function() {
gulp.src('src/main/webapp/**/*.ts')
.pipe(sourcemaps.init())
.pipe(ts({sourceRoot: ''}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('build/webapp/main/'));
});
the directory structure is recreated correctly in the destination folder:
Destination:
./build
└ webapp
└ main
└ src
├ file1.js
├ file1.js.map
├ file2.js
└ file2.js.map
however the .map files are incorrect. With:
.pipe(ts({sourceRoot: ''}))
I get no source code inlined in the map and an invalid 'sourceRoot':
{
version: 3,
sources: ["file1.ts"],
names: [...],
mappings: "...",
file: "src/file1.js",
sourceRoot: "/source/",
sourcesContent: [null]
}
with:
.pipe(ts())
I get no source code inlined in the map and 'sourceRoot' set to my project root:
{
version: 3,
sources: ["file1.ts"],
names: [...],
mappings: "...",
file: "src/file1.js",
sourceRoot: "C:/Dev/prj/foo/",
sourcesContent: [null]
}
with:
.pipe(ts({sourceRoot: 'src/'}))
sort of works. The source code is inlined and 'sourceRoot' is correct. However 'sources' relative path is still missing and, since 'sourceRoot' cannot be changed dynamically for every directory, it'll only work for the first '/src' directory level.
{
version: 3,
sources: ["file1.ts"],
names: [...],
mappings: "...",
file: "src/file1.js",
sourceRoot: "src/",
sourcesContent: ['file1.ts' source code]
}
in my opinion the final sourcemap file should be as follow (with 'sourceRoot' not present since it's not needed because the source code is inlined):
{
version: 3,
sources: ["src/file1.ts"],
names: [...],
mappings: "...",
file: "src/file1.js",
sourcesContent: ['file1.ts' source code]
}
And finally when I execute the 'test' task with concat and uglify:
gulp.task('test', function() {
gulp.src('src/main/webapp/**/*.ts')
.pipe(sourcemaps.init())
.pipe(ts({sourceRoot: 'src/'}))
.pipe(concat('src/bundle.min.js'))
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('build/webapp/main/'));
});
'src/bundle.min.js' is properly generated, its name is added to the sourcemap list of sources, but not its source code, resulting in a 'ghost' file in chrome javascript console:
{
version: 3,
sources: ["src/file1.ts", "src/file2.ts", "src/bundle.min.js"],
names: [...],
mappings: "...",
file: "src/bundle.min.js",
sourcesContent: ['file1.ts', 'file2.ts' but not 'bundle.min.js']
}
Looks to be related to #52, so this should be fixed now too.