Skip to content

Commit

Permalink
Use lazyFinalizer function when calling addJavaScript in BabelCompiler.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Newman committed Jun 11, 2018
1 parent c28065a commit a575100
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions packages/babel-compiler/babel-compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,29 @@ var hasOwn = Object.prototype.hasOwnProperty;
var isMeteorPre144 = semver.lt(process.version, "4.8.1");

BCp.processFilesForTarget = function (inputFiles) {
var compiler = this;

// Reset this cache for each batch processed.
this._babelrcCache = null;

inputFiles.forEach(function (inputFile) {
var toBeAdded = this.processOneFileForTarget(inputFile);
if (toBeAdded) {
inputFile.addJavaScript(toBeAdded);
var fileOptions = inputFile.getFileOptions();

if (inputFile.supportsLazyCompilation) {
inputFile.addJavaScript({
path: inputFile.getPathInPackage(),
hash: inputFile.getSourceHash(),
bare: !! fileOptions.bare
}, function () {
return compiler.processOneFileForTarget(inputFile);
});
} else {
var toBeAdded = compiler.processOneFileForTarget(inputFile);
if (toBeAdded) {
inputFile.addJavaScript(toBeAdded);
}
}
}, this);
});
};

// Returns an object suitable for passing to inputFile.addJavaScript, or
Expand Down

0 comments on commit a575100

Please sign in to comment.