Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

Commit 92093ce

Browse files
committed
implement locking
1 parent 149dbf1 commit 92093ce

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

lib/loader.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,13 +687,18 @@ function logloads(loads) {
687687
// NB This should be an Object.defineProperty, but that is very slow.
688688
// By disaling this module write-protection we gain performance.
689689
// It could be useful to allow an option to enable or disable this.
690+
module.locked = true;
690691
moduleObj[name] = value;
691692

692693
for (var i = 0, l = module.importers.length; i < l; i++) {
693694
var importerModule = module.importers[i];
694-
var importerIndex = importerModule.dependencies.indexOf(module);
695-
importerModule.setters[importerIndex](moduleObj);
695+
if (!importerModule.locked) {
696+
var importerIndex = importerModule.dependencies.indexOf(module);
697+
importerModule.setters[importerIndex](moduleObj);
698+
}
696699
}
700+
701+
module.locked = false;
697702
return value;
698703
});
699704

test/syntax/circular1.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import {fn2, variable2} from './circular2';
22

33
export var variable1 = 'test circular 1';
44

5+
export { output as output2 } from './circular2';
6+
57
fn2();
68

79
export var output;

test/test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ function runTests() {
212212
assert(
213213
[m2.output, 'test circular 1'],
214214
[m1.output, 'test circular 2'],
215-
[m2.output1, 'test circular 2']
215+
[m2.output1, 'test circular 2'],
216+
[m1.output2, 'test circular 1']
216217
);
217218
}, err);
218219
}, err);

0 commit comments

Comments
 (0)