Generate sourcemap files with grunt-ts
Generate sourcemap files with grunt-ts
Hi I am beggining a a project with typescript and it uses grunt-ts to compile to javascript.
My configs in a file: tsconfig.json are:
{
"compileOnSave": true,
"compilerOptions": {
"target": "es5",
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"removeComments": false,
"module": "amd",
"resolveJsonModule": true,
"strict": true,
"rootDir": "public_html/",
"outDir": ".tmp/",
"sourceMap": true
},
"include": [
"public_html/web/js/**/*.ts"
],
"exclude": [
"node_modules/"
]
}
My gruntfile.js it's huge but here it is my task that calls tsconfig.json
grunt.initConfig({
...
...
...
ts: {
dev: {
tsconfig: "./tsconfig.json"
}
},
...
});
I am running typescript: version 2.9.2 and grunt-ts version 5.5.1
I have sourceMap defined as true, but when I compile the .map files are not being generated.
What I am doing wrong?
UPDATE
I realize now that my .map files are being generated, altough the code it is in one line. :/
However in Chrome does not show any content in .ts files. In firefox it displays an error message
Error while fetching an original source: request failed with status 404
Source URL: http://localhost:3501/public_html/web/js...
grunt-ts
I @RobC. I updated my question.
– peterK
Jul 2 at 16:32
When I installed
grunt-ts
it came bundled with typescript@1.8.9
and source maps were successfully created using your config. To match your ts version I installed typescript@2.9.2
as a local dependency. Then added the compiler option to my grunt-ts
task in Gruntfile.js as follows; options: { compiler: './node_modules/typescript/bin/tsc' }
to instruct grunt to use the latest ts, and again source maps were successfully created. So you may want to try adding the compiler option to see if that resolves the issue.– RobC
Jul 3 at 8:20
grunt-ts
typescript@1.8.9
typescript@2.9.2
grunt-ts
options: { compiler: './node_modules/typescript/bin/tsc' }
Thanks @RobC. I realized now that my .map files are being generated. I updated the question justo now. The problem could be the path !?
– peterK
Jul 3 at 9:26
Sounds like you've probably moved the generated files (
.js
and .map
) from the .tmp/web/js
directory since they were generated. Doing this is likely to result in the relative paths created in your .map
files being incorrect - hence the error 404 error, they cannot be found.– RobC
Jul 3 at 10:22
.js
.map
.tmp/web/js
.map
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
You'll probably greater your chance of getting a solution/answer if you edit your question to show how your
grunt-ts
task is configured in your Gruntfile.js.– RobC
Jul 2 at 15:16