Use lazyFinalizer function when calling addJavaScript in BabelCompiler.

This commit is contained in:
Ben Newman
2018-06-09 16:08:22 -04:00
parent c28065aedc
commit a5751003a7

View File

@@ -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