Skip to content

Add a script to build blocks using Calypso SDK - #9944

Closed
simison wants to merge 3 commits into
masterfrom
add/block-builder-script
Closed

simison wants to merge 3 commits into
masterfrom
add/block-builder-script

Conversation

@simison

@simison simison commented Jul 24, 2018 •

Copy link
Copy Markdown
Member

⚠️ 🛠 Work In Progress — Do not merge


Adds a script to build all the blocks from Calypso, using Calypso as a dependency:

yarn build-blocks

Does this approach make sense regarding developer-experience?

Currently, blocks live inside Calypso codebase but as the block builder evolves, blocks could live also inside Jetpack or in a separate repository.

This doesn't include yet anything regarding PHP, styles or i18n stuff yet since we don't have any of that in the builder neither.

This PR is just to add the first iteration of the entry point in Jetpack for all the work that is Calypso SDK block builder. We will keep iterating on developer experience further down the road.

Testing

Requires linking Calypso to Jetpack manually (temporarily until it can be pulled in as a dependency).

Inside Calypso folder:

npm link

Inside Jetpack folder:

npm link wp-calypso

Finally, you can run:

yarn build-blocks

You should end up with _inc/build/blocks/hello-dolly/blocks-hello-dolly.js -file in Jetpack.

Requires linking Calypso to Jetpack manually and Automattic/wp-calypso#26273
@simison simison added [Status] In Progress [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack DO NOT MERGE don't merge it! labels Jul 24, 2018
@simison
simison requested review from oskosk and tyxla July 24, 2018 08:45
@simison
simison requested a review from a team as a code owner July 24, 2018 08:45
@jetpackbot

This comment has been minimized.

@tyxla tyxla left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is testing great! Also code looks good. Great work! 💯

I've left some comments and suggestions, nothing critical.

My $0.02: this is a wonderful example of a good developer experience from the plugin point of view. I'd like to see how that evolves as we bring pieces together for building the blocks in Calypso.

Comment thread bin/build-blocks.js
blocks.forEach( block => {
console.log( `Building ${ block }` );
// Relative to wp-calypso
const inputFile = path.join( 'client/gutenberg/extensions/', block );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good if we can change this directory when running the command.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'd love to get rid of "client/gutenberg/extensions/" bit here because Jetpack shouldn't need to care about Calypso's internal structure.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe at least set it as a const at the top so it can be easily switched out later?

Comment thread package.json
"install-if-deps-outdated": "yarn check 2> /dev/null || yarn install --check-files",
"distclean": "rm -rf node_modules && yarn cache clean",
"build": "yarn install-if-deps-outdated && yarn build-client",
"build-blocks": "node ./bin/build-blocks.js",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about a single build-block command that would allow us to build a single block instead of all of them? For example we would want to build the one we're changing only, and not all of them every time.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this is a good optimization for later? what's the benefit? a slightly shorter built time?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, that's definitely good for later for when we build a ton of blocks this way, and it would make a difference.

Comment thread bin/build-blocks.js
// 'jetpack/tiled-gallery/tiled-gallery.jsx',
];

const outputDir = path.resolve( '_inc/build/blocks' );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This directory makes sense to me, but I'd like to confirm with someone from @Automattic/jetpack-crew that this is the right directory we'll want to place the externally built blocks.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True; it probably isn't the right place. We'll need to wait for convos with @dereksmart and @oskosk

@simison simison changed the title Add a script to build blocks Add a script to build blocks using Calypso SDK Jul 25, 2018
@simison

simison commented Jul 26, 2018

Copy link
Copy Markdown
Member Author

This will need some modifications because of Automattic/wp-calypso#26320

@brbrr brbrr added the Enhancement Changes to an existing feature — removing, adding, or changing parts of it label Aug 3, 2018
@jeherve jeherve added this to the 6.7 milestone Oct 9, 2018
@sirreal

sirreal commented Oct 11, 2018

Copy link
Copy Markdown
Member

Shall we close this as superseded by #10279?

@jeherve

jeherve commented Oct 11, 2018

Copy link
Copy Markdown
Member

Closing as per discussion in Slack. We are now going another way, with #10279

@jeherve jeherve closed this Oct 11, 2018
@jeherve
jeherve deleted the add/block-builder-script branch October 11, 2018 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DO NOT MERGE don't merge it! Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack Touches WP.com Files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants