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

Scripts: Correctly resolve entry points when the directory is symlinked #54212

Merged
merged 4 commits into from Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/scripts/CHANGELOG.md
Expand Up @@ -6,6 +6,10 @@

- Added support for `test-playwright` script ([#53108](https://github.com/WordPress/gutenberg/pull/53108)).

### Bug Fix

- Correctly resolve entry points when the directory is symlinked ([#54212](https://github.com/WordPress/gutenberg/pull/54212)).

## 26.12.0 (2023-08-31)

## 26.11.0 (2023-08-16)
Expand Down
5 changes: 4 additions & 1 deletion packages/scripts/config/webpack.config.js
Expand Up @@ -10,6 +10,7 @@ const MiniCSSExtractPlugin = require( 'mini-css-extract-plugin' );
const { basename, dirname, resolve } = require( 'path' );
const ReactRefreshWebpackPlugin = require( '@pmmmwh/react-refresh-webpack-plugin' );
const TerserPlugin = require( 'terser-webpack-plugin' );
const { realpathSync } = require( 'fs' );

/**
* WordPress dependencies
Expand Down Expand Up @@ -302,7 +303,9 @@ const config = {
filter: ( filepath ) => {
return (
process.env.WP_COPY_PHP_FILES_TO_DIST ||
RenderPathsPlugin.renderPaths.includes( filepath )
RenderPathsPlugin.renderPaths.includes(
realpathSync( filepath ).replace( /\\/g, '/' )
)
gziolo marked this conversation as resolved.
Show resolved Hide resolved
);
},
},
Expand Down
11 changes: 4 additions & 7 deletions packages/scripts/utils/config.js
Expand Up @@ -206,17 +206,15 @@ function getWebpackEntryPoints() {

// 2. Checks whether any block metadata files can be detected in the defined source directory.
// It scans all discovered files looking for JavaScript assets and converts them to entry points.
const srcDirectory = fromProjectRoot( getWordPressSrcDirectory() ) + sep;
const blockMetadataFiles = glob(
gziolo marked this conversation as resolved.
Show resolved Hide resolved
`${ getWordPressSrcDirectory() }/**/block.json`,
join( srcDirectory, '**/block.json' ).replace( /\\/g, '/' ),
{
absolute: true,
}
);

if ( blockMetadataFiles.length > 0 ) {
const srcDirectory = fromProjectRoot(
getWordPressSrcDirectory() + sep
);
const entryPoints = blockMetadataFiles.reduce(
( accumulator, blockMetadataFile ) => {
// wrapping in try/catch in case the file is malformed
Expand Down Expand Up @@ -335,15 +333,14 @@ function getRenderPropPaths() {
}

// Checks whether any block metadata files can be detected in the defined source directory.
const srcDirectory = fromProjectRoot( getWordPressSrcDirectory() + sep );
const blockMetadataFiles = glob(
`${ getWordPressSrcDirectory() }/**/block.json`,
join( srcDirectory, '**/block.json' ).replace( /\\/g, '/' ),
{
absolute: true,
}
);

const srcDirectory = fromProjectRoot( getWordPressSrcDirectory() + sep );

const renderPaths = blockMetadataFiles.map( ( blockMetadataFile ) => {
const { render } = JSON.parse( readFileSync( blockMetadataFile ) );
if ( render && render.startsWith( 'file:' ) ) {
Expand Down