From 886c9b986cc41a2200c9f01b16146dd887fa3eef Mon Sep 17 00:00:00 2001 From: Vladimir Timofeev Date: Sat, 24 Feb 2018 08:56:46 -0800 Subject: [PATCH] Fix npm deps Summary: **Summary** This should fix install of the metro with npm (issue #142). We can't have both babylon@6 and babylon@7 as deps for metro package, so as jeanlauliac suggested in https://github.com/facebook/metro/issues/142#issuecomment-368217279 lets create wrapper-package `metro-babylon7` and reexport babylon@7 from it. **Test plan** I do manually `yarn && yarn test` - all checks passed. Closes https://github.com/facebook/metro/pull/143 Differential Revision: D7079144 Pulled By: rafeca fbshipit-source-id: eeb4f6a01ad92d84dc14702dee07975e253bcf88 --- packages/metro-babylon7/package.json | 18 ++++++++++++++++++ packages/metro-babylon7/src/index.js | 12 ++++++++++++ packages/metro/package.json | 2 +- packages/metro/src/babel-bridge.js | 2 +- yarn.lock | 9 ++++----- 5 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 packages/metro-babylon7/package.json create mode 100644 packages/metro-babylon7/src/index.js diff --git a/packages/metro-babylon7/package.json b/packages/metro-babylon7/package.json new file mode 100644 index 00000000..6162cac5 --- /dev/null +++ b/packages/metro-babylon7/package.json @@ -0,0 +1,18 @@ +{ + "version": "0.27.0", + "name": "metro-babylon7", + "description": "🚇 Metro babylon v7 wrapper", + "main": "src/index.js", + "repository": { + "type": "git", + "url": "git@github.com:facebook/metro.git" + }, + "scripts": { + "prepare-release": "test -d build && rm -rf src.real && mv src src.real && mv build src", + "cleanup-release": "test ! -e build && mv src build && mv src.real src" + }, + "dependencies": { + "babylon": "^7.0.0-beta" + } +} + \ No newline at end of file diff --git a/packages/metro-babylon7/src/index.js b/packages/metro-babylon7/src/index.js new file mode 100644 index 00000000..2f8ed183 --- /dev/null +++ b/packages/metro-babylon7/src/index.js @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ +'use strict'; + +module.exports = require('babylon'); diff --git a/packages/metro/package.json b/packages/metro/package.json index a7813fb6..e0579060 100644 --- a/packages/metro/package.json +++ b/packages/metro/package.json @@ -53,7 +53,6 @@ "babel-preset-react-native": "^4.0.0", "babel-register": "^6.24.1", "babylon": "^6.18.0", - "babylon7": "npm:babylon@^7.0.0-beta", "chalk": "^1.1.1", "concat-stream": "^1.6.0", "connect": "^3.6.5", @@ -73,6 +72,7 @@ "left-pad": "^1.1.3", "lodash.throttle": "^4.1.1", "merge-stream": "^1.0.1", + "metro-babylon7": "0.27.0", "metro-cache": "0.27.0", "metro-core": "0.27.0", "metro-resolver": "0.27.0", diff --git a/packages/metro/src/babel-bridge.js b/packages/metro/src/babel-bridge.js index b391d2bd..86f50760 100644 --- a/packages/metro/src/babel-bridge.js +++ b/packages/metro/src/babel-bridge.js @@ -42,7 +42,7 @@ const babelGenerate7 = require('@babel/generator').default; const babelTemplate7 = require('@babel/template').default; const babelTraverse7 = require('@babel/traverse').default; const babelTypes7 = require('@babel/types'); -const babylon7 = require('babylon7'); +const babylon7 = require('metro-babylon7'); const externalHelpersPlugin7 = require('babel-plugin-external-helpers'); const inlineRequiresPlugin7 = require('babel-preset-fbjs/plugins/inline-requires'); diff --git a/yarn.lock b/yarn.lock index d9173dc3..42a4e367 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1432,15 +1432,14 @@ babel-types@^6.19.0, babel-types@^6.26.0: lodash "^4.17.4" to-fast-properties "^1.0.3" -"babylon7@npm:babylon@^7.0.0-beta", babylon@7.0.0-beta.38: - name babylon7 - version "7.0.0-beta.38" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.38.tgz#9b3a33e571a47464a2d20cb9dd5a570f00e3f996" - babylon@7.0.0-beta.36: version "7.0.0-beta.36" resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.36.tgz#3a3683ba6a9a1e02b0aa507c8e63435e39305b9e" +babylon@^7.0.0-beta, babylon@7.0.0-beta.38: + version "7.0.0-beta.38" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.38.tgz#9b3a33e571a47464a2d20cb9dd5a570f00e3f996" + babylon@^6.11.0, babylon@^6.13.0, babylon@^6.15.0, babylon@^6.18.0: version "6.18.0" resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3"