ember-css-modules 2.1.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +311 -0
- package/addon/-runtime.js +1 -0
- package/docs/ORDERING.MD +51 -0
- package/docs/POSTCSS.md +89 -0
- package/docs/PREPROCESSORS.md +61 -0
- package/docs/TAILWINDCSS.md +77 -0
- package/docs/VIRTUAL_MODULES.md +41 -0
- package/index.js +19 -16
- package/lib/modules-preprocessor.js +5 -5
- package/package.json +19 -14
- package/addon/helpers/local-class.js +0 -34
- package/addon/index.js +0 -0
- package/addon/templates/static-helpers-hack.hbs +0 -1
- package/app/helpers/local-class.js +0 -1
- package/app/initializers/ensure-local-class-included.js +0 -12
- package/lib/htmlbars-plugin/index.js +0 -262
- package/lib/htmlbars-plugin/utils.js +0 -92
- package/lib/plugin/index.js +0 -29
- package/lib/plugin/registry.js +0 -100
package/lib/plugin/registry.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// eslint-disable-next-line node/no-unpublished-require
|
|
4
|
-
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
|
|
5
|
-
const Plugin = require('./index');
|
|
6
|
-
const merge = require('lodash.merge');
|
|
7
|
-
const debug = require('debug')('ember-css-modules:plugin-registry');
|
|
8
|
-
const normalizePostcssPlugins = require('../utils/normalize-postcss-plugins');
|
|
9
|
-
|
|
10
|
-
module.exports = class PluginRegistry {
|
|
11
|
-
constructor(parent) {
|
|
12
|
-
this.parent = parent;
|
|
13
|
-
this._plugins = null;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
computeOptions(includerOptions) {
|
|
17
|
-
let env = EmberApp.env();
|
|
18
|
-
let baseOptions = merge({}, includerOptions);
|
|
19
|
-
baseOptions.plugins = normalizePostcssPlugins(baseOptions.plugins);
|
|
20
|
-
|
|
21
|
-
let pluginOptions = this._computePluginOptions(env, baseOptions);
|
|
22
|
-
return merge(pluginOptions, baseOptions);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
notify(event) {
|
|
26
|
-
for (let plugin of this.getPlugins()) {
|
|
27
|
-
if (typeof plugin[event] === 'function') {
|
|
28
|
-
plugin[event]();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
getPlugins() {
|
|
34
|
-
if (this._plugins === null) {
|
|
35
|
-
this._plugins = this._instantiatePlugins();
|
|
36
|
-
}
|
|
37
|
-
return this._plugins;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
_instantiatePlugins() {
|
|
41
|
-
let plugins = this._discoverPlugins(
|
|
42
|
-
this.parent.addons,
|
|
43
|
-
'ember-css-modules-plugin'
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
// For addons under development, crawl the host app's available plugins for linting tools so they can be devDependencies
|
|
47
|
-
if (
|
|
48
|
-
typeof this.parent.isDevelopingAddon === 'function' &&
|
|
49
|
-
this.parent.isDevelopingAddon()
|
|
50
|
-
) {
|
|
51
|
-
let parentAddonNames = new Set(
|
|
52
|
-
this.parent.addons.map((addon) => addon.name)
|
|
53
|
-
);
|
|
54
|
-
let hostAddons = this.parent.project.addons.filter(
|
|
55
|
-
(addon) => !parentAddonNames.has(addon.name)
|
|
56
|
-
);
|
|
57
|
-
plugins = plugins.concat(
|
|
58
|
-
this._discoverPlugins(hostAddons, 'ember-css-modules-lint-plugin')
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return plugins;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
_discoverPlugins(addons, keyword) {
|
|
66
|
-
return addons
|
|
67
|
-
.filter((addon) => this._isPlugin(addon, keyword))
|
|
68
|
-
.map((addon) => this._instantiatePluginFor(addon));
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
_isPlugin(addon, keyword) {
|
|
72
|
-
return (
|
|
73
|
-
addon.pkg &&
|
|
74
|
-
addon.pkg.keywords &&
|
|
75
|
-
addon.pkg.keywords.indexOf(keyword) >= 0
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
_instantiatePluginFor(addon) {
|
|
80
|
-
debug('instantiating plugin %s', addon.name);
|
|
81
|
-
|
|
82
|
-
const plugin = addon.createCssModulesPlugin(this.parent);
|
|
83
|
-
if (!(plugin instanceof Plugin)) {
|
|
84
|
-
this.parent.ui.writeWarnLine(
|
|
85
|
-
`Addon ${addon.name} did not return a Plugin instance from its createCssModulesPlugin hook`
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
return plugin;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
_computePluginOptions(env, baseOptions) {
|
|
92
|
-
let options = merge({}, baseOptions);
|
|
93
|
-
for (let plugin of this.getPlugins()) {
|
|
94
|
-
if (plugin.config) {
|
|
95
|
-
merge(options, plugin.config(env, baseOptions));
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return options;
|
|
99
|
-
}
|
|
100
|
-
};
|