Skip to content

Commit

Permalink
fix: yarn pnp shoulde work on node ^20.6.0
Browse files Browse the repository at this point in the history
Signed-off-by: sunrabbit123 <qudwls185@naver.com>
  • Loading branch information
sunrabbit123 committed Aug 9, 2024
1 parent 65931f2 commit 37824ae
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/kit/src/utils/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ import { pathToFileURL } from 'node:url';
* @param {string} dependency
*/
export function resolve_peer_dependency(dependency) {
const [major, minor] = process.versions.node.split('.').map(Number);
try {
const resolved = (() => {
if (major >= 20 && minor >= 6) {
// @ts-expect-error the types are wrong
return import.meta.resolve(dependency);
}
// @ts-expect-error the types are wrong
return imr.resolve(dependency, pathToFileURL(process.cwd() + '/dummy.js'));
})();
// @ts-expect-error the types are wrong
const resolved = imr.resolve(dependency, pathToFileURL(process.cwd() + '/dummy.js'));
return import(resolved);
} catch {
throw new Error(
Expand Down

0 comments on commit 37824ae

Please sign in to comment.