-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Scripts: Scan block.json
files to detect entry points for the build process
#37661
Conversation
Size Change: 0 B Total Size: 1.13 MB ℹ️ View Unchanged
|
0f751a3
to
87dcefd
Compare
name( module, chunks, cacheGroupKey ) { | ||
return `${ cacheGroupKey }-${ chunks[ 0 ].name }`; | ||
name( _, chunks, cacheGroupKey ) { | ||
const chunkName = chunks[ 0 ].name; |
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 have to account for subfolders now. We missed that before which forces developers to use a flat structure in the build
folder.
@@ -45,6 +45,6 @@ module.exports = { | |||
], | |||
reporters: [ | |||
'default', | |||
'<rootDir>packages/scripts/config/jest-github-actions-reporter.js', | |||
'<rootDir>packages/scripts/config/jest-github-actions-reporter/index.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.
I moved this reporter to a subfolder to ensure we have configs only at the root level of the config
directory.
block.json
files to detect entry points in the build processblock.json
files to detect entry points for the build process
87dcefd
to
e533e67
Compare
I rebased this branch with the latest changes applied to |
Description
Partially addresses #25188.
This PR enhances how entry points for the plugin are discovered. They now can be detected by scanning all script fields in
block.json
files located in thesrc
directory. The fallback entry point remains the samesrc/index.js
(other supported extensions:.jsx
,.ts
, and.tsx
) in case there is noblock.json
file found.This complements #37612 where the
@wordpress/create-block
scaffolding tool can now putblock.json
file in thesrc
directory and copies those files to thebuild
folder when runningwp-scripts build
. The same change can also work separately with extra effort on the plugin's author side.More details in the screencasts:
wp-scripts-build-block-json-1.mov
wp-scripts-build-2.mov
How has this been tested?
Scaffolding
I generated three blocks using templates included in Gutenberg
ES5
ESNext + JSX (the default)
Gutenpride (handbook tutorial)
WordPress environment
I used
wp-env
command integrated with the Gutenberg project.I created an override to the existing config:
File:
.wp-env.override.json
I executed:
Testing plugins
I opened the following URL to test all the installed plugins: http://localhost:8888/wp-admin.
I created a new post and inserter all 3 blocks:
I saved the post and confirmed it renders correctly on the frontend.
Screenshots
Editor:
Frontend:
Types of changes
New feature (non-breaking change which adds functionality).
Checklist:
*.native.js
files for terms that need renaming or removal).