-
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
Calypso Build Package: Add calypso-build
bin shorthand
#32295
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Webpack Runtime
App Entrypoints
Sections
Async-loaded Components
Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
docs/monorepo.md
Outdated
@@ -1,5 +1,4 @@ | |||
Publishing Packages with the Monorepo | |||
===================================== | |||
# Publishing Packages with the Monorepo |
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 could change this to just "Publishing with the Monorepo" now that we also have /apps
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.
a955fb4
to
a88bf81
Compare
I'm starting to wonder if we can easily do this 🤔
However (unlike the script that we use to transpile JS), our webpack call is just that: a call to webpack, with an argument provided, and accepting other arguments. And due to our monorepo setup, we can't simply point a This leaves us with the following options:
|
cc @gziolo & @mkaz since this seems related to comment in https://make.wordpress.org/core/2019/03/25/building-javascript/#comment-35581 |
Well, this is what we do in https://github.com/WordPress/gutenberg/blob/master/packages/scripts/bin/wp-scripts.js It's the same technique that create-react-app or ksc-scripts are using. |
I think we can get I needed to At that point, I have Through some… ehem… fanciness… we essentially get a pass-through to webpack's CLI with a default |
packages/tree-select/package.json
Outdated
@@ -29,6 +29,6 @@ | |||
"scripts": { | |||
"clean": "npx rimraf dist", | |||
"prepublish": "npm run clean", | |||
"prepare": "npx @automattic/calypso-build" | |||
"prepare": "../calypso-build/bin/transpile.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.
Ugly but effective 😅
The npx --package @automattic/calypso-build transpile
version was broken 😬
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.
How was that broken? 🤔
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.
(Fine to keep the ugly-but-effective version to be able to ship this soon.)
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 may have been wrong and "fixed" this before doing the distclean
dance to get the monorepo package bins properly installed.
Please double check me, we may be able to use npx --package @automattic/calypso-build transpile
, although I suspect the change will be painful for some folks as they'll likely experience the same problem.
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.
Wondering if #32383 might've been the actual reason for this. Seems like a stretch, but maybe some silent error when trying to build a local package along the dependency chain?
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 reverted the commit since it seems to work in my testing 🤔 I'll leave it to reviewers/testers to correct me there...
cb
bin shorthand
Thanks Jon, loving it! I've pushed a commit to have our |
2a753bd
to
40cc278
Compare
Finall figured out the build error ( |
Somewhat related: #32389 to guard against broken |
2047809
to
619ced7
Compare
This can probably be switched to use Line 233 in 150878d
(the whole thing should probably be in |
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 fantastic and works well in my testing.
Tested:
npm ci
npm start
npm run build-notifications
:
Line 233 in 150878d
"build-notifications": "webpack --config='client/notifications/webpack.config.js'", npm run build-notifications
: by switchingwebpack
tocb
npx lerna run build
npx lerna run prepare
Only standing note I left was about build-notifications
This reverts commit 5da3969d80f8713012474fb5aa6688c965a46757.
60b9d96
to
f220fac
Compare
Done |
apps/full-site-editing/package.json
Outdated
@@ -16,10 +16,10 @@ | |||
}, | |||
"homepage": "https://github.com/Automattic/wp-calypso", | |||
"scripts": { | |||
"plugin": "webpack --source='plugin'", | |||
"plugin": "cb --config='./webpack.config.js' --source='plugin' --env.WP", |
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 you know where these --source
arguments come from? I don't see them documented in webpack CLI.
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.
Yeah, they're a custom addition to argv
in full-site-editing
's Webpack config:
* @param {object} argv.source "plugin" or "theme" |
Was also wondering if we should discourage 🤔
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.
Was also wondering if we should discourage 🤔
Oh, that's interesting! I'd say cb
itself should be very strict about adhering to the webpack CLI, but let's not prescribe how consumers should use it (yet)…
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.
Some feedback about naming:
cb
feels like something very generic, like a shell command. Specialized commands should have longer names, e.g.,calypso-build
.webpack --source
: again, very generic, looks like a built-in webpack option.--calypso-something-source
would communicate better that it's something custom.
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.
Thanks Jarda! I tend to agree with both points.
For a while, I was thinking that cb
was a nice shorthand, and that we could use npx --package=@automattic/calypso-build cb
to make sure we're getting the right command, but using that caused some rather annoying that I wasn't able to resolve easily.
Inclined to file a commit to s/cb/calypso-build/g
, unless anyone objects? @sirreal?
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.
cb
feels like something very generic, like a shell command. Specialized commands should have longer names, e.g.,calypso-build
.
@blowery suggested this in the interest of brevity. In practice, this will likely live mostly inside package.json
scripts
🤔 I'm fine either way.
webpack --source
: again, very generic, looks like a built-in webpack option.--calypso-something-source
would communicate better that it's something custom.
This isn't a "core" calypso-build
option, but some configuration that a particular webpack config function is exposing which is why I'm not too concerned. It would be harmful if folks start copying the pattern and expect it to be "core" functionality… Perhaps it is something to discourage?
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.
webpack --source
: again, very generic, looks like a built-in webpack option.--calypso-something-source
would communicate better that it's something custom.
Agree. We're using env
(e.g. env.WP
) to communicate Calypso-specific stuff, whereas full-size-editing
deviates from that pattern. However, the --source
arg has been merged prior to this PR and is thus arguably orthogonal to this one, so I'd like to change it with a separate PR.
Co-Authored-By: ockham <ockham@raz.or.at>
Co-Authored-By: ockham <ockham@raz.or.at>
4d32168
to
334f224
Compare
cb
bin shorthandcalypso-build
bin shorthand
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 looking great!
Changes proposed in this Pull Request
bin/build-packages
astranspile
bin. This will allow us to add more bin scripts.calypso-build
alias forwebpack --config=webpack.config.js
Relevant docs: https://docs.npmjs.com/files/package.json#bin
Testing instructions
Verify that
npm run build-packages
still transpiles packages code and writes it topackages/*/dist/cjs
andpackages/*/dist/esm
, respectively.Verify that
apps/
are built successfully.