From 7c3757418b49c496bda377e7819c71f652177b8c Mon Sep 17 00:00:00 2001 From: Stefan Penner Date: Wed, 7 Jun 2017 09:58:57 -0700 Subject: [PATCH] [BUGFIX] reified should not be explicitly retained --- lib/loader/loader.js | 1 + package.json | 1 + tests/all.js | 11 +++++++++++ 3 files changed, 13 insertions(+) diff --git a/lib/loader/loader.js b/lib/loader/loader.js index 7dc2420..a55526e 100644 --- a/lib/loader/loader.js +++ b/lib/loader/loader.js @@ -132,6 +132,7 @@ var loader, define, requireModule, require, requirejs; this.reify(); var result = this.callback.apply(this, this.reified); + this.reified.length = 0; this.state = 'finalized'; if (!(this.hasExportsAsDep && result === undefined)) { diff --git a/package.json b/package.json index 235664e..fb191ff 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "testem": "^1.0.0" }, "scripts": { + "build": "node build", "test": "testem ci && jshint lib tests && jscs lib tests", "test:dev": "testem", "prepublish": "./build.js" diff --git a/tests/all.js b/tests/all.js index b294847..c88c370 100644 --- a/tests/all.js +++ b/tests/all.js @@ -1580,6 +1580,17 @@ test('redefining a module when "pending" should no-op', function(assert) { assert.notOk(second, 'second module definition never used'); }); +test('reify should release', function(assert) { + define('foo', ['bar'], function() { }); + define('bar', ['bar'], function() { }); + + require('foo'); + require('bar'); + + assert.deepEqual(require.entries['foo'].reified, []); + assert.deepEqual(require.entries['bar'].reified, []); + +}); test('redefining a module when "reifying" should no-op', function(assert) { var first = false; var second = false;