Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/famous-colts-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: svelte should find other package on yarn pnp ([#12563](https://github.com/sveltejs/kit/pull/12563))
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 || (major === 20 && minor >= 6) || (major === 18 && minor >= 19)) {
// @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'));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want remove this, but i don't know side effect

})();
// @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