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
Packages: Add common utilities to WP.com block editor package #32294
Conversation
This PR does not affect the size of JS and CSS bundles shipped to the user's browser. Generated by performance advisor bot at iscalypsofastyet.com. |
apps/wpcom-block-editor/README.md
Outdated
Server-side handlers of the different communication channels we establish with the client-side when Calypso loads the iframed block editor. See [`calypsoify-iframe.jsx`](https://github.com/Automattic/wp-calypso/blob/master/client/gutenberg/editor/calypsoify-iframe.jsx). | ||
- `/common`: Logic than runs on both environments (WP Admin and Calypso). | ||
- `/calypso`: Logic than runs only on the Calypso iframed block editor. | ||
- `/wp-admin`: Logic than runs only on the WP Admin block editor. |
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.
Might as well remove this; it's not present, and not anticipated in the near future.
Awesome work ❤️ I did notice the minified scripts are missing from a manual build, and comparing the artifacts build versus the manual build shows a lot of differences (
This is magnificent, thank you! 🎉 |
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 some good improvements here. I don't see any reason to block merging this.
Thanks @mmtr for updating this code. Those scripts are starting to make me long for our Makefile
again… 😉
"build:common": "npm run bundle -- common='./src/common'", | ||
"build:calypso-iframe-bridge-server": "npm run bundle -- calypso-iframe-bridge-server='./src/calypso/iframe-bridge-server.js'", | ||
"build:calypso-tinymce": "npm run bundle -- calypso-tinymce='./src/calypso/tinymce.js'", | ||
"build": "npm-run-all --parallel \"build:* -- {@}\" --" |
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.
If this gets too funky at some point, you could also create a simple Webpack config for this package that inherits and extends the one from Calypso-build, similarly to client/notifications/
.
Yeah, this is normal since the commands used in the manual build are different from the automatic CircleCi build. The CircleCI job executes two commands:
I was thinking in wrapping these 2 commands in a single npm script that replaces the current Probably in this case we want consistency rather than flexibility, so I'm going to commit a change grouping the 2 commands so Edit: changed in a12f1c8 @sirreal @simison @ockham let me know if should take another approach here. |
"@wordpress/url": "2.3.3", | ||
"jquery": "^1.12", | ||
"lodash": "4.17.11", | ||
"react": "16.8.6", | ||
"tinymce": "4.8.5" | ||
}, | ||
"devDependencies": { |
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.
A peculiarity of monorepo: devDependencies
in non-root packages don't really mean anything. It's preferable to never include them, any devDependencies must be in the root package.
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.
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.
Changes proposed in this Pull Request
Add a new folder for all the common utilities we need to run in both block editor environments (Gutenframe and WP Admin).
So far, these utilities are the rich text extensions to add the missing formats in Core (justify, underline) and the "Switch to Classic" button on the "More tools" menu.
The logic of these utilities were previously maintained on the
gutenberg-wpcom.js
file, so the files added to thecommon/
folder on this PR contain the same code but using ES2015+ syntax.The documentation has also changed in order to make more obvious there are 2 environments we need to support. Note that I also grouped the previous scripts in a
calypso/
folder to reflect that the utilities inside this folder will be run only in a iframed block editor context.Given that this is adding a new entry file to the build script, I decided to split the
bundle
script into 3 smallerbuild
scripts (one for each entry file), so we don't have a very long script command. Thebuild
scripts runs now all the smaller build scripts in parallel (usingnpm-run-all
) and requires an explicit output path (reason why theclean
script is not needed anymore).Testing instructions
Check D26970-code