-
Notifications
You must be signed in to change notification settings - Fork 115
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
Updated to maintain roughly the same api, but remove monkeypatches #123
Conversation
but with minimum useage of private apis. Also enables source mapping and hot realoding, and sets us up for supporting in addon usage. * Need to add back in the accptance test after removed it due to such severe ember upgrade differences. * Need to add support for plain css useage * Need to better differentiate between pod-styles.scss, and pod-styles.sass, rather then just not accepting sass files and just scss styles instead. * Need better testing around empty states and precompilers other then sass
And since I know that you have been concerned with the performance with this addon @stefanpenner, I would appreciate any feedback or suggestions that you have as well. |
}); | ||
|
||
Component.reopen({ | ||
addPodStyleName: Ember.on('init', function() { |
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.
use init
+ super instead, better performance.
This looks very good! To support plain css and fix #107 you could use the removed postcss-selector-namespace plugin together with postcss-scss and postcss-less. Although I only tested postcss-scss yet. |
@topaxi totally! I was wanting to avoid having to add in that overhead, and with plain CSS, you couldn't do the standard import to include it in the app CSS either. so would have to either tack it only to the app CSS or the vendor CSS manually, or include in a third CSS file with utilizing the headerFor hook. which might not be a bad idea, and could potentially be a better solution for engines long term. Would want others who weigh in who are more familiar and see if it would actually have an impact. Plain CSS is something that should be addressed either before this PR would get merged, or very soon after. |
actually, scratch that. I don't think that it would have any impact on an engine, you'd want to have a single file. And for preprocessed styles, the file needs to be able to be imported into an existing app stylesheet to be processed so that you can utilize variables, methods, and the likes. So, we should just tac the plain css onto the end of the app css. |
@topaxi on further thought, to try to do plain css without a preprocessor, and just doing that ourselves, would be too hacky and would not want to maintain. We will however be basically giving them a preprocessor, which feels weird, but necessary. What do you feel about using cssnext rather then sass or less..? |
…eloads for better preformance per @stefanpenner suggestion
Yes, there's definitely need for a compiler, I'd use postcss (cssnext is only a postcss plugin collection) with as few plugins as possible, and let the addon consumer opt-in for more plugins like cssnext. As I already mentioned, the postcss-selector-namespace plugin I wrote could prefix plain css with the component class, though I'm not sure if we can reuse this 100%. We'd probably also need postcss-import-url to handle the |
@topaxi Why do you want to run it for every case? |
…d could potentialy be a computed property per per @stefanpenner suggestion
@webark If we run postcss in every case, we can support every precompiler for css there is, so we can transform the output of all the precompilers instead of the original files, where we'd need to support less, sass, scss, stylus, etc. But as I said, I'm not sure if we can actually do this (my broccoli/ember-cli knowledge is a bit limited here). |
So every preprocsors that uses a unique extension that is not .css, supports nesting with the & selector and uses curly brackets should be supported. This leaves us at the .css files not being supported cause they do not support nesting with the & selector. I had previously assumed this would be only plain CSS files, but that's wrong cause these could be cssnext files also as they use the .css extention, but run a preprocessor on them. We still want the file to be prepped but not processed until after its imported, cause that way you can utilize global variables and helper methods and the likes that are defined in the styles directory in your component CSS files. I think using that plugin for postcss you wrote to process the .css file would work well here for plain CSS files, and should be lighter weight then brining in sass or something like that. But as long as we keep the same API of the & selector and not let the user customize what that is, I dont see a need to use it for other files. But I totally admit that I could just be missing the point of what your after!! |
I see your point with I think the best way forward and being compatible is only using postcss for plain css for now :) If you're sure that just wrapping with |
On another note, it seems your changes don't support sass and stylus indentation style, or am I missing something? You'd probably have to do something along the lines like here: lib/broc-component-css-preprocessor.js#L37 |
I removed sass as an option cause it's kind of deprecated, it would have to use a different output cause it doesn't support curly brackets, and then when importing to the scss file I had, I would have had to import pod-styles.scss rather then just pod-styles, which was annoying. |
And I thought stylus supported curly brackets... grr.. |
Stylus supports curly brackets, though I'm not sure if mixing the two styles work. |
I'll have to look more into it. I didn't do any testing other then scss files. |
You could add a couple of new filters that handle the individual other file extensions. If a type used the same extension but different syntax that would be annoying. |
@topaxi what do you feel about allowing the defining of what the self selector is..? I kind of liked your approach of using :--component rather then the & |
Stylus definitely supports this: body
background: red;
.someClass {
background: blue;
} Wrapping in curlies doesn't seem to work though: body {
background: red;
// Does not work
.someClass
background: blue;
} I'd definitely prefer |
I think I'm starting to see more of what you are talking about. And now's a good time to do a breaking change if need be. So your saying, that we would open up every file, and then loop over each rule definition and either prepend a ".CLASS " or replace :--component with ".CLASS" and that way we don't need to worry about each preprocessors own idiosyncrasies.. |
Id say the main downside for me is the extra more intensive processing step that requires. But the simplicity and uniform approach to all preprocessors is nice. |
if you did a rule that was just an & though, if you pretended that with a ".CLASS " it would still work. Right? |
And we couldn't prepend any rules that where nested. Does that plugin you wrote account for that @topaxi? |
_concatenatedPodStyles(wrappedStyles) { | ||
var concatenatedStyles = []; | ||
|
||
for (var i = 0; i < this.allowedStyleExtentions.length; i++) { |
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.
how many extensions are typical?
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.
three are about 5 css preprocessing extensions? .scss, .sass, .less, . styl, and maybe one more?
@stefanpenner thanks for reviewing this! I'll start working on those changes tomorrow while I'm filling out some tests. Thanks again! |
…they will get included iwth the package
…rsistentOutput per @stefanpenner suggestion
@stefanpenner I moved the generating of the pod-names.js file that gets imported into the initializer to use persistentOutput and fs-tree-diff. Let me know if that's what you where thinking for that one. And I'll either find a better solution for the removing of the files empty files with the other one, or switch it to use the same methodology. |
|
||
ComponentLookup.reopen({ | ||
componentFor(name, owner) { | ||
if (podNames[name] && !owner.application.hasRegistration('component:' + name)) { |
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.
On Ember 2.3 and higher, owner.application should not be used. You should use owner.hasRegistration and owner.register. To enable usage of the same API across older Ember versions you can use the ember-getowner-polyfill.
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.
Also, wouldn't it be easier to call super and check if the return value is undefined instead of manually checking registration like this? Something like:
let FoundComponent = this._super(...arguments);
If (podNames[name] && !FoundComponent) {
FoundComponent = Component;
owner.register('component:' + name, FoundComponent);
}
return FoundComponent;
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.
I had tried this it wasn't working for me. I think cause _lookupFactory does more then just return the constructor. I would have to call super again at the end, which calling it twice felt weird.
This is looking great! I'd love to see this land on master and released (with a major version bump) as a prerelease so folks can start test/using it (and we can track issues/PR's independently). |
…ethod so that they will be done before application instatiation rather then after and only ran once for all tests per @rwjblue suggestion
… though the application, and using the polyfill for older versions per @rwjblue suggestion
…ps due to the final preprocessing step, and the annoyance of having to create a file even if none existed, I moved to using a persistant output plugin specifically for this purpose. *Note* Would like to move to using a manifest file that is a collection of imports rather then a file that gets concatinated due to better source map support. If there is another way to handle that. Let me know
…ons of node per @stefanpenner and @rwjblue suggestions
@rwjblue and @stefanpenner all of you suggestions have been addressed I believe. @ebryn or @topaxi what do you feel about the suggestion to prerelease this with a major version bump? I think it's read for that. I'm going to be replacing the tests over the next couple of days, and an architecture decision needs to be made about how to support plain css files (if at all) when no preprocessor is included. But it would be nice to get this into master sooner rather then later. |
I've created a |
We've got a beta release for this work as well... |
and with minimum useage of private apis.
Also enables source mapping and hot realoding,
and sets us up for supporting in addon usage.
it due to such severe ember upgrade differences.
rather then just not accepting sass files and just scss styles instead.