sourceRoot๋ฅผ ์ ๊ณตํ๋ฉด ๊ทธ๋๋ก ์์ค ๋งต ํ์ผ์ ์ง์ ๋ณต์ฌ๋ฉ๋๋ค. ์ด๊ฒ์ rootDir ๋ฐ outDir ์ต์ ์์ ์ฌ๋ฐ๋ฅด๊ฒ ์๋ํ์ง ์์ต๋๋ค. ์๋ฅผ ๋ค์ด ๋ค์๊ณผ ๊ฐ์ ๊ตฌ์กฐ๊ฐ์๋ ๊ฒฝ์ฐ :
repo / src / www / foo.ts
repo / src / bar.ts
๊ทธ๋ฆฌ๊ณ ํ์ผ์ repo / out /์ผ๋ก ์ถ๋ ฅํ๊ณ ์ถ์ต๋๋ค .sourceRoot : '../src'๋ฅผ ์ฌ์ฉํด ๋ณด์์ต๋๋ค. bar.js์์๋ ์ ๋๋ก ์๋ํ์ง๋ง www / foo.js์์๋ ์๋ํ์ง ์์ต๋๋ค. ์ด ์ค๋ช ์ด ์ดํด๋๊ธฐ๋ฅผ ๋ฐ๋๋๋ค.
sourceRoot
๋ ๊ด๋ จ ์์ค๋ฅผ ์ฐพ๊ธฐ ์ํด ๋๋ฒ๊ทธ์์ ์ฌ์ฉํ ๋ฃจํธ๋ฅผ ๋ํ๋
๋๋ค. ์๋ ๊ฒฝ๋ก ๋ง ์ํ๋ ๊ฒฝ์ฐ sourceRoot๋ฅผ ์ค์ ํ์ง ๋ง์ญ์์ค. ์ฌ๋ฐ๋ฅธ ์ผ์ด ๋ฐ์ํด์ผํฉ๋๋ค.
๊ทธ๋์ ์ฌ๊ธฐ์ ๋ด ์ค์ ์ด ์์ต๋๋ค.
tsconfig.json
{
"compilerOptions": {
"rootDir": "./",
"outDir": "./out",
"sourceMap": true
}
}
์ปดํ์ผํ๋ฉด ๋ค์์ ์ป์ต๋๋ค.
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"}
๋ด ์ค์, tsc๋ฅผ ์ฌ์ฉํ ๋ ์๋ํ๋ ๊ฒ ๊ฐ์ต๋๋ค. gulp ํตํฉ์ ๋ฌธ์ ๊ฐ์๋ ๊ฒ ๊ฐ์ต๋๋ค. ๊ฐ์ฌ.
@mhegazy @sheetalkamat ๋ค์๊ณผ ๊ฐ์ tsconfig.json์ด ์์ต๋๋ค.
{
"compilerOptions": {
"rootDir": "./",
"outDir": "./out",
"sourceMap": true
}
}
๋ด ์์ค๋ ./src์ ์์ต๋๋ค.
์์ค ๋งต์๋ "sources":["../../src/index.ts"]
์ด๊ฒ์ ๊ฐ๋ฐ์๋ ๋ง์ง๋ง ํ๋ก๋์
๋น๋๋ฅผ ์ํด ๋ด๊ฐ ์ํ๋ ๊ฒ์ "sources":["src/index.ts"]
(์๋ํ๋ฉด ์์ค ์ฝ๋๋ก ์์ค ๋งต์ ๋ด๋ณด๋ด๊ณ ํ๋ก๋์
๋น๋์์ js ๊ทผ์ฒ์ ts๋ฅผ ๊ฐ๊ธฐ๋ฅผ ์ํ๊ธฐ ๋๋ฌธ์
๋๋ค). ํ ๋ฐฉ๋ฒ์ด ์์ต๋๊น?
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
@mhegazy @sheetalkamat ๋ค์๊ณผ ๊ฐ์ tsconfig.json์ด ์์ต๋๋ค.
๋ด ์์ค๋ ./src์ ์์ต๋๋ค.
์์ค ๋งต์๋
"sources":["../../src/index.ts"]
์ด๊ฒ์ ๊ฐ๋ฐ์๋ ๋ง์ง๋ง ํ๋ก๋์ ๋น๋๋ฅผ ์ํด ๋ด๊ฐ ์ํ๋ ๊ฒ์
"sources":["src/index.ts"]
(์๋ํ๋ฉด ์์ค ์ฝ๋๋ก ์์ค ๋งต์ ๋ด๋ณด๋ด๊ณ ํ๋ก๋์ ๋น๋์์ js ๊ทผ์ฒ์ ts๋ฅผ ๊ฐ๊ธฐ๋ฅผ ์ํ๊ธฐ ๋๋ฌธ์ ๋๋ค). ํ ๋ฐฉ๋ฒ์ด ์์ต๋๊น?