Perfect your code
With built-in code review tools, GitHub makes it easy to raise the quality bar before you ship. Join the 36 million developers who've merged over 200 million pull requests.
Sign up for free See pricing for teams and enterprisesTry implementing a built-in Gutenberg playground #14497
Conversation
youknowriad
force-pushed the
try/playground
branch
from
5966c47
to
3a4863a
Mar 18, 2019
youknowriad
reviewed
Mar 18, 2019
@@ -103,6 +103,7 @@ | |||
"mkdirp": "0.5.1", | |||
"node-sass": "4.11.0", | |||
"node-watch": "0.6.0", | |||
"parcel-bundler": "1.12.2", |
This comment has been minimized.
This comment has been minimized.
youknowriad
Mar 18, 2019
Author
Contributor
I tried using wp-scripts
but it's not usable at the moment for this kind of use-cases as it automatically uses wp.*
globals. In this particular case I want to bundle the dependencies.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
gziolo
Mar 19, 2019
Member
We would have to add support for CSS as well. Does Parcel cover RTL support?
This comment has been minimized.
This comment has been minimized.
youknowriad
Mar 19, 2019
Author
Contributor
Parcel can support RTL through post-css plugins. That said, I'd prefer using wp-scripts
but there are still things to figure out before:
- Do we want an
--webpack-no-externals
. Is it something useful outside of this playground? - How do we build CSS with
wp-scripts
This comment has been minimized.
This comment has been minimized.
gziolo
Mar 19, 2019
Member
That's a great question for Core JS chat today :)
We should also check with @front team since they have this create-clould-block
tool which scaffolds cloud blocks:
https://github.com/front/create-cloud-block/blob/master/examples/1-simple-block/webpack.config.js
It uses different externals and bundles CSS as well.
youknowriad
reviewed
Mar 18, 2019
youknowriad
reviewed
Mar 18, 2019
*/ | ||
import React from 'react'; | ||
|
||
window.React = React; |
This comment has been minimized.
This comment has been minimized.
youknowriad
Mar 18, 2019
Author
Contributor
Not certain why this is needed yet. Maybe a parcel thing.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
youknowriad
Mar 21, 2019
Author
Contributor
So to solve this, I had to explicitely add the pragma config to the .babelrc
. I'm not sure why this is needed though as in theory it's already done by the wordpress default preset.
youknowriad
reviewed
Mar 18, 2019
/** | ||
* WordPress dependencies | ||
*/ | ||
import '@wordpress/editor'; // This shouldn't be necessary |
This comment has been minimized.
This comment has been minimized.
youknowriad
Mar 18, 2019
Author
Contributor
We're still using core/editor
in some places in the block editor, it should be refactored properly to avoid the need to import this.
youknowriad
reviewed
Mar 18, 2019
import '@wordpress/block-editor/build-style/style.css'; | ||
import '@wordpress/block-library/build-style/style.css'; | ||
import '@wordpress/block-library/build-style/editor.css'; | ||
import '@wordpress/block-library/build-style/theme.css'; |
This comment has been minimized.
This comment has been minimized.
youknowriad
Mar 18, 2019
Author
Contributor
I wonder if should have a simpler way to import all the required CSS styles for an npm package.
This comment has been minimized.
This comment has been minimized.
I noticed that Gutenberg requires some global styles we're including in A lot of core blocks rely on the REST API... to work properly, if we can make them more generic, that would be a good win. I like how this playground (and the fact that we can use it as part of our dev workflow) would allow us to detect issues related to the npm packages more easily. |
This comment has been minimized.
This comment has been minimized.
What is this playground for and how to use it? :) |
This comment has been minimized.
This comment has been minimized.
This playground is to use/try Gutenberg in a context outside of WordPress. this PR is still very early but you can try it by running |
youknowriad
force-pushed the
try/playground
branch
from
da19b50
to
64ad307
Mar 19, 2019
youknowriad
self-assigned this
Mar 19, 2019
youknowriad
marked this pull request as ready for review
Mar 19, 2019
youknowriad
requested a review
from chrisvanpatten
as a
code owner
Mar 19, 2019
youknowriad
requested a review
from WordPress/gutenberg-core
Mar 19, 2019
youknowriad
reviewed
Mar 19, 2019
|
||
// TODO: Extract these WP Global styles to a mixin | ||
// We can't apply these globally to html or body at the moment because of the WP sidebar/menu | ||
:root { |
This comment has been minimized.
This comment has been minimized.
youknowriad
Mar 19, 2019
Author
Contributor
The content of this selector is a "reset" that is applied in Gutenberg but is not applied globally to WordPress as we don't want to mess with the sidebar/topbar. This could be extracted to a mixin as it's useful in edit-widgets as well.
youknowriad
reviewed
Mar 19, 2019
youknowriad
reviewed
Mar 19, 2019
@@ -19,7 +19,7 @@ const FormatToolbar = ( { controls } ) => { | |||
<Slot name={ `RichText.ToolbarControls.${ format }` } key={ format } /> | |||
) } | |||
<Slot name="RichText.ToolbarControls"> | |||
{ ( fills ) => fills.length && | |||
{ ( fills ) => fills.length !== 0 && |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
gziolo
Mar 19, 2019
Member
Now, I remember why I was using isEmpty
in other places. I reviewed this code myself but I couldn't find a reason why it would be wrong
/cc @ellatrix
This comment has been minimized.
This comment has been minimized.
gziolo
reviewed
Mar 19, 2019
This PR is cool. I think this should be part of the repository as it helps to catch some bad practices like all those hacks with CSS imports :) |
.babelrc Outdated
@@ -103,6 +103,7 @@ | |||
"mkdirp": "0.5.1", | |||
"node-sass": "4.11.0", | |||
"node-watch": "0.6.0", | |||
"parcel-bundler": "1.12.2", |
This comment has been minimized.
This comment has been minimized.
youknowriad
force-pushed the
try/playground
branch
2 times, most recently
from
561c8aa
to
3549c93
Mar 21, 2019
youknowriad
added some commits
Mar 18, 2019
youknowriad
force-pushed the
try/playground
branch
from
3549c93
to
8d965d2
Mar 21, 2019
This comment has been minimized.
This comment has been minimized.
youknowriad
referenced this pull request
Mar 21, 2019
Closed
Follow-up tasks to polish the generic block editor module #14043
gziolo
referenced this pull request
Mar 22, 2019
Closed
Enable extending webpack.config.js in packages/scripts/ #14560
gziolo
reviewed
Mar 22, 2019
@@ -190,7 +191,9 @@ | |||
"test-unit:update": "npm run test-unit -- --updateSnapshot", | |||
"test-unit:watch": "npm run test-unit -- --watch", | |||
"test-unit-php": "docker-compose run --rm wordpress_phpunit phpunit", | |||
"test-unit-php-multisite": "docker-compose run -e WP_MULTISITE=1 --rm wordpress_phpunit phpunit" | |||
"test-unit-php-multisite": "docker-compose run -e WP_MULTISITE=1 --rm wordpress_phpunit phpunit", | |||
"playground:build": "npm run build:packages && parcel build playground/src/index.html -d playground/dist", |
This comment has been minimized.
This comment has been minimized.
gziolo
Mar 22, 2019
Member
I have just figured out that we can also use wp-scripts build --config playground/webpack.config.js
:)
This comment has been minimized.
This comment has been minimized.
youknowriad
Mar 22, 2019
Author
Contributor
As I said a lot of time now, I don't see the value of this, it's the same as webpack --config playground/webpack.config.js
This comment has been minimized.
This comment has been minimized.
gziolo
Mar 25, 2019
Member
Parcel does one more thing I didn't think about initially. It runs the server which is quite important in this particular case. Saying that I convinced myself that it is the best way to proceed as is
This comment has been minimized.
This comment has been minimized.
ashwinputhige
commented on 696a229
Mar 24, 2019
There’s a typo - ‘developping’ |
youknowriad
requested a review
from jorgefilipecosta
as a
code owner
Mar 25, 2019
gziolo
reviewed
Mar 25, 2019
@@ -0,0 +1,8 @@ | |||
{ | |||
"presets": ["@wordpress/babel-preset-default"], | |||
"plugins": [ |
This comment has been minimized.
This comment has been minimized.
gziolo
Mar 25, 2019
Member
I figured out why we need it in the first place:
Parcel tries to be smart and overrides our configuration.
gziolo
requested changes
Mar 25, 2019
@@ -0,0 +1,8 @@ | |||
{ |
This comment has been minimized.
This comment has been minimized.
gziolo
Mar 25, 2019
Member
Can we move this config inside playground
folder and maybe remove babel.config.js
which is something wp-scripts build/start
will use in the same form regardless?
This comment has been minimized.
This comment has been minimized.
gziolo
Mar 25, 2019
•
Member
There is no plan of supporting babel.config.js
with Parcel:
parcel-bundler/parcel#2110 (comment)
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@gziolo Actually, there are a lot of these issues and I don't consider them a blocker personally. These are related to the fact that we require plugins for the registry... some API fetch networks should be done only if the WP context... I consider these as separate issues that if solved will improve the reusability of the block editor module and the block library. Related #14043 |
gziolo
added
Technical Prototype
[Type] Task
labels
Mar 25, 2019
gziolo
approved these changes
Mar 25, 2019
Should we add a new label Let's move forward and address those issues separately then. My biggest concerns was the fact that we would have 2 Babel configs in the root folders which would make it confusing to maintain them. It was addressed so let's |
youknowriad
merged commit 8625b82
into
master
Mar 25, 2019
1 check passed
This comment has been minimized.
This comment has been minimized.
Thanks for the review @gziolo |
youknowriad
deleted the
try/playground
branch
Mar 25, 2019
This comment has been minimized.
This comment has been minimized.
Should this be highlighted in tomorrow's Core JS meeting? Having a hard time surmising from the conversation: Is Parcel intended to become a permanent tool? My main thought would be on the impact on install time (I think I measured it around ~8000 new dependencies) and maintaining multiple build toolchains, though I guess the proposed benefit in the latter case is that there's not so much configuration around Parcel to be maintaining. |
This comment has been minimized.
This comment has been minimized.
Yep, definitely worth highlighting. Parcel itself is an implementation detail as if I wanted to do the same with webpack, it would have required a lot of config. The dependency overhead is a real issue though, If I were to choose I'd actually think we should see if our current usage of webpack could be replaced by parcel :) but I don't mind the opposite. |
aduth
referenced this pull request
Mar 25, 2019
Merged
Testing: Add ESLint restricted syntax for truthy length rendering #14579
mkevins
added a commit
to mkevins/gutenberg
that referenced
this pull request
Mar 26, 2019
This comment has been minimized.
This comment has been minimized.
Yes, for the playground. It was way much simpler to proceed this way as
The downside is that Parcel comes with its own set of development dependencies and does some magic with Babel config which caused some issues as we had to override the default config we use. |
youknowriad
added this to the 5.4 (Gutenberg) milestone
Mar 29, 2019
Apr 1, 2019
This was referenced
aduth
reviewed
Apr 25, 2019
@@ -12,3 +12,6 @@ phpcs.xml | |||
yarn.lock | |||
docker-compose.override.yml | |||
/wordpress | |||
|
|||
playground/dist | |||
.cache |
This comment has been minimized.
This comment has been minimized.
aduth
Apr 25, 2019
Member
Does this need to be in .eslintignore
? Ignored tests (#14997) ? I worry its presence could add some significant folder-scan overhead for some common tasks.
This comment has been minimized.
This comment has been minimized.
youknowriad
Apr 25, 2019
Author
Contributor
Is there a config for .eslintignore to automatically include .gitignore?
This comment has been minimized.
This comment has been minimized.
aduth
Apr 25, 2019
Member
Is there a config for .eslintignore to automatically include .gitignore?
Not that I'm aware of, though I do sympathize with the goal to try to consolidate how we consider these "ignored" files.
Related: eslint/eslint#5848
youknowriad commentedMar 18, 2019
•
edited
This PR adds a local built-in Gutenberg playground:
Testing instructions