-
Notifications
You must be signed in to change notification settings - Fork 43
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
Blocks: Make webpack.config.extensions.js extend calypso-build's #3
Conversation
Does newspack need concept of "beta blocks" and outputting Could we simplify to: /**
* External dependencies
*/
const fs = require( 'fs' );
const getBaseWebpackConfig = require( '@automattic/calypso-build/webpack.config.js' );
const path = require( 'path' );
/**
* Internal variables
*/
const editorSetup = path.join( __dirname, 'src', 'setup', 'editor' );
const viewSetup = path.join( __dirname, 'src', 'setup', 'view' );
function blockScripts( type, inputDir, blocks ) {
return blocks
.map( block => path.join( inputDir, 'blocks', block, `${ type }.js` ) )
.filter( fs.existsSync );
}
const blocks = require( path.join( __dirname, 'src', 'setup', 'blocks.json' ) );
// Helps split up each block into its own folder view script
const viewBlocksScripts = blocks.reduce( ( viewBlocks, block ) => {
const viewScriptPath = path.join( __dirname, 'src', 'blocks', block, 'view.js' );
if ( fs.existsSync( viewScriptPath ) ) {
viewBlocks[ block + '/view' ] = [ viewSetup, ...[ viewScriptPath ] ];
}
return viewBlocks;
}, {} );
// Combines all the different blocks into one editor.js script
const editorScript = [
editorSetup,
...blockScripts( 'editor', path.join( __dirname, 'src' ), blocks ),
];
const webpackConfig = getBaseWebpackConfig( null, {
entry: {
editor: editorScript,
...viewBlocksScripts,
},
'output-path': path.join( __dirname, 'dist' ),
} );
module.exports = webpackConfig; Alternatively ditch completely any |
I don't think Newspack needs beta blocks, at least not for the foreseeable future. If I understand correctly, Jetpack/WPCOM beta blocks were conceived primarily to allow for testing on WPCOM before a block is ready for release. If true, the concept wouldn't really be necessary since Newspack is purely a plugin. Does this thinking sound correct or am I forgetting some aspect of the rationale behind beta blocks? |
I like this approach. I tried removing
How's this look? |
What do these recent changes mean for Babel? Can we remove
|
Yeah, I think the need for beta blocks. came from dealing with several environments. Folks should be able to merge small PRs early on and continue working on blocks even before they're published to production. I'd imagine in a plugin like this you'd control release by simply versioning the release, while Calypso and wpcom are continuously delivered. |
What's the best strategy for controlling the |
const path = require( 'path' ); | ||
|
||
/** | ||
* Internal dependencies |
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.
@ockham I'm curious why you put the Internal dependencies
block back in even though the only line is commented out? Was this just a copy/paste from Jetpack or was it meant to be a reminder that the workerCount
line will be significant in this repo too?
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.
@ockham I'm curious why you put the
Internal dependencies
block back in even though the only line is commented out? Was this just a copy/paste from Jetpack or was it meant to be a reminder that theworkerCount
line will be significant in this repo too?
Both 🙂 It's in JP too, and the reason in both cases is that I haven't entirely thought through what to do with it. 😬
Without looking at code; does Adding |
Confirmed. |
No, that pretty much sums it up. I agree that removing the beta blocks makes sense for Newspack 👍 |
Looks good 👍 You might not even need that though. The original motivation for iterating over individual blocks was that we wanted to be able to build individual JS bundles (i.e. entrypoints) for each block's For a single-entrypoint bundle, with no concept of beta blocks, Newspack might not need a |
We can at least heavily simplify |
I'm going to save this for a future PR. |
Per discussion with @ockham, going to address Babel config reduction in a future PR. |
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 great. Thank you @ockham for making this possible!
🎉 This PR is included in version 1.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
WIP.
Inspired by Automattic/jetpack#11802. The idea is to encapsulate complexity in
@automattic/calypso-build
and provide a nice enough interface to consumers.