JS/CSS not compiling with multiple blocks in create-block
when created in a symlinked directory.
#45792
Labels
[Status] Duplicate
Used to indicate that a current issue matches an existing one and can be closed
[Tool] WP Scripts
/packages/scripts
[Type] Bug
An existing feature does not function as intended
Description
If using
@wordpress/create-block
to create a new plugin with multiple blocks within a directory that is a symlink, the JS/CSS does not compile if the commands are run from within the symlink, rather than from within the original target directory. After investigating, I found that this was because in@wordpress > scripts > utils > config.js
on line 236, there is this:if ( ! filepath.startsWith( srcDirectory ) ) {
If I
cd
into the plugin through the original directory path, the files compile fine, however if Icd
into the plugin through the symlink path, then they don't. This appears to be because when I'm in the symlink directory, thefilepath
variable contains the symlink path, whereas thesrcDirectory
variable still contains the original directory (symlink target) path, thus theif
comparison fails.Please view the reproduction steps for further clarification.
Step-by-step reproduction instructions
Please note that the symlink command below is specific to Windows:
plugins
somewhere, and create a new@wordpress/create-block
plugin inside it.plugins
directory in another location calledplugins2
.On Windows:
mklink /d "C:\path\to\plugins2" "C:\path\to\plugins"
src
folder into a sub-folder:src\block-a
, and rename the block name toblock-a
appropriately inblocks.json
and in all the other block files.cd
into the plugin directory through the symlink's path:cd C:\path\to\plugins2\plugin
npm run build
.You should then see this notice in the terminal:
And, in the
build/block-a
folder, there will only be theblocks.json
file.If, however, you
cd
into the originalplugins
directory and attempt the build again, it will succeed.Screenshots, screen recording, code snippet
No response
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: