From 27d6e93729be675df1fab2d83c0be7b1aff30981 Mon Sep 17 00:00:00 2001 From: Ville Immonen Date: Mon, 21 Nov 2016 13:26:07 +0200 Subject: [PATCH] Remove bundledDependencies (#1068) * Remove bundledDependencies * Change the e2e scripts to use local file dependencies instead of bundledDependencies to test the packages --- CONTRIBUTING.md | 2 +- packages/react-scripts/package.json | 49 +------------------ tasks/cra.sh | 9 ++-- tasks/e2e.sh | 14 ++++-- tasks/release.sh | 17 ------- ...bundle-own-deps.js => replace-own-deps.js} | 12 +++-- 6 files changed, 26 insertions(+), 77 deletions(-) rename tasks/{bundle-own-deps.js => replace-own-deps.js} (66%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bc0f7aa0030..0cb0ed88a5a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -68,7 +68,7 @@ and then run `npm start` or `npm run build`. 6. Make sure to include “Migrating from ...” instructions for the previous release. Often you can copy and paste them. 7. After merging the changelog update, create a GitHub Release with the same text. See previous Releases for inspiration. 8. **Do not run `npm publish`. Instead, run `npm run publish`.** -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. +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. 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`. diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 3bad0b428f5..1558529da5c 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -68,57 +68,10 @@ "whatwg-fetch": "1.0.0" }, "devDependencies": { - "bundle-deps": "1.0.0", "react": "^15.3.0", "react-dom": "^15.3.0" }, "optionalDependencies": { "fsevents": "1.0.14" - }, - "bundledDependencies": [ - "autoprefixer", - "babel-core", - "babel-eslint", - "babel-jest", - "babel-loader", - "babel-preset-react-app", - "case-sensitive-paths-webpack-plugin", - "chalk", - "connect-history-api-fallback", - "cross-spawn", - "css-loader", - "detect-port", - "dotenv", - "eslint", - "eslint-config-react-app", - "eslint-loader", - "eslint-plugin-flowtype", - "eslint-plugin-import", - "eslint-plugin-jsx-a11y", - "eslint-plugin-react", - "extract-text-webpack-plugin", - "file-loader", - "filesize", - "find-cache-dir", - "fs-extra", - "gzip-size", - "html-webpack-plugin", - "http-proxy-middleware", - "jest", - "json-loader", - "object-assign", - "path-exists", - "postcss-loader", - "promise", - "react-dev-utils", - "recursive-readdir", - "rimraf", - "strip-ansi", - "style-loader", - "url-loader", - "webpack", - "webpack-dev-server", - "webpack-manifest-plugin", - "whatwg-fetch" - ] + } } diff --git a/tasks/cra.sh b/tasks/cra.sh index 0271536d706..f63fd464b0c 100755 --- a/tasks/cra.sh +++ b/tasks/cra.sh @@ -59,9 +59,9 @@ cd packages/react-scripts # Save package.json because we're going to touch it cp package.json package.json.orig -# Like bundle-deps, this script modifies packages/react-scripts/package.json, -# copying own dependencies (those in the `packages` dir) to bundledDependencies -node $root_path/tasks/bundle-own-deps.js +# Replace own dependencies (those in the `packages` dir) with the local paths +# of those packages. +node $root_path/tasks/replace-own-deps.js # Finally, pack react-scripts scripts_path=$root_path/packages/react-scripts/`npm pack` @@ -75,6 +75,9 @@ mv package.json.orig package.json # Now that we have packed them, call the global CLI. # ****************************************************************************** +# If Yarn is installed, clean its cache because it may have cached react-scripts +yarn cache clean || true + # Go back to the root directory and run the command from here cd $root_path node packages/create-react-app/index.js --scripts-version=$scripts_path "$@" diff --git a/tasks/e2e.sh b/tasks/e2e.sh index 9066af93f21..557b48ccda2 100755 --- a/tasks/e2e.sh +++ b/tasks/e2e.sh @@ -57,6 +57,7 @@ if [ "$USE_YARN" = "yes" ] then # Install Yarn so that the test can use it to install packages. npm install -g yarn + yarn cache clean fi npm install @@ -96,13 +97,20 @@ cli_path=$PWD/`npm pack` # Go to react-scripts cd $root_path/packages/react-scripts -# Like bundle-deps, this script modifies packages/react-scripts/package.json, -# copying own dependencies (those in the `packages` dir) to bundledDependencies -node $root_path/tasks/bundle-own-deps.js +# Save package.json because we're going to touch it +cp package.json package.json.orig + +# Replace own dependencies (those in the `packages` dir) with the local paths +# of those packages. +node $root_path/tasks/replace-own-deps.js # Finally, pack react-scripts scripts_path=$root_path/packages/react-scripts/`npm pack` +# Restore package.json +rm package.json +mv package.json.orig package.json + # ****************************************************************************** # Now that we have packed them, create a clean app folder and install them. # ****************************************************************************** diff --git a/tasks/release.sh b/tasks/release.sh index 14b5cb77b18..1520a5f0785 100755 --- a/tasks/release.sh +++ b/tasks/release.sh @@ -39,23 +39,6 @@ if [ -n "$(git status --porcelain)" ]; then exit 1; fi -# Update deps -rm -rf node_modules -rm -rf ~/.npm -npm cache clear -npm install - -cd packages/react-scripts -# Force dedupe -npm dedupe - -# Don't bundle fsevents because it is optional and OS X-only -# Since it's in optionalDependencies, it will attempt install outside bundle -rm -rf node_modules/fsevents - -# This modifies package.json to copy all dependencies to bundledDependencies -node ./node_modules/.bin/bundle-deps - cd $root_path # Go! ./node_modules/.bin/lerna publish --independent "$@" diff --git a/tasks/bundle-own-deps.js b/tasks/replace-own-deps.js similarity index 66% rename from tasks/bundle-own-deps.js rename to tasks/replace-own-deps.js index 61408f1cc00..23a3f4a01fe 100755 --- a/tasks/bundle-own-deps.js +++ b/tasks/replace-own-deps.js @@ -9,8 +9,7 @@ */ 'use strict'; -// Like bundle-deps, this script modifies packages/react-scripts/package.json, -// copying own dependencies (those in the `packages` dir) to bundledDependencies +// Replaces internal dependencies in package.json with local package paths. const fs = require('fs'); const path = require('path'); @@ -19,10 +18,13 @@ 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.readdirSync(packagesDir).forEach((name) => { + if (data.dependencies[name]) { + data.dependencies[name] = 'file:' + path.join(packagesDir, name); + } +}) fs.writeFile(pkgFilename, JSON.stringify(data, null, 2), 'utf8', (err) => { if (err) throw err; - console.log('bundled ' + data.bundledDependencies.length + ' dependencies.'); + console.log('Replaced local dependencies.'); });