-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix memory leak (adapted from @arthirm’s ember-cli/ember-cli-htmlbars…
- Loading branch information
1 parent
28d825f
commit fcf265a
Showing
6 changed files
with
108 additions
and
9 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 |
---|---|---|
|
@@ -15,6 +15,7 @@ bower.json | |
ember-cli-build.js | ||
testem.js | ||
yarn.lock | ||
node-tests | ||
|
||
# ember-try | ||
.node_modules.ember-try/ | ||
|
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,5 @@ | ||
'use strict'; | ||
|
||
module.exports = function() { | ||
return 'I AM MODULE OF COMPILER'; | ||
}; |
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,38 @@ | ||
'use strict'; | ||
|
||
const purgeModule = require('../ember-addon-main').purgeModule; | ||
const expect = require('chai').expect; | ||
|
||
describe('purgeModule', function() { | ||
const FIXTURE_COMPILER_PATH = require.resolve('./fixtures/compiler'); | ||
|
||
it('it works correctly', function() { | ||
expect(purgeModule('asdfasdfasdfaf-unknown-file')).to.eql(undefined); | ||
|
||
expect(require.cache[FIXTURE_COMPILER_PATH]).to.eql(undefined); | ||
|
||
require(FIXTURE_COMPILER_PATH); | ||
|
||
const mod = require.cache[FIXTURE_COMPILER_PATH]; | ||
|
||
expect(mod.parent).to.eql(module); | ||
expect(mod.parent.children).to.include(mod); | ||
|
||
purgeModule(FIXTURE_COMPILER_PATH); | ||
|
||
expect(require.cache[FIXTURE_COMPILER_PATH]).to.eql(undefined); | ||
expect(mod.parent.children).to.not.include(mod); | ||
|
||
require(FIXTURE_COMPILER_PATH); | ||
|
||
const freshModule = require.cache[FIXTURE_COMPILER_PATH]; | ||
|
||
expect(freshModule.parent).to.eql(module); | ||
expect(freshModule.parent.children).to.include(freshModule); | ||
|
||
purgeModule(FIXTURE_COMPILER_PATH); | ||
|
||
expect(require.cache[FIXTURE_COMPILER_PATH]).to.eql(undefined); | ||
expect(freshModule.parent.children).to.not.include(mod); | ||
}); | ||
}); |
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