-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Build Tooling: Correctly generate PHP files for server-side rendering of blocks on Windows OS #65248
Conversation
… of blocks on Windows OS
tools/webpack/blocks.js
Outdated
const [ , dirname, basename ] = | ||
const [ , dirname, _basename ] = |
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 change was necessary to prevent an eslint error regarding the scope of the basename
variable.
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'd prefer to completely rename one of these basenames, maybe this one should become fileBasename
? The _
prefix often indicates unused or private variables and I think this can be more descriptive.
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.
Certainly. I updated it that way.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: -211 B (-0.01%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
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 looks correct. I've built zips before and after this change on my machine and they seem to include the exact same files. Thanks!
Fixes #65244
What?
This PR correctly generates PHP files for server-side rendering of blocks when running
npm run {start|build}
on a Windows host OS.Why?
This issue was caused by #63311.
After investigating the
tools\webpack\blocks.js
file, which is a custom setting for the Gutenberg project, I found that thefilepath
argument to thefilter
option of theCopyWebpackPlugin
plugin uses forward slashes instead of backslashes even on Windows OS.Example of
filepath
:D:/Desktop/path/to/gutenberg/packages/block-library/src/archives/index.php
On the other hand,
path.sep
is a backslash on Windows OS, so it does not match the following conditional statement.How?
It is probably better to check the file name accurately with
path.basename
rather than checking the file name withendsWith
method.Just to be sure, I ran
npm run build
on WSL2 (Ubuntu OS) and Windows host OS and got the diff of the entirebuild/
directory, and the file configuration of each build directory is completely consistent in this PR.Testing Instructions
npm run {start|build}
, make sure that the PHP file is generated inbuild/block-library/blocks/
. as before.