Skip to content

Commit b671586

Browse files
author
Andrew A Lee
authored
Fixes code included in production builds [#108] (#134)
1 parent eddb7cb commit b671586

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

addon/instance-initializers/axe-component.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function initialize(appInstance) {
4646

4747
const {
4848
turnAuditOff: configuredTurnAuditOff,
49-
excludeAxeCore,
49+
excludeAxeCore = false,
5050
axeOptions = {},
5151
axeCallback,
5252
visualNoiseLevel: configuredVisualNoiseLevel,
@@ -59,7 +59,10 @@ export function initialize(appInstance) {
5959

6060
// Avoid modifying the Component class if the visual audit feature is configured disabled
6161
// and axe-core is excluded from the dev build
62-
if (turnAuditOff && excludeAxeCore) { return; }
62+
if ((turnAuditOff && excludeAxeCore) || typeof axe === 'undefined') {
63+
hasRan = true;
64+
return;
65+
}
6366

6467
Component.reopen({
6568
/**

index.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,34 @@ module.exports = {
5959
treeForApp: function(tree) {
6060
var checker = new VersionChecker(this);
6161
var isProductionBuild = process.env.EMBER_ENV === 'production';
62-
var isOldEmber = checker.for('ember', 'bower').lt('1.13.0');
62+
var isOldEmber = checker.forEmber().lt('1.13.0');
6363

6464
if (isProductionBuild || isOldEmber) {
6565
tree = new Funnel(tree, {
66-
exclude: [/instance-initializers\/axe-component|violations-helper.js/]
66+
exclude: [/instance-initializers\/(axe-component|violations-helper)\.js/]
67+
});
68+
}
69+
70+
return tree;
71+
},
72+
73+
/**
74+
* Exclude all addon code during build if this is a
75+
* production build or if the version of Ember being used is less than 1.13.
76+
* @override
77+
*/
78+
treeForAddon: function() {
79+
var tree = this._super.treeForAddon.apply(this, arguments);
80+
var checker = new VersionChecker(this);
81+
var isProductionBuild = process.env.EMBER_ENV === 'production';
82+
var isOldEmber = checker.forEmber().lt('1.13.0');
83+
84+
if (isProductionBuild || isOldEmber) {
85+
tree = new Funnel(tree, {
86+
exclude: [
87+
/instance-initializers\/(axe-component|violations-helper)\.js/,
88+
/utils\/(concurrent-axe|format-violation|is-background-replaced-element|violations-helper)\.js/
89+
]
6790
});
6891
}
6992

0 commit comments

Comments
 (0)