Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove bundledDependencies #1068

Merged
merged 1 commit into from
Nov 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
49 changes: 1 addition & 48 deletions packages/react-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
}
9 changes: 6 additions & 3 deletions tasks/cra.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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 "$@"
Expand Down
14 changes: 11 additions & 3 deletions tasks/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -97,13 +98,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.
# ******************************************************************************
Expand Down
17 changes: 0 additions & 17 deletions tasks/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
12 changes: 7 additions & 5 deletions tasks/bundle-own-deps.js → tasks/replace-own-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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.');
});