-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Use standalone .js bundle in dist tarball rather than individual JS files #3030
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3b0fdde
Use standalone .js bundle in dist tarball rather than individual JS f…
Daniel15 5916f40
Work around #2591 by explicitly executing yarn.cmd when building on W…
Daniel15 ac47aa9
Only run shasum if it's installed
Daniel15 0909197
Remove shasum from dist build script altogether - It can be hashed se…
Daniel15 185c5d0
Update build-webpack to work on Node.js 4.x
Daniel15 e58ddf2
Ensure bundled JS works as expected (similar to #3064)
Daniel15 8bda8b9
Include original build-dist script as build-dist-debug.sh
Daniel15 421796c
Adjust how version number is retrieved in CircleCI build
Daniel15 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to copy node-gyp from node_modules, too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, good catch! Do we need it? I tried
yarn install bcrypt
and it seemed to work, but perhaps I have a globally-installed node-gyp or something like that. I can test on a fresh VM and see if it works.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I wonder if Yarn should install node-gyp when needed (ie. run
yarn global add node-gyp
) rather than bundling it? I think bundling node-gyp would also require us to bundle all of its dependencies, so we'll end up with a giant node_modules directory bundled with Yarn again :(There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree.
That actually will solve the issue of single js file distributions.
Maybe Yarn could check if
node-gyp
binary is available and if not then install it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The down side is that in some cases we Yarn might need sudo permissions?
What if Yarn would install node-gyp locally next to yarn.js?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this change anything about #2266?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@teohhanhui - We'll most likely update Yarn to automatically install node-gyp if needed (see #3114)