Skip to content
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

[bug] ensure that SassCompiler is not run on files that are not (.scss|.sass|.css) #215

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gabrielcsapo
Copy link
Contributor

@gabrielcsapo gabrielcsapo commented May 26, 2020

Motivation

#214 #178

The sass compiler has an unintended overhead when running in projects as it rebuilds when it is not necessary.

What happens after this change?

When changing a .scss file

Screen Shot 2020-05-25 at 7 07 14 PM

> When changing a non `.scss` file

Screen Shot 2020-05-25 at 7 07 17 PM

screenshot produced using broccoli-inspector

This results in a net savings for rebuilds of 50%!

Change itself

  • Why was broccoli-sass-source-maps copied into the project? I was hoping to have a discussion around this change before opening up two PRs. In the context of ember it might make sense to care about the buildStart time where as in the more generic broccoli-sass-source-maps it would be better to not have a filter between file changes. Sass is different thenjs and hbs where the build output is the result of running sass on the top level input file. hbs and js can be altered and combined at the end of the build.

@gabrielcsapo
Copy link
Contributor Author

@simonexmachina would you be able to review this?

Copy link
Member

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

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

Can you split this up a bit? Specifically, I'd like PRs for each of the following:

  • Drop Node < 10
  • Migrate to broccoli-persistent-filter

index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
@gabrielcsapo
Copy link
Contributor Author

@rwjblue updated based on your suggestions and also broke up the node upgrade as a separate PR. #216

@gabrielcsapo
Copy link
Contributor Author

@rwjblue this seems to be plaguing many others would you be able to see if we can merge this?

}

processString() {
if(this.inputTree._buildStart !== this.lastBuildStart) {
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 am not sure of any way to make sure the files related to a specific input tree don't build again. Can multiple input trees have the same _buildStart? Is there a way we can distinguish the identity?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stefanpenner would you know of a good way to distinguish the identity of the input tree to avoid building specific trees that have built before?

Copy link
Member

Choose a reason for hiding this comment

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

Why do we care? We should not be mucking with the passed in tree directly, only with this.inputPaths...

@robclancy
Copy link

This is just not cared about anymore? Is there a version I can revert to for this?

Comment on lines +6 to +7
- "10"
- "12"
Copy link
Member

Choose a reason for hiding this comment

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

This is odd, was this not handled by #216 ?

Comment on lines -26 to -28
- EMBER_TRY_SCENARIO=ember-lts-2.12
- EMBER_TRY_SCENARIO=ember-lts-2.16
- EMBER_TRY_SCENARIO=ember-lts-2.18
Copy link
Member

Choose a reason for hiding this comment

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

This seems unrelated to the goal of this PR

}

processString() {
if(this.inputTree._buildStart !== this.lastBuildStart) {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we care? We should not be mucking with the passed in tree directly, only with this.inputPaths...

sourceMapFile = destFile + '.map';
}

mkdirp.sync(path.dirname(destFile));
Copy link
Member

Choose a reason for hiding this comment

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

Speculative mkdirp.sync is somewhat expensive, oftentimes we can avoid it by using try/catch and handling ENOENT + retry..

var mergeTrees = require('broccoli-merge-trees');

const path = require('path');
const Filter = require('broccoli-persistent-filter');
Copy link
Member

Choose a reason for hiding this comment

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

The use of broccoli-persistent-filter here seems odd to me. As far as I can tell, this is not a 1:1 compiler (which is essentially what broccoli-persistent-filter expects to be working with).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what would be a good way to get this type of caching without broccoli-persistent-filter?

@vlascik
Copy link

vlascik commented Mar 2, 2021

Any chance this will get merged soon? This PR seems to have worked, SassCompiler is gone from e-cli rebuild slowest nodes list.

I'm still having a pretty slow entry for Concat: Vendor Styles/assets/vendor.css (1) | 838ms when rebuilding .js/.ts.

Is this also caused by this addon, or does it come from somewhere else?

@knownasilya
Copy link
Collaborator

Looks like there is still some feedback that needs to be addressed before this can be merged.

@arjun-freshworks
Copy link

My codebase is big and usually around 3 seconds for SassCompiler when there are no SCSS changes. After this change, SassCompiler takes around 150ms and overall build time improvement is about 16%. For a SCSS change, the improvement is around 40%. Can we merge this?

@knownasilya
Copy link
Collaborator

Willing to merge if feedback is addressed

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

Successfully merging this pull request may close these issues.

6 participants