From 54d09aa9519b231be3b0334e8502ba7611da1752 Mon Sep 17 00:00:00 2001 From: John Knox Date: Thu, 29 Nov 2018 08:48:33 -0800 Subject: [PATCH] Fix open source yarn start Summary: The fb-stubs transform is getting applied when it shouldn't. Fix it by only applying it if src/fb exists. Reviewed By: danielbuechele Differential Revision: D13236217 fbshipit-source-id: 940def377839d16f34c49504948cb062916a3d6a --- static/transforms/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/static/transforms/index.js b/static/transforms/index.js index be2d0f04a..3737f812a 100644 --- a/static/transforms/index.js +++ b/static/transforms/index.js @@ -8,6 +8,8 @@ const generate = require('@babel/generator').default; const babylon = require('@babel/parser'); const babel = require('@babel/core'); +const fs = require('fs'); +const path = require('path'); function transform({filename, options, src}) { const presets = [require('../node_modules/@babel/preset-react')]; @@ -33,10 +35,17 @@ function transform({filename, options, src}) { require('../node_modules/@babel/plugin-proposal-class-properties'), require('../node_modules/@babel/plugin-transform-flow-strip-types'), require('../node_modules/@babel/plugin-proposal-optional-chaining'), - require('./fb-stubs.js'), require('./dynamic-requires.js'), ]; + if ( + fs.existsSync( + path.resolve(path.dirname(path.dirname(__dirname)), 'src', 'fb'), + ) + ) { + plugins.push(require('./fb-stubs.js')); + } + if (options.isTestRunner) { if (process.env.USE_ELECTRON_STUBS) { plugins.push(require('./electron-stubs.js'));