← 输入框|github.com|刷新
Skip to content

fix(compiler): Don't strip /*# ... */ comment when css scoping - #18641

Merged
hansl merged 1 commit into
angular:masterfrom
asnowwolf:dont-strip-hash-comment
Aug 15, 2017
Merged

hansl merged 1 commit into
angular:masterfrom
asnowwolf:dont-strip-hash-comment

Conversation

@asnowwolf

Copy link
Copy Markdown
Contributor

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "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)

Currently, the source-mapping comments of component style is stripped by extractStyleUrls, so, css mappings don't work properly for component styles.

What is the new behavior?

Don't strip hash comments, so that they will be past to style tags properly.

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

  • Yes
  • No

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

Other information:

@asnowwolf

Copy link
Copy Markdown
Contributor Author

Sorry, when i merge the latest branch, a misuse destroys #16090 , this one is a re-pushed version that has merged the latest master.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could we make it more robust by using a replace fn that would:

  • check if [0] === '#'
  • check if the content contains sourceURL= or sourceMappingURL=

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Did you mean that all of the comments that begin with # are likely to leave something that we do not want to keep, So we should only ignore the known sourceURL and sourceMappingURL? If so, I will try to revise it.

@vicb vicb added action: review The PR is still awaiting reviews from at least one requested reviewer area: core Issues related to the framework runtime labels Aug 11, 2017
@asnowwolf
asnowwolf force-pushed the dont-strip-hash-comment branch 5 times, most recently from fded4c3 to ef337b0 Compare August 12, 2017 03:38
@asnowwolf

Copy link
Copy Markdown
Contributor Author

There are some questions: whether we should support the legacy format /* @, and abnormal format /*# (no spaces between * and #, it's illegal, but exists.)

@asnowwolf

Copy link
Copy Markdown
Contributor Author

It seems that CI has failed, but I have been tested in the local development environment, and CI's failure seems to be due to random factors. Do I need to trigger CI until it runs successfully?

@Toxicable

Copy link
Copy Markdown

Looks due to a flake to me, i'd give suggest giving it a rerun

@asnowwolf
asnowwolf force-pushed the dont-strip-hash-comment branch from ef337b0 to 26291f4 Compare August 12, 2017 08:00
@asnowwolf

Copy link
Copy Markdown
Contributor Author

The aio-e2e-* tasks failed. I think this is the problem of CI itself.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you could just change the RegExp to /\/\*(?!# source(?:Mapping)?URL=)[\s\S]+?\*\//g and leave everything else as it was.
(Not that it matters much 😁)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think it's better too.

@asnowwolf
asnowwolf force-pushed the dont-strip-hash-comment branch 8 times, most recently from f36c4a4 to 0bcc85a Compare August 13, 2017 01:20
@vicb vicb added the target: major This PR is targeted for the next major release label Aug 14, 2017
@vicb

vicb commented Aug 14, 2017

Copy link
Copy Markdown
Contributor

The changes LGTM.

We should merge to master only as the behavior is different (we now keep comment when they contain source maps).

@asnowwolf could you please change the commit message to match the changes you've made and give more info:

fix(compiler): Don't strip CSS source maps 

Fix CSS source mapping for component by keeping `/*# sourceMappingURL= ... */` and  `/*# sourceURL= ... */` comments

Also please add links to the issues related to this PR (relates to #.... of fixes #...).

@asnowwolf
asnowwolf force-pushed the dont-strip-hash-comment branch from 0bcc85a to 94e1b4c Compare August 15, 2017 00:29
@asnowwolf

Copy link
Copy Markdown
Contributor Author

Done, but here is not a related issue, the relevant issue in the angular-cli repository.

@asnowwolf
asnowwolf force-pushed the dont-strip-hash-comment branch from 94e1b4c to 62d796b Compare August 15, 2017 14:00
Fix CSS source mapping for component by keeping `/*# sourceMappingURL= ... */` and  `/*# sourceURL= ... */` comments.

Relates to <angular/angular-cli#4199>.
@vicb

vicb commented Aug 15, 2017

Copy link
Copy Markdown
Contributor

Changes LGTM.
Travis was red, restarted.

@vicb vicb added state: Follow Up action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer state: Follow Up labels Aug 15, 2017
@asnowwolf

Copy link
Copy Markdown
Contributor Author

BTW:

What is going to do with #16088 ? It is aimed at a BUG that appears only in Chrome (and possibly a feature in Chrome because it's been there for a long time, so there's a special Chrome plugin to fix it). In addition, it can be modified by modifying the Angular-CLI or other toolchain.

Is it worth merging here? Do I need to turn it off and to find other ways to solve it?

@hansl
hansl merged commit 64b4be9 into angular:master Aug 15, 2017
@asnowwolf
asnowwolf deleted the dont-strip-hash-comment branch August 15, 2017 23:34
@mwijnands

Copy link
Copy Markdown

Can this be fixed in a 4.x release as well? Behavior changed but how would it affect anything? Also it's mentioned in the changelog as a bugfix, not a breaking change.

@angular-automatic-lock-bot

Copy link
Copy Markdown

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

action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime cla: yes target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants