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

Commit 680e90a

Browse files
committed
Track whether transpiler has ran with a flag on the Loader
This fixes a bug where setting Traceur and/or Babel wasn't happening in multiple-loader scenarios. Instead of using a closure variable set one on the loader itself. Picked a long name to avoid collision. Fixes #347
1 parent 924c0fd commit 680e90a

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/transpiler.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
function getTranspilerModule(loader, globalName) {
88
return loader.newModule({ 'default': g[globalName], __useDefault: true });
99
}
10-
// NB this does not support sub-classing well
11-
var firstRun = true;
1210

1311
// use Traceur by default
1412
Loader.prototype.transpiler = 'traceur';
@@ -17,12 +15,12 @@
1715
var self = this;
1816

1917
// pick up Transpiler modules from existing globals on first run if set
20-
if (firstRun) {
18+
if (!self.transpilerHasRun) {
2119
if (g.traceur && !self.has('traceur'))
2220
self.set('traceur', getTranspilerModule(self, 'traceur'));
2321
if (g.babel && !self.has('babel'))
2422
self.set('babel', getTranspilerModule(self, 'babel'));
25-
firstRun = false;
23+
self.transpilerHasRun = true;
2624
}
2725

2826
return self['import'](self.transpiler).then(function(transpiler) {
@@ -101,4 +99,4 @@
10199
}
102100

103101

104-
})(__global.LoaderPolyfill);
102+
})(__global.LoaderPolyfill);

0 commit comments

Comments
 (0)