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

Track whether transpiler has ran with a flag on the Loader #348

Merged
merged 1 commit into from
Apr 4, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/transpiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
function getTranspilerModule(loader, globalName) {
return loader.newModule({ 'default': g[globalName], __useDefault: true });
}
// NB this does not support sub-classing well
var firstRun = true;

// use Traceur by default
Loader.prototype.transpiler = 'traceur';
Expand All @@ -17,12 +15,12 @@
var self = this;

// pick up Transpiler modules from existing globals on first run if set
if (firstRun) {
if (!self.transpilerHasRun) {
if (g.traceur && !self.has('traceur'))
self.set('traceur', getTranspilerModule(self, 'traceur'));
if (g.babel && !self.has('babel'))
self.set('babel', getTranspilerModule(self, 'babel'));
firstRun = false;
self.transpilerHasRun = true;
}

return self['import'](self.transpiler).then(function(transpiler) {
Expand Down Expand Up @@ -101,4 +99,4 @@
}


})(__global.LoaderPolyfill);
})(__global.LoaderPolyfill);