-
Notifications
You must be signed in to change notification settings - Fork 50
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
[Experimental] Support template co-location and Embroider #153
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,13 +24,11 @@ module.exports = { | |
this.modulesPreprocessor = new ModulesPreprocessor({ owner: this }); | ||
this.outputStylesPreprocessor = new OutputStylesPreprocessor({ owner: this }); | ||
this.checker = new VersionChecker(this.project); | ||
this.plugins = new PluginRegistry(this.parent); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is potentially a breaking change. We have an addon like this: module.exports = {
name: require('./package').name,
createCssModulesPlugin(parent) {
return new BreakpointsPlugin(parent, {
breakpoints: this.breakpoints
});
},
included() {
this.breakpoints = require('./breakpoints.json');
}
} Prior to this change, For this simple case, the fix is easy: module.exports = {
name: require('./package').name,
createCssModulesPlugin(parent) {
return new BreakpointsPlugin(parent, {
breakpoints: this.breakpoints
});
},
init(...args) {
this._super(...args);
this.breakpoints = require('./breakpoints.json');
}
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the public registry, at least, I think you and I are the only two authors of packages with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally and speaking for @ClarkSource I'm totally fine with this change. None of my public plugins break, and of all private ones this was the only one. 🎉 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 Ok, we'll see if anyone else runs into this during the beta, and assuming they don't we'll plan to keep this in as a non-major change under the banner of "undefined behavior can't break" |
||
}, | ||
|
||
included(includer) { | ||
debug('included in %s', includer.name); | ||
this.ownerName = includer.name; | ||
this.plugins = new PluginRegistry(this.parent); | ||
this.cssModulesOptions = this.plugins.computeOptions(includer.options && includer.options.cssModules); | ||
|
||
if (this.belongsToAddon()) { | ||
this.verifyStylesDirectory(); | ||
|
@@ -58,15 +56,24 @@ module.exports = { | |
// Skip if we're setting up this addon's own registry | ||
if (type !== 'parent') { return; } | ||
|
||
let includerOptions = this.app ? this.app.options : this.parent.options; | ||
this.cssModulesOptions = this.plugins.computeOptions(includerOptions && includerOptions.cssModules); | ||
|
||
registry.add('js', this.modulesPreprocessor); | ||
registry.add('css', this.outputStylesPreprocessor); | ||
registry.add('htmlbars-ast-plugin', HtmlbarsPlugin.forEmberVersion(this.checker.forEmber().version)); | ||
registry.add('htmlbars-ast-plugin', HtmlbarsPlugin.instantiate({ | ||
emberVersion: this.checker.forEmber().version, | ||
options: { | ||
fileExtension: this.getFileExtension(), | ||
includeExtensionInModulePath: this.includeExtensionInModulePath(), | ||
}, | ||
})); | ||
}, | ||
|
||
verifyStylesDirectory() { | ||
if (!fs.existsSync(path.join(this.parent.root, this.parent.treePaths['addon-styles']))) { | ||
this.ui.writeWarnLine( | ||
'The addon ' + this.getOwnerName() + ' has ember-css-modules installed, but no addon styles directory. ' + | ||
'The addon ' + this.getParentName() + ' has ember-css-modules installed, but no addon styles directory. ' + | ||
'You must have at least a placeholder file in this directory (e.g. `addon/styles/.placeholder`) in ' + | ||
'the published addon in order for ember-cli to process its CSS modules.' | ||
); | ||
|
@@ -77,8 +84,8 @@ module.exports = { | |
this.plugins.notify(event); | ||
}, | ||
|
||
getOwnerName() { | ||
return this.ownerName; | ||
getParentName() { | ||
return this.app ? this.app.name : this.parent.name; | ||
}, | ||
|
||
getParent() { | ||
|
@@ -97,6 +104,10 @@ module.exports = { | |
return this.cssModulesOptions.generateScopedName || require('./lib/generate-scoped-name'); | ||
}, | ||
|
||
getModuleRelativePath(fullPath) { | ||
return this.modulesPreprocessor.getModuleRelativePath(fullPath); | ||
}, | ||
|
||
getModulesTree() { | ||
return this.modulesPreprocessor.getModulesTree(); | ||
}, | ||
|
@@ -121,6 +132,10 @@ module.exports = { | |
return this.cssModulesOptions && this.cssModulesOptions.extension || 'css'; | ||
}, | ||
|
||
includeExtensionInModulePath() { | ||
return !!this.cssModulesOptions.includeExtensionInModulePath; | ||
}, | ||
|
||
getPostcssOptions() { | ||
return this.cssModulesOptions.postcssOptions; | ||
}, | ||
|
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.
is app/components/my-component/index.css also supported?