Files
meteor/packages/babel-runtime/babel-runtime.js
Ben Newman a69ba4904d Move meteorBabelHelpers to modules package, and restrict to legacy bundle. (#10596)
Should fix #10595.

Code from the application `node_modules` directory becomes part of the
`modules` package, so that it can be imported by any other package that
uses the module system, regardless of package load order.

Now that we compile code from `node_modules` using `babel-compiler` and
`meteor-babel` (#10585), `node_modules` code requires the same runtime
environment as any other Meteor JS code. For the most part, this need is
satisfied by the `@babel/runtime/helpers/...` modules, which are also
defined in the `modules` package because they come from `node_modules`.
However, in the legacy bundle, `meteorBabelHelpers.sanitizeForInObject` is
used to fix buggy for-in iteration in older Internet Explorers.

Thankfully, this extra helper code does not need to be included in the
modern or server bundles, but only in legacy code.
2019-06-25 13:08:38 -04:00

27 lines
838 B
JavaScript

try {
var babelRuntimeVersion = require("@babel/runtime/package.json").version;
} catch (e) {
throw new Error([
"",
"The @babel/runtime npm package could not be found in your node_modules ",
"directory. Please run the following command to install it:",
"",
" meteor npm install --save @babel/runtime",
""
].join("\n"));
}
if (parseInt(babelRuntimeVersion, 10) < 7 ||
(babelRuntimeVersion.indexOf("7.0.0-beta.") === 0 &&
parseInt(babelRuntimeVersion.split(".").pop(), 10) < 56)) {
console.error([
"The version of @babel/runtime installed in your node_modules directory ",
"(" + babelRuntimeVersion + ") is out of date. Please upgrade it by running ",
"",
" meteor npm install --save @babel/runtime@latest",
"",
"in your application directory.",
""
].join("\n"));
}