Comments (8)
Does setting the sourceRoot
option to ''
solve this? Changing the default value of sourceRoot
to an empty string might solve this issue. Mentioning @shiwano since he added sourceRoot option.
from gulp-typescript.
Setting sourceRoot to empty string did work, thanks!
On Sat, Jan 17, 2015 at 8:48 PM, Ivo Gabe de Wolff <[email protected]
wrote:
Does setting the sourceRoot option to '' solve this? Changing the default
value of sourceRoot to an empty string might solve this issue. Mentioning
@shiwano https://github.com/shiwano since he added sourceRoot option.—
Reply to this email directly or view it on GitHub
#52 (comment)
.
from gulp-typescript.
Unfortunately, I'm getting the same issue, and setting sourceRoot to '' doesn't appear to resolve it. My build step looks like this:
gulp.task('tsc', [], function () {
'use strict';
var tsRes = gulp.src('src/*.ts', { base: './' })
.pipe($.sourcemaps.init())
.pipe($.typescript({
target: 'ES6',
sortOutput: true
}));
return tsRes.js
.pipe($.concat('script.js'))
.pipe($.sourcemaps.write('.', { includeContent: false, sourceRoot: '' }))
.pipe(gulp.dest('./dist'));
});
My TypeScript files are all internal modules present under the 'src' directory, and the generated sourcemap's 'sources' collection ends up containing all absolute paths; while the map file the TypeScript compiler generates when using the --out flag has relative paths.
from gulp-typescript.
Can you set the base property in the options object of gulp-typescript instead of gulp-sourcemaps?
from gulp-typescript.
That solved it, cheers for the help.
Edit: Looks like I was mistaken, the first step of the build is now as follows
var tsRes = gulp.src(files.ts)
.pipe($.sourcemaps.init())
.pipe($.typescript({
target: 'ES6',
sortOutput: true,
base: './'
}));
And I'm still getting absolute filepaths in the sourcemap, any further suggestions would be appreciated.
from gulp-typescript.
I'm also having the same problem. My gulpfile has this:
gulp.src("app/**/*.ts")
.pipe(sourcemap.init())
// .pipe(typescript({base:"."})).js
.pipe(concat("app.js"))
.pipe(uglify())
.pipe(sourcemap.write(".", { includeContent: false }))
.pipe(gulp.dest("."));
With the typescript line commented out (they're still plain javascript files, I'm trying to migrate to typescript), the map file contains relative paths. With the line uncommented, the map file contains absolute paths.
I tried:
- adding {base:"."} to the call to src()
- adding sourceRoot to sourcemap.write's options
- changing, or removing the base option in the call to typescript
- removing the .js call at the end of the line that calls typescipt
but I haven't found a way to get it to use relative urls with typescript yet.
from gulp-typescript.
I had solved the absolute path problem putting:
sourceRoot : ''
in my typescript project object like this:
var typeScriptProject = typescript.createProject({
declarationFiles: false,
noExternalResolve: false,
removeComments: false,
sourceRoot: ''
});
but a new problem arise...
I have source files organized in folders but when I put sourceRoot in project properties all the files paths are removed and the file are flattened out.
This is the section of map file without sourceRoot:
"sources": [
"C:/Development/FrontEnd/scripts/module.ts",
"C:/Development/FrontEnd/scripts/controllers/controllers.ts"
]
but with sourceRoot = '':
"sources": [
"module.ts",
"controllers.ts"
]
I would expect this kind of result:
"sources": [
"module.ts",
"controllers/controllers.ts"
]
as I get when i sourcemap javascript instead typescript.
from gulp-typescript.
Solved by removing the sourceRoot option. Because the sourceRoot property was present in the source map, gulp-concat would add that to the source property of the source map generated by gulp-concat, which resulted in an absolute path. That's now fixed by removing sourceRoot from the source-map generated by TypeScript.
Also I removed the sourceRoot option, since gulp-sourcemap has a sourceRoot option. Gulpfiles should now look like:
return gulp.src('lib/**/**.ts')
.pipe(sourcemaps.init())
.pipe(ts())
.pipe(sourcemaps.write())
.pipe(gulp.dest('release'));
If you want to provide a sourceRoot option, you can use
.pipe(sourcemaps.write('.', { sourceRoot: 'foo' }))
from gulp-typescript.
Related Issues (20)
- TypeScript semantic errors angularJs 1.8.2 with gulp, not sure why its compiling the node_modules even though its excluded
- Definitions are not created HOT 2
- Unexpected promisified pipeline behavior when the plugin is included HOT 1
- glob-parent vulnerability
- Package maintaining HOT 13
- Not produce json module to destination directory ? HOT 18
- Wrong reference in source map for files in subfolders HOT 3
- paths work incorrect HOT 4
- Add Typescript 4 to list of peer dependancies HOT 1
- Generate d.ts using Omit not Pick
- Unable to OR'd the variables using the symple '||=' in [email protected] HOT 2
- gulp-typescript doesn't resolve @types in outter node_modules
- use gulp and gupl-typescript to compile but found error TS2724: '"react"' has no exported member named 'SFCElement'. Did you mean 'CElement'? HOT 1
- Filter files with supported file extensions HOT 1
- tsconfig's rootDirs overridden by synthesized rootDir in compiler.ts HOT 3
- composite makes gulp fail but not tsc HOT 1
- is recent version of gulp-typescript has bug with 'typeRoots' attribute?
- Node 18: You must provide the URL of lib/mappings.wasm by calling `SourceMapConsumer.initialize`
- How to generate only .d.ts files without transforming .ts to .js ? HOT 1
- high severity vulnerabilities HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gulp-typescript.