Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sourceRoot should support relative paths and respect folder hirearchy #5180

Closed
seanzer opened this issue Oct 8, 2015 · 3 comments
Closed
Labels
Question An issue which isn't directly actionable in code

Comments

@seanzer
Copy link

seanzer commented Oct 8, 2015

When supplying sourceRoot, it is just directly copied into the source map file as is. This doesn't work correctly with rootDir and outDir options. For example, if I have the following structure:

repo/src/www/foo.ts
repo/src/bar.ts

and I want to output the files into repo/out/, I tried using sourceRoot: '../src' and that works okay for bar.js, but not www/foo.js. I hope this explanation makes sense.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 8, 2015

sourceRoot represents the root to use by the debug to locate the sources relative to. if you just want a relative path, do not set sourceRoot and the right thing should happen..

so here is my setup:

tsconfig.json

{
    "compilerOptions": {
        "rootDir": "./",
        "outDir": "./out",
        "sourceMap": true
    }
}

compiling, i get:

C:\test\5180>type out\bar.js.map
{"version":3,"file":"bar.js","sourceRoot":"","sources":["../src/bar.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAE,CAAC,CAAC"}
C:\test\5180>type out\www\foo.js.map
{"version":3,"file":"foo.js","sourceRoot":"","sources":["../../src/www/foo.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,CAAC,CAAC"}

@mhegazy mhegazy added the Question An issue which isn't directly actionable in code label Oct 8, 2015
@seanzer
Copy link
Author

seanzer commented Oct 9, 2015

My mistake, it looks like it works when I use tsc. It looks to be an issue with gulp integration. Thanks.

@pleerock
Copy link

@mhegazy @sheetalkamat I have following tsconfig.json:

{
    "compilerOptions": {
        "rootDir": "./",
        "outDir": "./out",
        "sourceMap": true
    }
}

my sources are in ./src
And in source maps I have "sources":["../../src/index.ts"]
This is correct for development, but what I want to do for production build is "sources":["src/index.ts"] (because I emit source maps with source code, and want in production build to have ts near its js). Is there way to do it?

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

3 participants