-
-
Notifications
You must be signed in to change notification settings - Fork 471
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
refactor: use annotation comments for source maps (options.sourceMap
)
#219
refactor: use annotation comments for source maps (options.sourceMap
)
#219
Conversation
I set @john-bai as the author of the commit as almost the whole code is his. I can add tests in a separate commit. |
@mgol You mentioned Chrome && Firefox. Do you know the status in Safari/Edge ? (General browser support/limitations) since this a breaking change we need to know, how to handle eventual support for folks unable to use this immediately for some reason, or maybe (hopefully) it's widely enough supported, so we can just recommend to modify their setup in one way or the other so it works for the majority 😛 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one small thing, thx 👍 in advance, this PR is a really nice and needed cleanup :)
package.json
Outdated
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "style-loader", | |||
"version": "0.16.1", | |||
"version": "0.16.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't 😛, we use standard-version
for release management across webpack-contrib and this is the responsibility of the respective maintainer(s)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. A bad merge, I didn't intend to mess with this field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep no offense I thought so 😛
6619acf
to
8ac2325
Compare
@mgol Test(s) would be highly appreciated, but you mentioned it's better do it in a separate PR which is ok as long as their will be one 😛 . Otherwise browser support and how strongly this affects current users is the elefant in the room :D |
@michael-ciniawsky I did some testing:
I still think the Let me know what you think. EDIT: Reported issues: |
First thx very much for investigating on this futher 👍 , personally I would prefer a "Best used with Chrome/Firefox' 😛 note/warning in the README instead of a bloated inconvenient 'ducktape' approach in |
@michael-ciniawsky does #153 influence this PR as well? |
@mgol I'm not 💯 about that fact |
I’m using this in a project, and it seems to work just fine. Sad to see that there are merge conflicts now, though! |
@mgol Could you rebase one more time and change the base branch |
Fixes broken relative and protocol-relative url() use in stylesheets when source maps are enabled. Chrome >=57 and Firefox >=50.1 support loading source maps when sourceMapURL directive is dynamically added to a new or existing style element in the DOM. This means that style-loader can simply add the styles and sourceMapURL directive as text inside a style element and the source map will be loaded by the browser. Given the simpler insertion method, the relative and protocol-relative urls in stylesheets will not break.
d16feca
to
8a17918
Compare
@michael-ciniawsky Done. |
@mgol maybe best create new PR? |
@evilebottnawi Why? It's already rebased. Do you want to have clearer conversation or something? Note that @john-bai is still marked as the author of the commit in this PR as I based my PR on his one. |
Also, perhaps some source map tests would be useful to make sure this feature works correctly. Although we won't be able to unit-test that mappings work in the browser. |
Any progress on getting this PR merged in? |
options.sourceMap
)
Fixes #165 webpack-contrib/style-loader#165 Using #219 refactor: use annotation comments for source maps (`options.sourceMap`) webpack-contrib/style-loader#219
Would like to add to @kevinzang comment that downloading the latest version |
This is a rebase of PR #165 with minor modifications (e.g. a complete removal of
fixUrls.js
.Fixes broken relative and protocol-relative url() use in stylesheets when
source maps are enabled. Chrome >=57 and Firefox >=50.1 support loading source
maps when sourceMapURL directive is dynamically added to a new or existing style
element in the DOM. This means that style-loader can simply add the styles and
sourceMapURL directive as text inside a style element and the source map will be
loaded by the browser. Given the simpler insertion method, the relative and
protocol-relative urls in stylesheets will not break.
Fixes #121
Ref #93
What kind of change does this PR introduce?
Bugfix + breaking change.
Did you add tests for your changes?
Not yet.
If relevant, did you update the README?
Yes.
Summary
Currently if source maps are enabled
style-loader
uses blob URLs instead of<style>
tags with inline CSS. This makes the CSS loading asynchronous and causes subsequent JavaScript to often see the state from before applying the CSS, breaking apps (see #121). Another issue is breaking relative URLs (see #93).Blobs were previously used to make source maps work but recent versions of major browsers have no problems with source maps working for inline
<style>
tags if a proper source map comment is appended.Does this PR introduce a breaking change?
Yes. The
convertToAbsoluteUrls
option is removed as it's no longer needed.Other information
I can add some tests to verify the source map comment is appended and that it has correct mapping. Is anything else needed to land it?