-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Framework: Add lerna to publish @automattic/simple-components
#16782
Conversation
454ed82
to
b78e15a
Compare
client/components/package.json
Outdated
"version": "0.1.0-alpha.1", | ||
"description": "React components, as used on WordPress.com", | ||
"scripts": { | ||
"build": "babel ./index.js --out-dir cjs && babel ./button --out-dir cjs/button && babel ./main --out-dir cjs/main", |
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.
Noting here that I also tried
babel --only ./index.js,./button/,./main/ --out-dir cjs .
but that is unfortunately evaluated as a glob (and apparently broken) since it includes e.g. every path that ends in button/
or main
/, and every index.js[x]
(as opposed to just top-level ones).
Babel 7 changes --only
and --ignore
args to be evaluated as relative paths instead of globs.
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 might want to consider moving components that are supposed to go into simple-components
into a separate subfolder, e.g. client/components/simple
. This is going to save us a lot of hassle.
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.
Also, I should probably file an issue against Babel 6, since this behavior doesn't seem right.
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.
Also, I should probably file an issue against Babel 6, since this behavior doesn't seem right.
3c15803
to
481c294
Compare
b827025
to
152a883
Compare
@automattic/simple-components
5724135
to
94cd250
Compare
Okay, I'd say this is ready for review! |
package.json
Outdated
@@ -250,6 +251,7 @@ | |||
"glob": "7.0.3", | |||
"husky": "0.13.3", | |||
"jscodeshift": "0.3.30", | |||
"lerna": "^2.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.
Why the ^
s?
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.
Ah, good spot. Comes from running lerna init
. I'll remove the caret.
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.
Same for @automattic/simple-components
.
@gwwar: you need to run |
Summary says:
|
I'd be happy to make
It's normal that when |
package.json
Outdated
@@ -194,12 +195,13 @@ | |||
"clean:public": "npm run -s rm -- public .css .css.map .js .js.map", | |||
"predashboard": "npm run -s install-if-deps-outdated", | |||
"dashboard": "cross-env DASHBOARD=1 webpack-dashboard -- npm start", | |||
"distclean": "npm run -s clean && npm run -s rm -- node_modules", | |||
"distclean": "npm run -s clean && lerna clean --yes && npm run -s rm -- node_modules", |
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 is problematic as lerna
is not global and nothing guarantees it will be present.
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.
No problem here, npm
is adding node_modules/.bin
when running scripts.
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.
Well, there is a problem if it’s not present, of course.
Fixed by replacing the |
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 this is in a good place and ready to move forward. Thanks for your work on it and patience 🙂
I just realized something and wanted to share it here. When we get to Node 8 LTS (mid-october) it will include npm@^5.2 which includes npx, which will automagially local-install required binaries, and we won't have to worry about whether |
package.json
Outdated
@@ -194,12 +195,13 @@ | |||
"clean:public": "npm run -s rm -- public .css .css.map .js .js.map", | |||
"predashboard": "npm run -s install-if-deps-outdated", | |||
"dashboard": "cross-env DASHBOARD=1 webpack-dashboard -- npm start", | |||
"distclean": "npm run -s clean && npm run -s rm -- node_modules", | |||
"distclean": "npm run -s clean && lerna clean --yes ; npm run -s rm -- node_modules", |
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.
Please use &&
instead of ;
, unless for some reason lerna clean
returns a non-zero status on completion.
Nevermind, I've just read the PR comments. Sorry for the noise.
Is this one still going ahead? Thanks |
Still relevant/being discussed, yeah. Would prefer to keep it open for another while. |
Add `lerna` (a monorepo tool) to Calypso, and use it to publish [`@automattic/simple-components`](https://www.npmjs.com/package/@automattic/simple-components) as a separate npm. This involves adding a `package.json`, `.gitignore`, and `.npmignore` to `client/components`, and an `alias` field to Calypso's webpack configs. Since we want Calypso (and possibly other consumers) to continue to use untranspiled code (to benefit from features such as tree-shaking), the npms we produce should contain both transpiled and untranspiled versions of the code. See http://2ality.com/2017/07/npm-packages-via-babel.html, and for more information, http://2ality.com/2017/04/transpiling-dependencies-babel.html and http://2ality.com/2017/06/pkg-esnext.html.
875d43e
to
9b0f1b8
Compare
9b0f1b8
to
e0a31d1
Compare
@ockham Let's give this another 2-3 weeks, if there's no movement I think it's time to move on. |
Any verdict here @ockham of how or whether to proceed? |
Sigh, I haven't found time in the past weeks to reinvigorate the conversation around this idea. So I guess I'll close it 🙁 |
Updated -- no longer requires
lerna
to be installed globally!Add
lerna
(a monorepo tool) to Calypso, and use it to publish@automattic/simple-components
as a separate npm.This involves adding a
package.json
,.gitignore
, and.npmignore
toclient/components
, and analias
field to Calypso's webpack configs.Since we want Calypso (and possibly other consumers) to continue to use untranspiled code (to benefit from features such as tree-shaking), the npms we produce should contain both transpiled and untranspiled versions of the code. See http://2ality.com/2017/07/npm-packages-via-babel.html, and for more information, http://2ality.com/2017/04/transpiling-dependencies-babel.html and http://2ality.com/2017/06/pkg-esnext.html.
Please note #16782 (comment)!
To test:
npm run distclean && npm start
node_modules/@automattic/simple-components
is a symlink toclient/components/
!npm run build-docker
) and running (npm run docker
) the Docker container still works (see PCYsg-5XR-p2).(To publish, run
lerna publish --skip-git
(but don't unless you know what you're doing!) When asked for version, selectPrerelease
for@automattic/simple-components
!)Related (but no longer required for this PR!): #16870.