From 302b9ec73fd05497d8402f45a9cc7f3b4ba84773 Mon Sep 17 00:00:00 2001
From: Ville Immonen <ville.immonen@iki.fi>
Date: Fri, 23 Sep 2016 00:29:52 +0300
Subject: [PATCH] Attempt to fix the e2e test (#704)

Only copy our own packages to bundledDependencies in the e2e test
---
 tasks/bundle-own-deps.js | 28 ++++++++++++++++++++++++++++
 tasks/e2e.sh             |  5 +++--
 2 files changed, 31 insertions(+), 2 deletions(-)
 create mode 100755 tasks/bundle-own-deps.js

diff --git a/tasks/bundle-own-deps.js b/tasks/bundle-own-deps.js
new file mode 100755
index 000000000..61408f1cc
--- /dev/null
+++ b/tasks/bundle-own-deps.js
@@ -0,0 +1,28 @@
+#!/usr/bin/env node
+/**
+ * Copyright (c) 2015-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+'use strict';
+
+// Like bundle-deps, this script modifies packages/react-scripts/package.json,
+// copying own dependencies (those in the `packages` dir) to bundledDependencies
+
+const fs = require('fs');
+const path = require('path');
+
+const packagesDir = path.join(__dirname, '../packages');
+const pkgFilename = path.join(packagesDir, 'react-scripts/package.json');
+const data = require(pkgFilename);
+
+data.bundledDependencies = fs.readdirSync(packagesDir)
+  .filter((name) => data.dependencies[name]);
+
+fs.writeFile(pkgFilename, JSON.stringify(data, null, 2), 'utf8', (err) => {
+  if (err) throw err;
+  console.log('bundled ' + data.bundledDependencies.length + ' dependencies.');
+});
diff --git a/tasks/e2e.sh b/tasks/e2e.sh
index f8f9120b2..22d36b488 100755
--- a/tasks/e2e.sh
+++ b/tasks/e2e.sh
@@ -117,8 +117,9 @@ $root_path/node_modules/.bin/lerna bootstrap
 
 cd $clean_path/packages/react-scripts
 
-# This modifies package.json to copy all dependencies to bundledDependencies
-node ./node_modules/.bin/bundle-deps
+# Like bundle-deps, this script modifies packages/react-scripts/package.json,
+# copying own dependencies (those in the `packages` dir) to bundledDependencies
+node $clean_path/tasks/bundle-own-deps.js
 
 # Finally, pack react-scripts
 scripts_path=$clean_path/packages/react-scripts/`npm pack`
-- 
GitLab