4

I'm using Sublime Typescript Plugin to transpile Typescript files.

Project folder

enter image description here

I've done all the setup for a sample project with help of tsconfig.json(using Typescript 1.5V). Below is my tsconfig.json

{
    "compilerOptions": {
        "declaration":false,
        "mapRoot":"mapFiles",  
        "module": "commonjs",
        "noImplicitAny": true,
        "outDir": "js",
        "preserveConstEnums": true,
        "removeComments": true,
        "sourceMap": true,
        "sourceRoot": "mapFiles",
        "target":"es3",
        "watch":true,
        "rootDir":""
    }

}

To move all the sourceMap files into other folder(mapFiles) folder rather than keeping in all the files(.js and .map files) in same folder, I've added below config into tsconfig.json

"mapRoot":"mapFiles", 
"sourceMap": true,
"sourceRoot": "mapFiles",

After done the build, Script files are generated successfully along with sourceMappingURL comments. Below is the out of main.ts file.

var x = "will work";
//# sourceMappingURL=E:/type/projects/Examples/ex1/mapFiles/main.js.map

But main.js.map file is not moved the respective folder(mapFiles). It is in same folder where the js file is generated.

Below is my understanding about .maps files:

1. Map files have the details about the respective .ts files with location of it.

2. it is used to track down .ts files easily.

Please let me know how to move sourceMap files to other folders on run-time.

mu is too short
  • 426,620
  • 70
  • 833
  • 800
jayapal
  • 67
  • 10

1 Answers1

3

There is something similar to your question here. Take a look there and you will certainly be able to decide what approach fits your wishes.

I don't see a problem in leaving them both on the same folder whereas *.js.map and *.js won't even be pushed to your repo, just .gitignore them. I use IntelliJ with the Typescript plugin, which already helps to keep my eyes from drying out. Here's how it looks like with my setup.

If there is a reason to separate them and I am not aware of it, then you can write a task that separates them. So keep "mapRoot":"mapFiles", "outDir": "js", in your tsconfig.json and add a script in package.json to move them.

leosteffen
  • 379
  • 2
  • 10