diff --git a/packages/scripts/CHANGELOG.md b/packages/scripts/CHANGELOG.md index 1e11550a8f07c3..acf24a423c0aff 100644 --- a/packages/scripts/CHANGELOG.md +++ b/packages/scripts/CHANGELOG.md @@ -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) diff --git a/packages/scripts/config/webpack.config.js b/packages/scripts/config/webpack.config.js index 29a25c9353ff3c..05b37945795a7b 100644 --- a/packages/scripts/config/webpack.config.js +++ b/packages/scripts/config/webpack.config.js @@ -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 @@ -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, '/' ) + ) ); }, }, diff --git a/packages/scripts/utils/config.js b/packages/scripts/utils/config.js index fc00a613d34ac7..e4e42255f95dd3 100644 --- a/packages/scripts/utils/config.js +++ b/packages/scripts/utils/config.js @@ -206,12 +206,10 @@ 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 blockMetadataFiles = glob( - `${ getWordPressSrcDirectory() }/**/block.json`, - { - absolute: true, - } - ); + const blockMetadataFiles = glob( '**/block.json', { + absolute: true, + cwd: fromProjectRoot( getWordPressSrcDirectory() ), + } ); if ( blockMetadataFiles.length > 0 ) { const srcDirectory = fromProjectRoot( @@ -260,9 +258,12 @@ function getWebpackEntryPoints() { // Detects the proper file extension used in the defined source directory. const [ entryFilepath ] = glob( - `${ getWordPressSrcDirectory() }/${ entryName }.[jt]s?(x)`, + `${ entryName }.[jt]s?(x)`, { absolute: true, + cwd: fromProjectRoot( + getWordPressSrcDirectory() + ), } ); @@ -302,13 +303,12 @@ function getWebpackEntryPoints() { } // 3. Checks whether a standard file name can be detected in the defined source directory, - // and converts the discovered file to entry point. - const [ entryFile ] = glob( - `${ getWordPressSrcDirectory() }/index.[jt]s?(x)`, - { - absolute: true, - } - ); + // and converts the discovered file to entry point. + const [ entryFile ] = glob( 'index.[jt]s?(x)', { + absolute: true, + cwd: fromProjectRoot( getWordPressSrcDirectory() ), + } ); + if ( ! entryFile ) { log( chalk.yellow( @@ -335,12 +335,10 @@ function getRenderPropPaths() { } // Checks whether any block metadata files can be detected in the defined source directory. - const blockMetadataFiles = glob( - `${ getWordPressSrcDirectory() }/**/block.json`, - { - absolute: true, - } - ); + const blockMetadataFiles = glob( '**/block.json', { + absolute: true, + cwd: fromProjectRoot( getWordPressSrcDirectory() ), + } ); const srcDirectory = fromProjectRoot( getWordPressSrcDirectory() + sep );