Skip to content

fix(core): Let Chrome be able to use source-maps in the style tag #14175

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

Conversation

asnowwolf
Copy link
Contributor

The component style creates a style tag that contains the source-maps, and Chrome will not be able to use it. We need to add /*@ sourceURL=... */ comments to make Chrome happy.

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x")

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior? (You can also link to an open issue here)

The component style will create a style tag that contains the sourcemap information, which chrome will not be able to use

What is the new behavior?

The component style will create a style tag that contains the sourcemap information, which chrome will be able to use it.

Does this PR introduce a breaking change? (check one with "x")

[ ] Yes
[x] No

If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...

Other information:

@asnowwolf asnowwolf force-pushed the source-maps-for-style-tag branch 3 times, most recently from 8ff5c6e to b2b94d1 Compare January 29, 2017 07:58
@asnowwolf asnowwolf changed the title fix(core): Let chrome be able to use source-maps in the style tag fix(core): Let Chrome/Firefox be able to use source-maps in the style tag Jan 29, 2017
@asnowwolf
Copy link
Contributor Author

live example: http://plnkr.co/edit/cUYoQWsYX5mVZhYP5GYa?p=preview

If you append the following css comments to the dynamically generated style tag, you will see the correct source-map in chrome dev tool:

/*# sourceURL=any-name.scss */
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi8uL3NyYy9hcHAvc3JjL2FwcC9hcHAuY29tcG9uZW50LnNjc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7RUFDRSxXQUFVLEVBQ1giLCJmaWxlIjoiYXBwLmNvbXBvbmVudC5zY3NzIiwic291cmNlc0NvbnRlbnQiOlsiZGl2IHtcbiAgY29sb3I6IHJlZDtcbn1cbiJdLCJzb3VyY2VSb290Ijoid2VicGFjazovLyJ9 */

@@ -526,7 +532,7 @@ function stripComments(input: string): string {
}

// all comments except inline source mapping
const _sourceMappingUrlRe = /\/\*\s*#\s*sourceMappingURL=[\s\S]+?\*\//;
const _sourceMappingUrlRe = /\/\*#\s*sourceMappingURL=[\s\S]+?\*\//;
Copy link
Contributor Author

@asnowwolf asnowwolf Jan 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The standard source mapping comment is /*# sourceMappingURL=...*/. So we needn't support /* #sourceMappingURL=... */ variant

@asnowwolf asnowwolf force-pushed the source-maps-for-style-tag branch 5 times, most recently from 226e64d to 2462153 Compare February 2, 2017 05:37
@asnowwolf asnowwolf changed the title fix(core): Let Chrome/Firefox be able to use source-maps in the style tag fix(core): Let Chrome be able to use source-maps in the style tag Feb 2, 2017
@asnowwolf asnowwolf force-pushed the source-maps-for-style-tag branch from 2462153 to 7fbafb0 Compare February 3, 2017 12:12
@asnowwolf
Copy link
Contributor Author

asnowwolf commented Feb 3, 2017 via email

The component style creates a style tag that contains the source-maps, and Chrome will not be able to use it. We need to add `/*@ sourceURL=... */` comments to make Chrome happy.
The `/* #sourceMappingURL` syntax is no longer supported and only supports `/*# sourceMappingURL` and `/*#sourceMappingURL`.
@asnowwolf
Copy link
Contributor Author

@vicb could you please make a review of this PR?

@asnowwolf
Copy link
Contributor Author

Oh, It's outdated. I will close it. if the issue still exists, I will resend a new PR based on the new code base.

@asnowwolf asnowwolf closed this Apr 18, 2017
@asnowwolf
Copy link
Contributor Author

asnowwolf commented Apr 18, 2017

@vicb
In fact, It resolves two bugs. So, I've splitted it to two PRs, see #16088 and #16090.

@p-sara
Copy link

p-sara commented Oct 24, 2017

Did this solution work for anyone? Live demo doesn't work for me. As I understand it will work after changing shadow.css file? What should I change in the given comment?

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants