wp-build: Replace import.meta.resolve with createRequire in getPackageInfo#74171
wp-build: Replace import.meta.resolve with createRequire in getPackageInfo#74171lezama wants to merge 1 commit intoWordPress:trunkfrom
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
cfb88cd to
62f230e
Compare
SirLouen
left a comment
There was a problem hiding this comment.
It's seems that the original code prevented a second resolution. of the same package name with the packageJsonCache. I'm not 100% aware of how require.resolve works behind the scenes and maybe it's not worth, but I wonder if it would be a good idea to also implement some sort of cache something equivalent to this declaration, const packageJsonCache = new Map(); but adapted to this require.resolve version.
SirLouen
left a comment
There was a problem hiding this comment.
Also forgot to mention to fix the linting error here
| const handle = `${ externalConfig.handlePrefix }-${ shortName }`; | ||
|
|
||
| const packageJson = getPackageInfo( packageName ); | ||
| const packageJson = getPackageInfo( packageName, args.resolveDir ); |
There was a problem hiding this comment.
| const packageJson = getPackageInfo( packageName, args.resolveDir ); | |
| const packageJson = getPackageInfo( | |
| packageName, | |
| args.resolveDir | |
| ); |
|
@youknowriad closing this as it got merged in #74194 right? |
Refactors package resolution in getPackageInfo to use Node's createRequire and require.resolve instead of import.meta.resolve and fileURLToPath. This improves compatibility and reliability when resolving package.json files.
What?
Closes
Why?
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast