Skip to content

Commit e042634

Browse files
authored
Remove bundledDependencies (#1068)
* Remove bundledDependencies * Change the e2e scripts to use local file dependencies instead of bundledDependencies to test the packages
1 parent 29299f2 commit e042634

File tree

6 files changed

+26
-77
lines changed

6 files changed

+26
-77
lines changed

Diff for: CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ and then run `npm start` or `npm run build`.
6868
6. Make sure to include “Migrating from ...” instructions for the previous release. Often you can copy and paste them.
6969
7. After merging the changelog update, create a GitHub Release with the same text. See previous Releases for inspiration.
7070
8. **Do not run `npm publish`. Instead, run `npm run publish`.**
71-
9. Wait for a long time, and it will get published. Don’t worry that it’s stuck. It will bundle dependencies into a single tarball before publishing for faster installs. In the end the publish script will prompt for versions before publishing the packages.
71+
9. Wait for a long time, and it will get published. Don’t worry that it’s stuck. In the end the publish script will prompt for versions before publishing the packages.
7272

7373
Make sure to test the released version! If you want to be extra careful, you can publish a prerelease by running `npm run publish -- --tag next` instead of `npm run publish`.
7474

Diff for: packages/react-scripts/package.json

+1-48
Original file line numberDiff line numberDiff line change
@@ -68,57 +68,10 @@
6868
"whatwg-fetch": "1.0.0"
6969
},
7070
"devDependencies": {
71-
"bundle-deps": "1.0.0",
7271
"react": "^15.3.0",
7372
"react-dom": "^15.3.0"
7473
},
7574
"optionalDependencies": {
7675
"fsevents": "1.0.14"
77-
},
78-
"bundledDependencies": [
79-
"autoprefixer",
80-
"babel-core",
81-
"babel-eslint",
82-
"babel-jest",
83-
"babel-loader",
84-
"babel-preset-react-app",
85-
"case-sensitive-paths-webpack-plugin",
86-
"chalk",
87-
"connect-history-api-fallback",
88-
"cross-spawn",
89-
"css-loader",
90-
"detect-port",
91-
"dotenv",
92-
"eslint",
93-
"eslint-config-react-app",
94-
"eslint-loader",
95-
"eslint-plugin-flowtype",
96-
"eslint-plugin-import",
97-
"eslint-plugin-jsx-a11y",
98-
"eslint-plugin-react",
99-
"extract-text-webpack-plugin",
100-
"file-loader",
101-
"filesize",
102-
"find-cache-dir",
103-
"fs-extra",
104-
"gzip-size",
105-
"html-webpack-plugin",
106-
"http-proxy-middleware",
107-
"jest",
108-
"json-loader",
109-
"object-assign",
110-
"path-exists",
111-
"postcss-loader",
112-
"promise",
113-
"react-dev-utils",
114-
"recursive-readdir",
115-
"rimraf",
116-
"strip-ansi",
117-
"style-loader",
118-
"url-loader",
119-
"webpack",
120-
"webpack-dev-server",
121-
"webpack-manifest-plugin",
122-
"whatwg-fetch"
123-
]
76+
}
12477
}

Diff for: tasks/cra.sh

+6-3
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ cd packages/react-scripts
5959
# Save package.json because we're going to touch it
6060
cp package.json package.json.orig
6161

62-
# Like bundle-deps, this script modifies packages/react-scripts/package.json,
63-
# copying own dependencies (those in the `packages` dir) to bundledDependencies
64-
node $root_path/tasks/bundle-own-deps.js
62+
# Replace own dependencies (those in the `packages` dir) with the local paths
63+
# of those packages.
64+
node $root_path/tasks/replace-own-deps.js
6565

6666
# Finally, pack react-scripts
6767
scripts_path=$root_path/packages/react-scripts/`npm pack`
@@ -75,6 +75,9 @@ mv package.json.orig package.json
7575
# Now that we have packed them, call the global CLI.
7676
# ******************************************************************************
7777

78+
# If Yarn is installed, clean its cache because it may have cached react-scripts
79+
yarn cache clean || true
80+
7881
# Go back to the root directory and run the command from here
7982
cd $root_path
8083
node packages/create-react-app/index.js --scripts-version=$scripts_path "$@"

Diff for: tasks/e2e.sh

+11-3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ if [ "$USE_YARN" = "yes" ]
5757
then
5858
# Install Yarn so that the test can use it to install packages.
5959
npm install -g yarn
60+
yarn cache clean
6061
fi
6162

6263
npm install
@@ -96,13 +97,20 @@ cli_path=$PWD/`npm pack`
9697
# Go to react-scripts
9798
cd $root_path/packages/react-scripts
9899

99-
# Like bundle-deps, this script modifies packages/react-scripts/package.json,
100-
# copying own dependencies (those in the `packages` dir) to bundledDependencies
101-
node $root_path/tasks/bundle-own-deps.js
100+
# Save package.json because we're going to touch it
101+
cp package.json package.json.orig
102+
103+
# Replace own dependencies (those in the `packages` dir) with the local paths
104+
# of those packages.
105+
node $root_path/tasks/replace-own-deps.js
102106

103107
# Finally, pack react-scripts
104108
scripts_path=$root_path/packages/react-scripts/`npm pack`
105109

110+
# Restore package.json
111+
rm package.json
112+
mv package.json.orig package.json
113+
106114
# ******************************************************************************
107115
# Now that we have packed them, create a clean app folder and install them.
108116
# ******************************************************************************

Diff for: tasks/release.sh

-17
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,6 @@ if [ -n "$(git status --porcelain)" ]; then
3939
exit 1;
4040
fi
4141

42-
# Update deps
43-
rm -rf node_modules
44-
rm -rf ~/.npm
45-
npm cache clear
46-
npm install
47-
48-
cd packages/react-scripts
49-
# Force dedupe
50-
npm dedupe
51-
52-
# Don't bundle fsevents because it is optional and OS X-only
53-
# Since it's in optionalDependencies, it will attempt install outside bundle
54-
rm -rf node_modules/fsevents
55-
56-
# This modifies package.json to copy all dependencies to bundledDependencies
57-
node ./node_modules/.bin/bundle-deps
58-
5942
cd $root_path
6043
# Go!
6144
./node_modules/.bin/lerna publish --independent "$@"

Diff for: tasks/bundle-own-deps.js renamed to tasks/replace-own-deps.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
*/
1010
'use strict';
1111

12-
// Like bundle-deps, this script modifies packages/react-scripts/package.json,
13-
// copying own dependencies (those in the `packages` dir) to bundledDependencies
12+
// Replaces internal dependencies in package.json with local package paths.
1413

1514
const fs = require('fs');
1615
const path = require('path');
@@ -19,10 +18,13 @@ const packagesDir = path.join(__dirname, '../packages');
1918
const pkgFilename = path.join(packagesDir, 'react-scripts/package.json');
2019
const data = require(pkgFilename);
2120

22-
data.bundledDependencies = fs.readdirSync(packagesDir)
23-
.filter((name) => data.dependencies[name]);
21+
fs.readdirSync(packagesDir).forEach((name) => {
22+
if (data.dependencies[name]) {
23+
data.dependencies[name] = 'file:' + path.join(packagesDir, name);
24+
}
25+
})
2426

2527
fs.writeFile(pkgFilename, JSON.stringify(data, null, 2), 'utf8', (err) => {
2628
if (err) throw err;
27-
console.log('bundled ' + data.bundledDependencies.length + ' dependencies.');
29+
console.log('Replaced local dependencies.');
2830
});

0 commit comments

Comments
 (0)