-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from NullVoxPopuli/make-inert-after-4.4
feat: make inert when ember-source supports default helper manager Closes: #121
- Loading branch information
Showing
6 changed files
with
1,639 additions
and
3,151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,50 @@ | ||
'use strict'; | ||
|
||
const VersionChecker = require('ember-cli-version-checker'); | ||
|
||
const MINIMUM_VERSION = '4.5.0-alpha.3' | ||
|
||
module.exports = { | ||
name: require('./package').name, | ||
|
||
_usePolyfill: flag(process.env.USE_DEFAULT_HELPER_MANAGER_POLYFILL), | ||
|
||
options: { | ||
'ember-cli-babel': { | ||
enableTypeScriptTransform: true, | ||
}, | ||
}, | ||
|
||
usePolyfill() { | ||
if (this._usePolyfill === undefined) { | ||
let version = new VersionChecker(this.project).for(`ember-source`); | ||
this._usePolyfill = version.lt(MINIMUM_VERSION); | ||
} | ||
|
||
return this._usePolyfill; | ||
}, | ||
|
||
treeForAddon() { | ||
if (this.usePolyfill()) { | ||
return this._super.treeForAddon.apply(this, arguments); | ||
} | ||
}, | ||
|
||
treeForApp() { | ||
if (this.usePolyfill()) { | ||
return this._super.treeForApp.apply(this, arguments); | ||
} | ||
}, | ||
}; | ||
|
||
const FALSE = ['false', 'disable', 'no', 'off', '0']; | ||
|
||
function flag(flag) { | ||
if (flag === undefined) { | ||
return undefined; | ||
} else if (FALSE.includes(flag.toLowerCase())) { | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
|
||
import { macroCondition, dependencySatisfies } from '@embroider/macros'; | ||
|
||
module('Unit | inert', function (hooks) { | ||
setupTest(hooks); | ||
|
||
function hasPolyfill() { | ||
let initializers = ['install-function-helper-manager', 'usable-function-manager']; | ||
|
||
return Object.keys(window.requirejs.entries).some(e => initializers.some(name => e.includes(name))) | ||
} | ||
|
||
if (macroCondition(dependencySatisfies('ember-source', '^4.5.0-alpha.3 || ^4.5.0'))) { | ||
|
||
test('polyfill is inert', function(assert) { | ||
assert.strictEqual(hasPolyfill(), false, 'no polyfill'); | ||
}); | ||
|
||
} else { | ||
|
||
test('polyfill is present', function(assert) { | ||
assert.strictEqual(hasPolyfill(), true, 'has polyfill'); | ||
}); | ||
|
||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.