You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've got a problem with Chrome Google Dev Tools not being able to point to a correct line in minified js source. This is hard to explain so I've prepared a zip file, which allows me to reproduce the problem.
Run grunt build -> will run r.js to concatenate & minify relevant .js files
Run php -S localhost:8080 -> will serve the directory over http (requires php 5.4).
Open Google Chrome. Go to localhost:8080 -> a blank page should open
Open Developers Tools.
Go to to the Console tab. -> You should see, that an error occurred in page1.ts file. The link should take you to the .ts file which contains the error. This shows, that typescript source maps works correctly.
Edit index.html. Comment line baseUrl: "/js/ts-compiled",. Uncomment line baseUrl: "/js/ts-compiled-optimized",. Save the file.
Refresh the page in Google Chrome. -> You should see, that an error occurred in page1.js:1 file. The link should take you to the .js file which contains the error. If you beautify the .js file using the Google Chrome dev tools feature, you can see, that Google Chrome points to the correct place in the file. So everything's still working.
Edit Gruntfile. Uncomment lines: generateSourceMaps: true, and preserveLicenseComments: false,. Save the file.
Run grunt build.
Refresh the page in Google Chrome. -> You should see, that an error occurred in widget1.js file. The link should take you to the unminified version of widget1.js.
So, two things about the step 14.:
Google Chrome points to a unminified file, which is good.
Google Chrome doesn't point to the file, where the error occurred. (i.e. to the page.js file).
Did I mess up something with my r.js configuration? I tried different things, but I couldn't make it work correctly.
The other thing is: is it possible to configure r.js/uglify2 to create source maps in such a way, that they point to the original .ts files after the minification? I read this post: link, but:
It uses uglify grunt task to do the job. It's ok, but I would rather not over-complicate my build procedure with yet another moving part. I would rather use r.js itself for talking with the uglifyjs2.
It assumes, that there is only one file, that is produced. I would like to provide a directory of source maps, that needs to be included in the final source maps generation, because I would like to use requirejs, to implement a multipage-require solution (1 common file and a bunch of page*.js files) (see the provided .zip file; I didn't exactly follow this solution, because I need to support a legacy code).
So far I'm very happy with the requirejs and r.js. The source maps issue is the last thing that currently bothers me (although it is an issue only for the production environment, because in dev I don't minify those files which is faster and which allows me to use .ts source maps). I'd appreciate a hand here.
Thanks.
The text was updated successfully, but these errors were encountered:
Source map support has been uneven just given browser bugs and issues with proper chaining against tools. Bug #470 goes into more of the issues. The example is really helpful, thanks for putting it together. It has been difficult for me to work through all the source map issues, so I am not sure when or how it will get sorted yet though.
Thanks for a quick response. I'm glad you found my example helpful. Not having those source maps working entirely how they should is not a show-stopper for me, so take as much time as you need to make a decision on how to tackle this matter. I'm now following the #470 ticket. It's good to know, that I'm not the only one finding this as an issue.
Thanks for require.js, James. It's really a piece of good software.
Hello there,
I've got a problem with Chrome Google Dev Tools not being able to point to a correct line in minified js source. This is hard to explain so I've prepared a zip file, which allows me to reproduce the problem.
link to the zip file
npm install
.grunt
-> will compile typescript filesgrunt build
-> will run r.js to concatenate & minify relevant .js filesphp -S localhost:8080
-> will serve the directory over http (requires php 5.4).localhost:8080
-> a blank page should openpage1.ts
file. The link should take you to the.ts
file which contains the error. This shows, thattypescript
source maps works correctly.index.html
. Comment linebaseUrl: "/js/ts-compiled",
. Uncomment linebaseUrl: "/js/ts-compiled-optimized",
. Save the file.page1.js:1
file. The link should take you to the.js
file which contains the error. If you beautify the.js
file using the Google Chrome dev tools feature, you can see, that Google Chrome points to the correct place in the file. So everything's still working.Gruntfile
. Uncomment lines:generateSourceMaps: true,
andpreserveLicenseComments: false,
. Save the file.grunt build
.widget1.js
file. The link should take you to the unminified version ofwidget1.js
.So, two things about the step 14.:
page.js
file).Did I mess up something with my r.js configuration? I tried different things, but I couldn't make it work correctly.
The other thing is: is it possible to configure r.js/uglify2 to create source maps in such a way, that they point to the original
.ts
files after the minification? I read this post: link, but:uglify
grunt task to do the job. It's ok, but I would rather not over-complicate my build procedure with yet another moving part. I would rather user.js
itself for talking with theuglifyjs2
..zip
file; I didn't exactly follow this solution, because I need to support a legacy code).So far I'm very happy with the requirejs and r.js. The source maps issue is the last thing that currently bothers me (although it is an issue only for the production environment, because in dev I don't minify those files which is faster and which allows me to use .ts source maps). I'd appreciate a hand here.
Thanks.
The text was updated successfully, but these errors were encountered: