-
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: Correctly resolve entry points when the directory is symlinked #54212
Conversation
Size Change: +8.4 kB (+1%) Total Size: 1.52 MB
ℹ️ View Unchanged
|
214b7b0
to
ef5acd0
Compare
Flaky tests detected in ef5acd0. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6096482834
|
src
directory is simlinkedThere 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.
The code changes look good. Ideally, I'd like to wait to hear from @pbiron or @mastermind-0xff before landing these changes, so we can confirm it resolves the issue for them as reported in #44937.
Fix confirmed with #44937 (comment). |
the latest version of the PR works great in Windows, whether I run the scripts from the symlink dir or the target dir! |
I believe that this is going to be published to npm around September 20th, because the upcoming Gutenberg plugin release is delayed by a week. They are tied to each other to ensure the stability for WordPress packages unrelated to tooling. |
Fixes #44937
What?
This PR fixes a problem where a file other than
block.json
is not generated when building a block using wp-scripts with a symlinked path.Note: This PR probably fixes a Windows-specific problem; nothing should change on MacOS, but I would appreciate it if you could test it to see if it works correctly.
Why?
In scripts, the path of
block.json
is first searched for byglob()
function.However, since the argument of the
glob()
function is not an absolute path, such assrc/**/block.json
, I expected that the path would not be resolved correctly when theblock.json
path was symlinked.Also, as with #38781, it appears that when using regular expressions in the
glob()
function, they need to be unified with forward slashes.How?
Explicitly use the full path when searching for the path of
block.json
and replace backslashes with forward slashes at the same time. This seems to have resulted in block.json being detected correctly and returning the resolved path at the same time.Testing Instructions
Note: For Windows users, start the command prompt with the administrator role.
plugins
directory in the root of the Gutenberg repository. and move to theplugins
directory.npx @wordpress/create-block test-block --no-wp-scripts
. In theplugins
directory,test-block
directory should be created.test-block/build
directory.render
property to thetest-block/src/block-a/block.json
file:"render": "file:./render.php"
render.php
file to thetest-block/src/block-a/
directory.test-block/src
directory to the subdirectory calledtest-block/src/block-a
.plugins
directory in another location calledplugins-symlink
.mklink /d "C:\path\to\gutenberg/\plugins-symlink" "C:\path\to\gutenberg\plugins"
ln -s /path/to/gutenberg/plugins /path/to/gutenberg/plugins-symlink
cd C:\path\to\plugins-symlink\test-block
cd /path/to/gutenberg/plugins-symlink/test-block
C:\path\to\gutenberg\node_modules\.bin\wp-scripts build
/path/to/node_modules/.bin/wp-scripts build
test-block/build/block-a
directory.