Skip to content

Remove source mapping URL from non minified source code #3485

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

Closed
1 of 3 tasks
adamreisnz opened this issue Jun 24, 2017 · 7 comments
Closed
1 of 3 tasks

Remove source mapping URL from non minified source code #3485

adamreisnz opened this issue Jun 24, 2017 · 7 comments
Milestone

Comments

@adamreisnz
Copy link

adamreisnz commented Jun 24, 2017

This is a:

  • Bug Report
  • Feature Request
  • General Query

My version of UI-Router is: 1.0.3

Bug Report

Current Behavior:

The following line is included in the unminified source code of ui-router:

//# sourceMappingURL=angular-ui-router.js.map

This now causes an error in my chrome console:

DevTools failed to parse SourceMap: http://localhost:8080/lib/angular-ui-router.js.map

This is because I don't include (and don't want to include) the pre-rolled sourcemap for ui-router. I bundle the unminified source code into a vendor package and roll my own sourcemaps from that.

As such, this sourcemapping is redundant and problematic causing dev tools to look for non-existent source maps.

Expected Behavior:

Only include source map reference in the minified code and let developers handle it themselves if they want to use the non-minfied code. Don't include source map in the non-minified code.

Link to Plunker that reproduces the issue:

Cannot be demonstrated in a Plunkr because the source map is provided on the CDN.

@adamreisnz
Copy link
Author

Not sure if this was caused by the request in #2378

@adamreisnz
Copy link
Author

adamreisnz commented Jun 24, 2017

Workaround is to strip all comments from the source codes in build process, but still I don't think it should be included by default for non minified source files. The whole point of source maps is to unmangle minified code and make it possible to debug it. Unminified source code is already possible to debug...

@aeisenberg
Copy link

Possible duplicate of #3465

@aeisenberg
Copy link

And ui-router/core#58 fixes the problem by including the proper files in the built package and allows you to debug with correct sources as well.

@christopherthielen
Copy link
Contributor

christopherthielen commented Jun 26, 2017

We may take a different approach by embedding the sourcemaps inline into the es5 transpiled code. Please see ui-router/angular#136 and comment

Note: The es5 files would have the sourcemaps embedded. However, when we generate bundles, the sourcemaps would be extracted to external .map files.

Let me know if you anyone has concerns with this approach. I think this should solve for most cases without packaging the source files.

@aeisenberg
Copy link

I'm not sure if this alone will fix the problem. Here are my thoughts:

  1. The problem exists in both ui-router/angular and ui-router/core. So, the same fix would need to be applied to both.
  2. The problem isn't the lack of source maps. The problem is that the source maps point to sources that don't exist. The sourcemaps include URLs to the original sources. If the sources don't exist, then that causes a 404 error and makes ui-router very difficult to debug. Additionally, some other tools seem to stop working as well. As far as I can tell, there is no way around including the original sources if you include source maps.

Can I ask why you are reticent to include the source files in the non-minified release?

@aeisenberg
Copy link

Oh, right. It looks like this option will inline the sources into the actual target file. If that's the case, then this solution will probably be fine. Though it still needs to be applied to both projects. Thanks for addressing this problem.

@christopherthielen christopherthielen added this to the 1.0.5 milestone Jul 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants