Skip to content

Commit 302b9ec

Browse files
fsongaearon
authored andcommitted
Attempt to fix the e2e test (#704)
Only copy our own packages to bundledDependencies in the e2e test
1 parent bc6392a commit 302b9ec

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

tasks/bundle-own-deps.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env node
2+
/**
3+
* Copyright (c) 2015-present, Facebook, Inc.
4+
* All rights reserved.
5+
*
6+
* This source code is licensed under the BSD-style license found in the
7+
* LICENSE file in the root directory of this source tree. An additional grant
8+
* of patent rights can be found in the PATENTS file in the same directory.
9+
*/
10+
'use strict';
11+
12+
// Like bundle-deps, this script modifies packages/react-scripts/package.json,
13+
// copying own dependencies (those in the `packages` dir) to bundledDependencies
14+
15+
const fs = require('fs');
16+
const path = require('path');
17+
18+
const packagesDir = path.join(__dirname, '../packages');
19+
const pkgFilename = path.join(packagesDir, 'react-scripts/package.json');
20+
const data = require(pkgFilename);
21+
22+
data.bundledDependencies = fs.readdirSync(packagesDir)
23+
.filter((name) => data.dependencies[name]);
24+
25+
fs.writeFile(pkgFilename, JSON.stringify(data, null, 2), 'utf8', (err) => {
26+
if (err) throw err;
27+
console.log('bundled ' + data.bundledDependencies.length + ' dependencies.');
28+
});

tasks/e2e.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,9 @@ $root_path/node_modules/.bin/lerna bootstrap
117117

118118
cd $clean_path/packages/react-scripts
119119

120-
# This modifies package.json to copy all dependencies to bundledDependencies
121-
node ./node_modules/.bin/bundle-deps
120+
# Like bundle-deps, this script modifies packages/react-scripts/package.json,
121+
# copying own dependencies (those in the `packages` dir) to bundledDependencies
122+
node $clean_path/tasks/bundle-own-deps.js
122123

123124
# Finally, pack react-scripts
124125
scripts_path=$clean_path/packages/react-scripts/`npm pack`

0 commit comments

Comments
 (0)