Skip to content
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

JS/CSS not compiling with multiple blocks in create-block when created in a symlinked directory. #45792

Closed
shoelaced opened this issue Nov 16, 2022 · 3 comments
Labels
[Package] Scripts /packages/scripts [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed [Type] Bug An existing feature does not function as intended

Comments

@shoelaced
Copy link

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 I cd into the plugin through the symlink path, then they don't. This appears to be because when I'm in the symlink directory, the filepath variable contains the symlink path, whereas the srcDirectory variable still contains the original directory (symlink target) path, thus the if 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:

  1. Create a directory plugins somewhere, and create a new @wordpress/create-block plugin inside it.
  2. Create a symlink of the plugins directory in another location called plugins2.
    On Windows: mklink /d "C:\path\to\plugins2" "C:\path\to\plugins"
  3. Move everything in the plugin's src folder into a sub-folder: src\block-a, and rename the block name to block-a appropriately in blocks.json and in all the other block files.
  4. In your terminal, cd into the plugin directory through the symlink's path: cd C:\path\to\plugins2\plugin
  5. Run npm run build.

You should then see this notice in the terminal:

Skipping "./index.js" listed in "C:/path/to/plugins2/plugin/src/block-a/block.json". File is located outside of the "src" directory.
No entry file discovered in the "src" directory.

And, in the build/block-a folder, there will only be the blocks.json file.

If, however, you cd into the original plugins directory and attempt the build again, it will succeed.

Screenshots, screen recording, code snippet

No response

Environment info

  • Windows 11
  • VSCode

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

@iamleese
Copy link

What does your entire src file structure look like?

@t-hamano
Copy link
Contributor

@shoelaced
Thanks for the report.
I think this issue is exactly the same as #44937, so let's close this issue and focus the discussion on #44937.

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Package] Scripts /packages/scripts [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed labels Nov 16, 2022
@shoelaced
Copy link
Author

Ah, sorry somehow I didn't find that report before. Cheers, hope it gets resolved. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Scripts /packages/scripts [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

3 participants