diff --git a/packages/ember-css-modules/app/initializers/ensure-local-class-included.js b/packages/ember-css-modules/app/initializers/ensure-local-class-included.js deleted file mode 100644 index 50ee24e..0000000 --- a/packages/ember-css-modules/app/initializers/ensure-local-class-included.js +++ /dev/null @@ -1,12 +0,0 @@ -import 'ember-css-modules/templates/static-helpers-hack'; - -export default { - initialize() { - // This file exists to support Embroider's `staticHelpers` option. - // ECM relies on the existence of a `local-class` helper, but that - // helper may never be statically referenced in an application template. - // Instead, we reference it in our own template, and then import that - // template from a file (an initializer) that we know must always - // be loaded in order to boot the app and/or run tests. - }, -}; diff --git a/packages/ember-css-modules/index.js b/packages/ember-css-modules/index.js index 43010fd..f4ea78e 100644 --- a/packages/ember-css-modules/index.js +++ b/packages/ember-css-modules/index.js @@ -164,6 +164,10 @@ module.exports = { return this.cssModulesOptions.postcssOptions; }, + getScopeBehaviour() { + return this.cssModulesOptions.scopeBehaviour; + }, + getParentAddonTree() { return path.join(this.parentAddon.root, this.parentAddon.treePaths.addon); }, diff --git a/packages/ember-css-modules/lib/modules-preprocessor.js b/packages/ember-css-modules/lib/modules-preprocessor.js index ce1013c..43592d8 100644 --- a/packages/ember-css-modules/lib/modules-preprocessor.js +++ b/packages/ember-css-modules/lib/modules-preprocessor.js @@ -71,6 +71,7 @@ module.exports = class ModulesPreprocessor { enableSourceMaps: this.owner.enableSourceMaps(), sourceMapBaseDir: '', postcssOptions: this.owner.getPostcssOptions(), + scopeBehaviour: this.owner.getScopeBehaviour(), virtualModules: this.owner.getVirtualModules(), generateScopedName: this.scopedNameGenerator(), resolvePath: this.resolveAndRecordPath.bind(this), diff --git a/packages/ember-css-modules/lib/output-styles-preprocessor.js b/packages/ember-css-modules/lib/output-styles-preprocessor.js index 77785d9..60652fb 100644 --- a/packages/ember-css-modules/lib/output-styles-preprocessor.js +++ b/packages/ember-css-modules/lib/output-styles-preprocessor.js @@ -1,5 +1,6 @@ 'use strict'; +const path = require('path'); const debug = require('debug')('ember-css-modules:output-styles-preprocessor'); const Concat = require('broccoli-concat'); const MergeTrees = require('broccoli-merge-trees'); @@ -78,6 +79,15 @@ module.exports = class OutputStylesPreprocessor { return build.apply(this, arguments); }; + // NOTE: we sort file paths using our unique method and then add them to the header + // so they maintain order. If we don't broccoli-concat would reoder anyway + let calculatePatch = concat.calculatePatch; + concat.calculatePatch = function() { + let patch = calculatePatch.apply(this, arguments).sort(sortPatch); + this.headerFiles = this.headerFiles.concat(patch.map(entry => entry[1])); + return patch; + } + return concat; } @@ -156,3 +166,21 @@ function makeIndex(a, b) { return index; } + +function sortPatch(a, b) { + const sortNumber = 0; + const aLevels = path.normalize(a[1]).split(path.sep).length; + const bLevels = path.normalize(b[1]).split(path.sep).length; + + if (aLevels < bLevels) { + return -1; + } else if (aLevels > bLevels) { + return 1; + } else if (a < b) { + return -1; + } else if (a > b) { + return 1; + } else { + return 0; + } +} diff --git a/packages/ember-css-modules/package.json b/packages/ember-css-modules/package.json index 3486e16..f975865 100644 --- a/packages/ember-css-modules/package.json +++ b/packages/ember-css-modules/package.json @@ -1,6 +1,6 @@ { - "name": "ember-css-modules", - "version": "2.0.1", + "name": "@simplepractice/ember-css-modules", + "version": "2.1.0-beta.1", "description": "CSS Modules for ambitious applications", "scripts": { "build": "ember build --environment=production", @@ -74,7 +74,7 @@ "dependencies": { "broccoli-bridge": "^1.0.0", "broccoli-concat": "^4.2.5", - "broccoli-css-modules": "^0.8.0", + "broccoli-css-modules": "https://github.com/simplepractice/broccoli-css-modules.git#master", "broccoli-funnel": "^3.0.8", "broccoli-merge-trees": "^4.2.0", "broccoli-postcss": "^6.0.0",