-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Yarn workspaces #1810
Yarn workspaces #1810
Conversation
# Conflicts: # yarn.lock
Codecov Report
@@ Coverage Diff @@
## release/3.3 #1810 +/- ##
===============================================
- Coverage 23.34% 23.32% -0.02%
===============================================
Files 277 281 +4
Lines 6041 6045 +4
Branches 703 708 +5
===============================================
Hits 1410 1410
+ Misses 4136 4126 -10
- Partials 495 509 +14
Continue to review full report at Codecov.
|
package.json
Outdated
"scripts": { | ||
"bootstrap": "./scripts/bootstrap.js", | ||
"bootstrap:core": "lerna bootstrap --concurrency 1 --npm-client=\"yarn\" --hoist && node ./scripts/hoist-internals.js", | ||
"bootstrap:docs": "cd docs && yarn install", | ||
"bootstrap:core": "yarn install && lerna run prepublish && node ./scripts/hoist-internals.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.
Unfortunately, at the moment yarn doesn't run lifecycle hooks when bootstrapping workspaces: yarnpkg/yarn#3911
That's why we need lerna run prepublish
here
package.json
Outdated
"scripts": { | ||
"bootstrap": "./scripts/bootstrap.js", | ||
"bootstrap:core": "lerna bootstrap --concurrency 1 --npm-client=\"yarn\" --hoist && node ./scripts/hoist-internals.js", | ||
"bootstrap:docs": "cd docs && yarn install", | ||
"bootstrap:core": "yarn install && lerna run prepublish && node ./scripts/hoist-internals.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.
We can probably now remove yarn install
step from yarn bootstrap --reset
task, as it runs anyway as part of yarn bootstrap --core
package.json
Outdated
@@ -80,7 +88,8 @@ | |||
"symlink-dir": "^1.1.0" | |||
}, | |||
"engines": { | |||
"node": "node" | |||
"node": "^8.0.0", |
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.
This just states the limitation we have de facto
"git add" | ||
], | ||
"*.json": [ | ||
"npm run lint:js -- --fix", | ||
"yarn lint:js --fix", | ||
"git add" | ||
], | ||
"*.md": [ |
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.
Unfortunately when I try to use yarn for *.md
tasks, yarn precommit
hangs
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.
@@ -15,7 +15,7 @@ log.addLevel('success', 3001, { fg: 'green', bold: true }); | |||
log.info(prefix, 'Hoisting internal packages'); | |||
|
|||
const getLernaPackages = () => | |||
fse.readJson(path.join(__dirname, '..', 'lerna.json')).then(json => json.packages); | |||
fse.readJson(path.join(__dirname, '..', 'package.json')).then(json => json.workspaces); |
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've noticed that this script always yields Hoisted 0 packages
. So either something is broken, or yarn
does what's needed. @ndelangen can you please check?
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 think yarn workspaces already hoists everything?
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.
Looks like that, I just want to be sure about this
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.
This entire script can be removed if this PR comes thru
"storybook-server": "./dist/server/index.js" | ||
"build-storybook": "./bin/build.js", | ||
"start-storybook": "bin/index.js", | ||
"storybook-server": "bin/index.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.
This change is needed because yarn needs some files to link as binaries, see https://github.com/storybooks/storybook/pull/1810/files#r137413061
…now part of bootstrap:core # Conflicts: # .circleci/config.yml
"publish": { | ||
"ignore": [ | ||
"cra-kitchen-sink", | ||
"crna-kitchen-sink", |
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.
@Hypnosphi we don't need these because ... "private: true" in package.json?
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.
] | ||
} | ||
}, | ||
"packages": [ |
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.
@Hypnosphi why don't we need this anymore?
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.
https://github.com/lerna/lerna#--use-workspaces
If
--use-workspaces
is true thenpackages
will be overridden by the value frompackage.json/workspaces
.
@Hypnosphi Awesome!! I'm excited to learn about workspaces. I tried them out on another project and reverted because it didn't seem to do what I wanted, but I'm eager to learn the right way on storybook 😸 |
command: | | ||
node --version | ||
npm --version | ||
yarn --version |
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.
why?
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.
yarn version won't print the correct version anymore, This script isn't providing value really.
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.
Maybe comment it instead? To reenable once docker image gets updated
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.
Meh, it's really not useful the info is in the logs anyway.
scripts/bootstrap.js
Outdated
@@ -71,6 +77,9 @@ const tasks = { | |||
defaultValue: true, | |||
option: '--core', | |||
command: () => { | |||
log.info(prefix, 'prepublish'); | |||
spawn('lerna run prepublish -- --silent'); |
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.
this won't work without global lerna installed
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.
and without some package deps like babel
as well
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.
isn't lerna a local dependency?
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.
Hmm, yes, didn't know you can run local deps with spawn
. The problem is that we effectively yarn install
two times in this setup. Why not just once?
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.
Ok, you can't run bootstrap script without root dependencies anyway
…k` runs `prepublish` anyway
…`npm pack` runs `prepublish` anyway" This reverts commit f3046d5.
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.
WORKS ON MY MACHINE
# Conflicts: # package.json
- run: | ||
name: "Bootstrapping" | ||
command: | | ||
yarn bootstrap -- --all | ||
yarn bootstrap --core --docs --reactnative --reactnativeapp |
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.
What was wrong with --all
?
Oh I see, the reset step would remove the cache
Issue: when running
yarn
in root packages, all the locks for non-root packages are cleared and then recreated withlerna bootstrap
. See Hypnosphi#85 (comment)How to test