webark / ember-component-css

An Ember CLI addon which allows you to specify styles for individual components
MIT License
540 stars 115 forks source link

Allow to opt out of classic component patching #376

Closed SergeAstapov closed 2 years ago

SergeAstapov commented 2 years ago

opt-in to address #365 until ember-cli-styles has stable release.

This would allow you to specify in config/environment.js:

'ember-component-css': {
  patchClassicComponent: false
}

Avoid the deprecation Reopening the Ember.Component super class itself is deprecated if you do not use classic components (or the bindings on classic components, at least).

Similar to https://github.com/salsify/ember-css-modules/pull/251 and https://github.com/simplabs/ember-test-selectors/pull/721.

webark commented 2 years ago

@SergeAstapov I can merge this. Just curious as to what your usage is without the initializer.

SergeAstapov commented 2 years ago

@webark we've migrated almost all components to Glimmer and use helper similar to https://github.com/webark/ember-cli-styles/blob/main/packages/namespace/addon/helpers/style-namespace.js but much simpler:

import { helper } from '@ember/component/helper';
import podNames from 'ember-component-css/pod-names';

export default helper(function styleNamespace ([componentName]) {
    return podNames[componentName];
});

which was inspired by this comment https://github.com/ebryn/ember-component-css/issues/342#issuecomment-570722703 (or maybe another one but with the same idea behind)

SergeAstapov commented 2 years ago

@webark moving forward we'll definitely migrate to ember-cli-styles or ember-css-modules but having such fix proposed here allows to decouple that effort from Ember v4 upgrade.

webark commented 2 years ago

ahh. Ok cool. Yea, ember-cli-styles uses the same kind of helper, just adds the namespace during build through an ast rather than needing to look it up through a dynamically generated file.

webark commented 2 years ago

I'll get a release out in the next couple of days

SergeAstapov commented 2 years ago

Thank you @webark! I'll submit PR adding this option info to the readme

webark commented 2 years ago

thanks