Skip to content

fix(@angular-devkit/build-angular): load component source maps inline… #11729

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

Merged
merged 1 commit into from
Aug 27, 2018

Conversation

ajspera
Copy link
Contributor

@ajspera ajspera commented Jul 31, 2018

… so they work

without this, the way styles are into the DOM breaks the default sourcemap option
postcss-loader option docs
https://github.com/postcss/postcss-loader#inline
fixes #9099

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@ajspera
Copy link
Contributor Author

ajspera commented Jul 31, 2018

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

@@ -267,7 +267,7 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
options: {
ident: buildOptions.extractCss ? 'extracted' : 'embedded',
plugins: postcssPluginCreator,
sourceMap: cssSourceMap
sourceMap: cssSourceMap ? 'inline' : false
Copy link
Member

Choose a reason for hiding this comment

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

I'm assuming based on the linked issue that you meant to change the source map configuration for component styles located here and not the global styles config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually both are affected by the problem, but I had missed that there were 2 instances of postcss-loader. With each using 'inline' instead of a boolean, both the global maps and component maps are now working. I updated the commit and the commit message to reflect that.

Copy link
Member

@clydin clydin Aug 1, 2018

Choose a reason for hiding this comment

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

If that is the case then the comment in this section is very relevant. style-loader 1.0 (unreleased) automatically handles the source maps in this regard. As a stopgap this appears to be an acceptable solution. However, if the global stylesheets are extracted, they should not contain inline source maps. The conditional in this case should set the value to true if source maps and extraction are enabled; inline if only source maps are enabled; and false otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had thought about that, but when I tried ng build --source-map --extract-css without the inline sourcemaps, they did not work. The chrome inspector just referenced the generated css files. Looking a bit further, it does generate a map file for the styles, but there are no mappings to the scss files in it.

dist/styles.css.map

{"version":3,"sources":[],"names":[],"mappings":"","file":"styles.css","sourceRoot":""}

There may be another bug happening on top of this, although the always inline will resolve it as is until it's found. I suppose that's up to you whether you want extracted sourcemaps broken until it's found or supplement it as is (always inline if true) until then.

Copy link
Member

Choose a reason for hiding this comment

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

Extracted stylesheets should have working source maps. If they are not working that would be a separate issue. Altering the behavior for extracted souremaps in this way would be require a major version bump as end users may not realize the source maps are embedded resulting in the source being pushed unknowingly in production builds.

Copy link
Contributor Author

@ajspera ajspera Aug 1, 2018

Choose a reason for hiding this comment

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

It will still only push source maps if --source-map is explicitly set, but I suppose your point may be relevant if people are building source maps and then manually pulling the map files from their build as part of a deployment process which I would consider unorthodox. I do agree that its a separate issue, but its also related to the referenced issue since it isn't completely resolved until the extracted scss source maps also work.

Copy link
Member

Choose a reason for hiding this comment

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

If you are willing to make the suggested change, we should be able to roll this into the next minor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, I should be able to get that in today. Just to confirm, the component styles are always injected inline via js even with extract-css, so the change just goes on the global styles, right?

Copy link
Member

Choose a reason for hiding this comment

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

yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The change is up.

@ajspera ajspera force-pushed the fix-component-style-sourcemaps branch from 4e569e5 to 7ab661c Compare August 1, 2018 01:45
@ajspera ajspera closed this Aug 14, 2018
@ajspera ajspera force-pushed the fix-component-style-sourcemaps branch from 7ab661c to 84ec302 Compare August 14, 2018 17:06
@ajspera ajspera reopened this Aug 14, 2018
@ajspera ajspera force-pushed the fix-component-style-sourcemaps branch from f130a0d to ba22a3b Compare August 14, 2018 18:15
@ajspera ajspera closed this Aug 14, 2018
@ajspera ajspera force-pushed the fix-component-style-sourcemaps branch from ba22a3b to f46869d Compare August 14, 2018 18:18
@ajspera ajspera reopened this Aug 14, 2018
@ajspera ajspera force-pushed the fix-component-style-sourcemaps branch from 3e8992b to 50eb452 Compare August 14, 2018 18:30
@ajspera
Copy link
Contributor Author

ajspera commented Aug 14, 2018

Sorry about the close and re-open. I had my gitlab account in my config when I rebased and reverting closed this. Everything should be good to go now, though, as long as the rebase fixed those failed tests.

…they work

without this, the way styles are into the DOM breaks the default sourcemap option
postcss-loader option docs
https://github.com/postcss/postcss-loader#inline
fixes angular#9099
@ajspera ajspera force-pushed the fix-component-style-sourcemaps branch from 50eb452 to 7a0165c Compare August 22, 2018 16:14
@ajspera
Copy link
Contributor Author

ajspera commented Aug 22, 2018

@clydin A couple of rebases later and the appveyor CI finally passed. All automated checks are good, just needing approval.

@clydin clydin added the target: major This PR is targeted for the next major release label Aug 22, 2018
@vikerman vikerman merged commit c66f831 into angular:master Aug 27, 2018
@zuzusik
Copy link

zuzusik commented Oct 26, 2018

is it possible to port this to version 6.x?

@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
target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Source map not working for SCSS files
5 participants