Replace module.importSync with module.import in older Meteor versions.

Also bumping the ecmascript version because it registers a compiler plugin
that uses babel-compiler.

Fixes #8572, albeit somewhat hackily.
This commit is contained in:
Ben Newman
2017-04-07 11:51:37 -04:00
parent 948ec2b05f
commit ac5131d1d7
3 changed files with 21 additions and 2 deletions

View File

@@ -1,3 +1,5 @@
var semver = Npm.require("semver");
/**
* A compiler that can be instantiated with features and used inside
* Plugin.registerCompiler
@@ -13,6 +15,10 @@ var BCp = BabelCompiler.prototype;
var excludedFileExtensionPattern = /\.(es5|min)\.js$/i;
var hasOwn = Object.prototype.hasOwnProperty;
// There's no way to tell the current Meteor version, but we can infer
// whether it's Meteor 1.4.4 or earlier by checking the Node version.
var isMeteorPre144 = semver.lt(process.version, "4.8.1");
BCp.processFilesForTarget = function (inputFiles) {
// Reset this cache for each batch processed.
this._babelrcCache = null;
@@ -103,6 +109,19 @@ BCp.processOneFileForTarget = function (inputFile, source) {
throw e;
}
if (isMeteorPre144) {
// Versions of meteor-tool earlier than 1.4.4 do not understand that
// module.importSync is synonymous with the deprecated module.import
// and thus fail to register dependencies for importSync calls.
// This string replacement may seem a bit hacky, but it will tide us
// over until everyone has updated to Meteor 1.4.4.
// https://github.com/meteor/meteor/issues/8572
result.code = result.code.replace(
/\bmodule\.importSync\b/g,
"module.import"
);
}
toBeAdded.data = result.code;
toBeAdded.hash = result.hash;
toBeAdded.sourceMap = result.map;

View File

@@ -6,7 +6,7 @@ Package.describe({
// isn't possible because you can't publish a non-recommended
// release with package versions that don't have a pre-release
// identifier at the end (eg, -dev)
version: '6.18.0'
version: '6.18.1'
});
Npm.depends({

View File

@@ -1,6 +1,6 @@
Package.describe({
name: 'ecmascript',
version: '0.7.1',
version: '0.7.2',
summary: 'Compiler plugin that supports ES2015+ in all .js files',
documentation: 'README.md'
});