@meteorjs/babel 7.18.0-beta.5 → 7.19.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/options.js CHANGED
@@ -35,6 +35,10 @@ function getReifyOptions(features) {
35
35
  // wrap it with a function to rename the `module` identifier.
36
36
  reifyOptions.moduleAlias = "module";
37
37
  }
38
+
39
+ if (features.topLevelAwait) {
40
+ reifyOptions.topLevelAwait = true;
41
+ }
38
42
  }
39
43
 
40
44
  return reifyOptions;
@@ -182,18 +186,20 @@ function getDefaultsForNode8(features) {
182
186
  require("@babel/plugin-syntax-object-rest-spread"),
183
187
  require("@babel/plugin-proposal-object-rest-spread")
184
188
  );
185
-
186
- // Ensure that async functions run in a Fiber, while also taking
187
- // full advantage of native async/await support in Node 8.
189
+ // TODO [fibers]: instead of removing the code below, consider this comment:
190
+ // https://github.com/meteor/meteor/pull/12471/files#r1089610144
188
191
  const isFiberDisabled = process.env.DISABLE_FIBERS === '1';
189
192
  const ignoreAsyncPlugin = process.env.IGNORE_ASYNC_PLUGIN === '1';
190
193
 
191
194
  if (!ignoreAsyncPlugin) {
192
- combined.plugins.push([require("./plugins/async-await.js"), {
193
- // Do not transform `await x` to `Promise.await(x)`, since Node
194
- // 8 has native support for await expressions.
195
- useNativeAsyncAwait: isFiberDisabled,
196
- }]);
195
+ combined.plugins.push([
196
+ require('./plugins/async-await.js'),
197
+ {
198
+ // Do not transform `await x` to `Promise.await(x)`, since Node
199
+ // 8 has native support for await expressions.
200
+ useNativeAsyncAwait: isFiberDisabled,
201
+ },
202
+ ]);
197
203
  }
198
204
  // Enable async generator functions proposal.
199
205
  combined.plugins.push(require("@babel/plugin-proposal-async-generator-functions"));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@meteorjs/babel",
3
3
  "author": "Meteor <dev@meteor.com>",
4
- "version": "7.18.0-beta.5",
4
+ "version": "7.19.0-beta.1",
5
5
  "license": "MIT",
6
6
  "description": "Babel wrapper package for use with Meteor",
7
7
  "keywords": [
@@ -41,7 +41,7 @@
41
41
  "@babel/template": "^7.16.7",
42
42
  "@babel/traverse": "^7.17.0",
43
43
  "@babel/types": "^7.17.0",
44
- "@meteorjs/reify": "0.23.0",
44
+ "@meteorjs/reify": "https://github.com/meteor/reify/tarball/5078da9d0827cc17741504762f3a7f71c3b01448",
45
45
  "babel-preset-meteor": "^7.10.0",
46
46
  "babel-preset-minify": "^0.5.1",
47
47
  "convert-source-map": "^1.6.0",
@@ -54,7 +54,6 @@
54
54
  "@babel/plugin-syntax-decorators": "7.14.5",
55
55
  "d3": "4.13.0",
56
56
  "fibers": "5.0.0",
57
- "meteor-promise": "0.9.0",
58
57
  "mocha": "6.2.3",
59
58
  "promise": "8.1.0",
60
59
  "source-map": "0.6.1"
package/runtime.js CHANGED
@@ -11,21 +11,3 @@ Module.prototype.resolve = function (id) {
11
11
 
12
12
  require("@meteorjs/reify/lib/runtime").enable(Module.prototype);
13
13
 
14
- if (!process.env.DISABLE_FIBERS) {
15
- require("meteor-promise").makeCompatible(
16
- global.Promise = global.Promise ||
17
- require("promise/lib/es6-extensions"),
18
- require("fibers")
19
- );
20
-
21
- // If Promise.asyncApply is defined, use it to wrap calls to
22
- // regeneratorRuntime.async so that the entire async function will run in
23
- // its own Fiber, not just the code that comes after the first await.
24
- if (typeof Promise.asyncApply === "function") {
25
- var regeneratorRuntime = require("@babel/runtime/regenerator");
26
- var realAsync = regeneratorRuntime.async;
27
- regeneratorRuntime.async = function (innerFn) {
28
- return Promise.asyncApply(realAsync, regeneratorRuntime, arguments);
29
- };
30
- }
31
- }
@@ -1,74 +0,0 @@
1
- "use strict";
2
-
3
- module.exports = function (babel) {
4
- const t = babel.types;
5
-
6
- return {
7
- name: "transform-meteor-async-await",
8
- visitor: {
9
- Function: {
10
- exit: function (path) {
11
- const node = path.node;
12
- if (!node.async) {
13
- return;
14
- }
15
-
16
- // The original function becomes a non-async function that
17
- // returns a Promise.
18
- node.async = false;
19
-
20
- // The inner function should inherit lexical environment items
21
- // like `this`, `super`, and `arguments` from the outer
22
- // function, and arrow functions provide exactly that behavior.
23
- const innerFn = t.arrowFunctionExpression(
24
- // The inner function has no parameters of its own, but can
25
- // refer to the outer parameters of the original function.
26
- [],
27
- node.body,
28
- // The inner function called by Promise.asyncApply should be
29
- // async if we have native async/await support.
30
- !! this.opts.useNativeAsyncAwait
31
- );
32
-
33
- const promiseResultExpression = t.callExpression(
34
- t.memberExpression(
35
- t.identifier("Promise"),
36
- t.identifier("asyncApply"),
37
- false
38
- ), [innerFn]
39
- );
40
-
41
- // Calling the async function with Promise.asyncApply is
42
- // important to ensure that the part before the first await
43
- // expression runs synchronously in its own Fiber, even when
44
- // there is native support for async/await.
45
- if (node.type === "ArrowFunctionExpression") {
46
- node.body = promiseResultExpression;
47
- } else {
48
- node.body = t.blockStatement([
49
- t.returnStatement(promiseResultExpression)
50
- ]);
51
- }
52
- }
53
- },
54
-
55
- AwaitExpression: function (path) {
56
- if (this.opts.useNativeAsyncAwait) {
57
- // No need to transform await expressions if we have native
58
- // support for them.
59
- return;
60
- }
61
-
62
- const node = path.node;
63
- path.replaceWith(t.callExpression(
64
- t.memberExpression(
65
- t.identifier("Promise"),
66
- t.identifier(node.all ? "awaitAll" : "await"),
67
- false
68
- ),
69
- [node.argument]
70
- ));
71
- }
72
- }
73
- };
74
- };