Build: Split config into two parts - blocks and packages#33293
Merged
Conversation
|
Size Change: -221 B (0%) Total Size: 1.07 MB
ℹ️ View Unchanged
|
1951805 to
93de573
Compare
kevin940726
reviewed
Jul 13, 2021
93de573 to
a674d33
Compare
vcanales
approved these changes
Jul 19, 2021
Comment on lines
-142
to
+45
| filename: ( pathData ) => { | ||
| const { chunk } = pathData; | ||
| const { entryModule } = chunk; | ||
| const { rawRequest, rootModule } = entryModule; | ||
|
|
||
| // When processing ESM files, the requested path | ||
| // is defined in `entryModule.rootModule.rawRequest`, instead of | ||
| // being present in `entryModule.rawRequest`. | ||
| // In the context of frontend view files, they would be processed | ||
| // as ESM if they use `import` or `export` within it. | ||
| const request = rootModule?.rawRequest || rawRequest; | ||
|
|
||
| if ( request.includes( '/view.js' ) ) { | ||
| return `./build/block-library/[name]/view.min.js`; | ||
| } | ||
|
|
||
| return `./build/[name]/index.min.js`; | ||
| }, | ||
| filename: './build/[name]/index.min.js', |
Member
There was a problem hiding this comment.
Perfect, love to see this super polished. 🎉
Member
Author
There was a problem hiding this comment.
Yes, when we have two configs some parts become simpler 😄
6 tasks
nylen
pushed a commit
to nylen/wordpress-develop-svn
that referenced
this pull request
Jul 28, 2021
It aligns with the changes proposed added in Gutenberg: WordPress/gutenberg#33293. The idea here is to split the growing webpack config into two parts: blocks and packages. We need to add handling for JavaScript files that are going to be used with blocks on the frontend. They didn't work quite well with the current setup for entry points created for packages. As part of the effort, it adds support for `viewScript` in `block.json` metadata file that is later translated to `$view_script` in `WP_Block_Type` class and exposed as `view_script` from the REST API endpoint for block types. Props youknowriad, desrosj, aristath. Fixes #53690. git-svn-id: https://develop.svn.wordpress.org/trunk@51501 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith
pushed a commit
to markjaquith/WordPress
that referenced
this pull request
Jul 28, 2021
It aligns with the changes proposed added in Gutenberg: WordPress/gutenberg#33293. The idea here is to split the growing webpack config into two parts: blocks and packages. We need to add handling for JavaScript files that are going to be used with blocks on the frontend. They didn't work quite well with the current setup for entry points created for packages. As part of the effort, it adds support for `viewScript` in `block.json` metadata file that is later translated to `$view_script` in `WP_Block_Type` class and exposed as `view_script` from the REST API endpoint for block types. Props youknowriad, desrosj, aristath. Fixes #53690. Built from https://develop.svn.wordpress.org/trunk@51501 git-svn-id: http://core.svn.wordpress.org/trunk@51112 1a063a9b-81f0-0310-95a4-ce76da25c4cd
gMagicScott
pushed a commit
to gMagicScott/core.wordpress-mirror
that referenced
this pull request
Jul 28, 2021
It aligns with the changes proposed added in Gutenberg: WordPress/gutenberg#33293. The idea here is to split the growing webpack config into two parts: blocks and packages. We need to add handling for JavaScript files that are going to be used with blocks on the frontend. They didn't work quite well with the current setup for entry points created for packages. As part of the effort, it adds support for `viewScript` in `block.json` metadata file that is later translated to `$view_script` in `WP_Block_Type` class and exposed as `view_script` from the REST API endpoint for block types. Props youknowriad, desrosj, aristath. Fixes #53690. Built from https://develop.svn.wordpress.org/trunk@51501 git-svn-id: https://core.svn.wordpress.org/trunk@51112 1a063a9b-81f0-0310-95a4-ce76da25c4cd
desrosj-bot
pushed a commit
to desrosj-bot/wordpress-develop
that referenced
this pull request
Mar 17, 2025
It aligns with the changes proposed added in Gutenberg: WordPress/gutenberg#33293. The idea here is to split the growing webpack config into two parts: blocks and packages. We need to add handling for JavaScript files that are going to be used with blocks on the frontend. They didn't work quite well with the current setup for entry points created for packages. As part of the effort, it adds support for `viewScript` in `block.json` metadata file that is later translated to `$view_script` in `WP_Block_Type` class and exposed as `view_script` from the REST API endpoint for block types. Props youknowriad, desrosj, aristath. Fixes #53690. git-svn-id: https://develop.svn.wordpress.org/trunk@51501 602fd350-edb4-49c9-b593-d223f7449a82
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up for #33281.
This PR proposes to split webpack config into two subconfigs:
It's similar to what's proposed in WordPress core in WordPress/wordpress-develop#1412. The main benefit is that we can have better control over the output generated for JavaScript files. In particular, for the block-related files, we shouldn't enforce
wpglobal to be used. It also slightly decreases the size of files:How has this been tested?
npm run devandnpm run buildshould work as before.Types of changes
Refactoring
Checklist:
*.native.jsfiles for terms that need renaming or removal).