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

fix: svelte should find other package on yarn pnp #12563

Closed
wants to merge 4 commits into from

Conversation

sunrabbit123
Copy link

@sunrabbit123 sunrabbit123 commented Aug 9, 2024

fix resolve_peer_dependency function for yarn pnp

description

As you can see from #5353, the problem is bothering yarn pnp users.

This is PR that I hope that the yarn pnp users can enjoy Svelte under certain conditions.

detail

wooorm/import-meta-resolve#10 (comment)

The author of the import-meta-resolve in question is not interested in the yarn pnp issue, will not be, and talked as below.

"Then there would be significant differences between when the actual import.meta.resolve is available and when not. As in, Yarn PnP wouldn’t work on old Node. At that point, just use import.meta.resolve?"

I modified the node version to call import.meta.resolve accordingly.

import meta resolve

https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Operators/import.meta
image


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

Copy link

changeset-bot bot commented Aug 9, 2024

⚠️ No Changeset found

Latest commit: 37824ae

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@sunrabbit123 sunrabbit123 changed the title fix: #5252 fix: #5353 Aug 9, 2024
Signed-off-by: sunrabbit123 <qudwls185@naver.com>
@sunrabbit123 sunrabbit123 changed the title fix: #5353 fix: svelte should find other package on yarn pnp Aug 9, 2024
Signed-off-by: sunrabbit123 <qudwls185@naver.com>
@sunrabbit123 sunrabbit123 marked this pull request as ready for review August 9, 2024 07:02
@Conduitry
Copy link
Member

https://nodejs.org/docs/latest/api/esm.html#importmetaresolvespecifier import.meta.resolve has been around for a while - is there some particular change in 20.6 that you need here?

@sunrabbit123
Copy link
Author

On double checking, it seems to be a problem with the esm and commonjs.
I'll check again and revise it on weekdays and give you a mention.

I'm sorry.

@sunrabbit123
Copy link
Author

sunrabbit123 commented Aug 12, 2024

https://nodejs.org/docs/latest/api/esm.html#importmetaresolvespecifier import.meta.resolve has been around for a while - is there some particular change in 20.6 that you need here?

nodejs/node#49028
20.6.0 started not receiving the corresponding flag value. --experimental-import-meta-resolve(18.19.0 too)
If you used 'import.meta.resolve' before that version, you had to insert that flag at every run, but it doesn't matter after that version.

image

And as a result, we can rely on the loader to import dependencies, even if we don't have that flag. (wooorm/import-meta-resolve#10 (comment))
@Conduitry


Besides this, I think something has changed, but I can't find it.

Signed-off-by: sunrabbit123 <qudwls185@naver.com>
return import.meta.resolve(dependency);
}
// @ts-expect-error the types are wrong
return imr.resolve(dependency, pathToFileURL(process.cwd() + '/dummy.js'));
Copy link
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

@clemyan
Copy link

clemyan commented Aug 15, 2024

The import-meta-resolve dependency was introduced to fix #11433. The fix requires the using parent parameter of import.meta.resolve which is still flagged as of 22.6.0 and which import-meta-resolve ponyfills. This PR undoes that fix.

The more "proper" fix is #12532.

@sunrabbit123
Copy link
Author

The import-meta-resolve dependency was introduced to fix #11433. The fix requires the using parent parameter of import.meta.resolve which is still flagged as of 22.6.0 and which import-meta-resolve ponyfills. This PR undoes that fix.
The more "proper" fix is #12532.

good idea, I look forward to a quick merge

@sunrabbit123 sunrabbit123 deleted the fix/#5353 branch August 19, 2024 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants