-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use standalone .js bundle in dist tarball rather than individual JS f…
…iles (#3030) Instead of including all the raw JS files in the dist tarball, just use the single Yarn JS file that's built as part of the build, along with a few other files that are required. This significantly reduces the number of files in the tarball: ``` C:\src\yarn\dist (bundle-as-dist) ([email protected]) λ find . . ./bin ./bin/node-gyp-bin ./bin/node-gyp-bin/node-gyp ./bin/node-gyp-bin/node-gyp.cmd ./bin/yarn ./bin/yarn.cmd ./bin/yarn.js ./bin/yarnpkg ./bin/yarnpkg.cmd ./lib ./lib/v8-compile-cache.js ./lib/yarn-cli.js ./LICENSE ./package.json ``` There are three .js files in the archive: - `lib/v8-compile-cache.js`: Speeds up instantiation time by using the V8 code cache (https://www.npmjs.com/package/v8-compile-cache). This needs to be separate as it has to load **before** the bulk of the application code is loaded, so it can **not** be bundled - `lib/yarn-cli.js`: Contains all the bundled Yarn code - `bin/yarn.js`: Entry point to the app, just like today. Loads `v8-compile-cache` then loads `yarn-cli` This change means that **only** the JavaScript files that are actually used are included, resulting in a nice file size reduction for the installation packages: ![](http://ss.dan.cx/2017/04/Yarn_bundle_dist_metrics_-_Google_Sheets_-_Google__01-13.51.49.png) Differences are due to differing compression algorithms: Debian packages use xz or LZMA, RedHat uses gzip, Windows installer uses Cabinet They're also slightly faster to extract: ![image 3](https://cloud.githubusercontent.com/assets/91933/24582332/483b41f4-16e2-11e7-9509-8024b1e78a39.png) Testing was performed on my desktop computer (Intel Core i5 6500, Samsung 850 Evo 1TB SSD, Windows 10), with testing for Linux stuff (like installing the Debian package) tested in a Docker container. Raw data: https://docs.google.com/spreadsheets/d/1d8jdf3DU_GUFdotlPl08PkYa8SkzStK2tgnQ54ivsm0/edit?usp=sharing Performance is very slightly faster when using `v8-compile-cache` along with the bundled file, but it's not extremely significant (`yarn --version` went from 0.19s to 0.14s on my BuyVM server). The difference might be bigger on servers with slower disks (HDD) or with more overloaded servers. I also deleted the `build-dist.ps1` file because we _should_ be able to assume that Bash is available on Windows, particularly if Git is installed (as it comes with Git Bash). I need to verify that this works on AppVeyor.
- Loading branch information
Showing
13 changed files
with
84 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
/.nyc_output | ||
/coverage | ||
/dist | ||
/dist-debug | ||
/artifacts | ||
/updates | ||
/.roadrunner.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
/scripts | ||
/coverage | ||
/dist | ||
/dist-debug | ||
/__tests__ | ||
/.roadrunner.json | ||
.vs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env node | ||
|
||
/* eslint-disable flowtype/require-valid-file-annotation */ | ||
'use strict'; | ||
|
||
require('../lib/v8-compile-cache'); | ||
module.exports = require('../lib/yarn-cli'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/sh | ||
set -ex | ||
|
||
# This is similar to build-dist.sh, except it includes the original .js files | ||
# rather than bundling them into a single .js file. This distribution can | ||
# potentially be useful for debugging purposes, but it's more bloated than the | ||
# regular distribution. | ||
|
||
npm run build | ||
npm pack | ||
rm -rf dist-debug | ||
mkdir dist-debug | ||
mkdir -p artifacts | ||
mv yarn-*.tgz dist-debug/pack.tgz | ||
|
||
cd dist-debug | ||
umask 0022 # Ensure permissions are correct (0755 for dirs, 0644 for files) | ||
tar -xzf pack.tgz --strip 1 | ||
rm -rf pack.tgz | ||
# Change this to "yarn install --production" once #1115 is fixed | ||
npm install --production | ||
../scripts/set-installation-method.js $(readlink -f package.json) tar | ||
cd .. | ||
|
||
tar -cvzf artifacts/yarn-v`dist-debug/bin/yarn --version`.tar.gz dist-debug/* | ||
shasum -a 256 artifacts/yarn-*.tar.gz |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,40 @@ | ||
#!/bin/sh | ||
|
||
#!/bin/bash | ||
set -ex | ||
# Builds the release tarball for Yarn. | ||
|
||
umask 0022 # Ensure permissions are correct (0755 for dirs, 0644 for files) | ||
|
||
npm run build | ||
npm pack | ||
# Workaround for https://github.com/yarnpkg/yarn/issues/2591 | ||
case "$(uname -s)" in | ||
*CYGWIN*|MSYS*|MINGW*) | ||
dist_yarn=dist/bin/yarn.cmd | ||
system_yarn=yarn.cmd | ||
;; | ||
*) | ||
dist_yarn=dist/bin/yarn | ||
system_yarn=yarn | ||
;; | ||
esac | ||
|
||
rm -rf artifacts dist | ||
rm -rf dist | ||
mkdir dist | ||
mkdir -p artifacts | ||
mv yarn-*.tgz dist/pack.tgz | ||
mkdir artifacts | ||
mkdir dist{,/bin,/lib} | ||
|
||
cd dist | ||
umask 0022 # Ensure permissions are correct (0755 for dirs, 0644 for files) | ||
tar -xzf pack.tgz --strip 1 | ||
rm -rf pack.tgz | ||
# Change this to "yarn install --production" once #1115 is fixed | ||
npm install --production | ||
../scripts/clean-node-modules.sh | ||
../scripts/set-installation-method.js $(readlink -f package.json) tar | ||
cd .. | ||
# Workaround for https://github.com/yarnpkg/yarn/issues/2591 | ||
eval $system_yarn run build | ||
eval $system_yarn run build-bundle | ||
chmod +x artifacts/*.js | ||
|
||
cp package.json dist/ | ||
cp LICENSE dist/ | ||
cp artifacts/yarn-legacy-*.js dist/lib/yarn-cli.js | ||
cp bin/yarn-bundle-entry.js dist/bin/yarn.js | ||
cp bin/{yarn,yarnpkg,*.cmd} dist/bin/ | ||
cp -r bin/node-gyp-bin dist/bin/ | ||
# We cannot bundle v8-compile-cache as it must be loaded separately to be effective. | ||
cp node_modules/v8-compile-cache/v8-compile-cache.js dist/lib/v8-compile-cache.js | ||
|
||
tar -cvzf artifacts/yarn-v`dist/bin/yarn --version`.tar.gz dist/* | ||
shasum -a 256 artifacts/yarn-*.tar.gz | ||
version=`exec $dist_yarn --version` | ||
./scripts/set-installation-method.js $(readlink -f dist/package.json) tar | ||
tar -cvzf artifacts/yarn-v$version.tar.gz dist/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.