From 3dbc4fd7151b37cc78f0b988c99560316f6f3128 Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Thu, 19 Apr 2018 12:01:10 +0800 Subject: [PATCH 1/2] fix missing config in babel 7 --- packages/metro/src/transformer.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/metro/src/transformer.js b/packages/metro/src/transformer.js index c542a56544..4fbcdd0596 100644 --- a/packages/metro/src/transformer.js +++ b/packages/metro/src/transformer.js @@ -111,6 +111,10 @@ function buildBabelConfig(filename, options, plugins?: BabelPlugins = []) { config = Object.assign({}, config, hmrConfig); } + if (process.env.BABEL_VERSION === '7') { + config = Object.assign({}, config, {ast: true}); + } + return Object.assign({}, babelRC, config); } From 72a31cabdffb42bfc279a1d8045596eeebc3dabe Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Thu, 19 Apr 2018 17:31:07 +0800 Subject: [PATCH 2/2] add sourceType for babel 7 --- packages/metro/src/transformer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/metro/src/transformer.js b/packages/metro/src/transformer.js index 4fbcdd0596..0ceed324a3 100644 --- a/packages/metro/src/transformer.js +++ b/packages/metro/src/transformer.js @@ -112,7 +112,7 @@ function buildBabelConfig(filename, options, plugins?: BabelPlugins = []) { } if (process.env.BABEL_VERSION === '7') { - config = Object.assign({}, config, {ast: true}); + config = Object.assign({}, config, {ast: true, sourceType: 'unambiguous'}); } return Object.assign({}, babelRC, config);