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

chore: use peer dependencies rather than dev dependencies #11433

Merged
merged 3 commits into from
Jan 8, 2024

Conversation

Rich-Harris
Copy link
Member

Right now it's rather difficult to use Svelte 5 alongside a linked @sveltejs/kit, because Kit imports vite and @sveltejs/vite-plugin-svelte relative to itself, even though these are peer dependencies.

This means that components will be compiled by Svelte 4 (as that's what the @sveltejs/vite-plugin-svelte inside the linked @sveltejs/kit depends on), but then try to use the Svelte 5 runtime.

This is already a nuisance but it will become much more of one as Svelte 5 gets closer to release and we're trying to make sure everything works in both versions.

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:.

Copy link

changeset-bot bot commented Dec 21, 2023

🦋 Changeset detected

Latest commit: 39e4fe5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

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

@maximdeclercq
Copy link

maximdeclercq commented Jan 9, 2024

This PR makes use of import-meta-resolve, which is incompatible with Yarn PnP, resulting in the following error:

error when starting dev server:
Error: Cannot find package '@sveltejs/vite-plugin-svelte' imported from /work/my-app/dummy.js
    at __node_internal_ (file:///home/mdc/.yarn/berry/cache/import-meta-resolve-npm-4.0.0-13a6ef4fd3-10c0.zip/node_modules/import-meta-resolve/lib/errors.js:431:11)
    at new NodeError (file:///home/mdc/.yarn/berry/cache/import-meta-resolve-npm-4.0.0-13a6ef4fd3-10c0.zip/node_modules/import-meta-resolve/lib/errors.js:374:5)
    at packageResolve (file:///home/mdc/.yarn/berry/cache/import-meta-resolve-npm-4.0.0-13a6ef4fd3-10c0.zip/node_modules/import-meta-resolve/lib/resolve.js:1038:9)
    at moduleResolve (file:///home/mdc/.yarn/berry/cache/import-meta-resolve-npm-4.0.0-13a6ef4fd3-10c0.zip/node_modules/import-meta-resolve/lib/resolve.js:1101:20)
    at defaultResolve (file:///home/mdc/.yarn/berry/cache/import-meta-resolve-npm-4.0.0-13a6ef4fd3-10c0.zip/node_modules/import-meta-resolve/lib/resolve.js:1266:15)
    at Module.resolve (file:///home/mdc/.yarn/berry/cache/import-meta-resolve-npm-4.0.0-13a6ef4fd3-10c0.zip/node_modules/import-meta-resolve/index.js:32:12)
    at resolve_peer_dependency (file:///work/my-app/.yarn/unplugged/@sveltejs-kit-virtual-ff81c722c8/node_modules/@sveltejs/kit/src/exports/vite/index.js:132:29)
    at sveltekit (file:///work/my-app/.yarn/unplugged/@sveltejs-kit-virtual-ff81c722c8/node_modules/@sveltejs/kit/src/exports/vite/index.js:167:27)
    at async Promise.all (index 0)
    at async asyncFlatten (file:///work/my-app/.yarn/__virtual__/vite-virtual-ccd3afe941/4/.yarn/berry/cache/vite-npm-5.0.11-d5457a8b86-10c0.zip/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:12894:16)
    at async resolveConfig (file:///work/my-app/.yarn/__virtual__/vite-virtual-ccd3afe941/4/.yarn/berry/cache/vite-npm-5.0.11-d5457a8b86-10c0.zip/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:67863:29)
    at async _createServer (file:///work/my-app/.yarn/__virtual__/vite-virtual-ccd3afe941/4/.yarn/berry/cache/vite-npm-5.0.11-d5457a8b86-10c0.zip/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:60327:20)
    at async CAC.<anonymous> (file:///work/my-app/.yarn/__virtual__/vite-virtual-ccd3afe941/4/.yarn/berry/cache/vite-npm-5.0.11-d5457a8b86-10c0.zip/node_modules/vite/dist/node/cli.js:764:24)

@Rich-Harris
Copy link
Member Author

Yarn PnP is broken, and we do not support it. Use npm or pnpm instead.

@maximdeclercq
Copy link

maximdeclercq commented Jan 10, 2024

Yarn PnP with Yarn 4 works on SvelteKit 2.0.7, but not on SvelteKit 2.0.8.
I have made an issue here #11578.

@clemyan
Copy link

clemyan commented Aug 1, 2024

You can restore compatibility if you fallback to just import-ing if cwd-relative import fails. Given that this was the original behavior before this change and this change is aimed at maintainers/contributors to SvelteKit I don't think that's an unreasonable ask.

EDIT: I don't use Svelte in my day-to-day so I don't know if this is feasible/common, but if there are wrapper packages around SvelteKit, looks like this change would break the setup of a developer linking to that wrapper.

And, FWIW, you wouldn't need this change at all if you were using PnP -- it can correctly resolve peer dependencies across portals (Yarn's equivalent to npm link)

arcanis pushed a commit to yarnpkg/berry that referenced this pull request Oct 15, 2024
## What's the problem this PR addresses?

The SvelteKit E2E test has been failing

## How did you fix it?

- `create-svelte` discontinued the `next` dist-tag, use `latest` instead
- I don't know how it was but `yes` cannot defeat `create-svelte`
interactivity now, so I just use its node API instead
- Also added a TypeScript test

The test should still be failing due to
sveltejs/kit#11433 (comment), but
at least it is an actual failure of the E2E test, not of our setup.
:shrug:

Closes #6345

## Checklist

<!--- Don't worry if you miss something, chores are automatically
tested. -->
<!--- This checklist exists to help you remember doing the chores when
you submit a PR. -->
<!--- Put an `x` in all the boxes that apply. -->
- [x] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).

<!-- See
https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released
for more details. -->
<!-- Check with `yarn version check` and fix with `yarn version check
-i` -->
- [x] I have set the packages that need to be released for my changes to
be effective.

<!-- The "Testing chores" workflow validates that your PR follows our
guidelines. -->
<!-- If it doesn't pass, click on it to see details as to what your PR
might be missing. -->
- [x] I will check that all automated PR checks pass before the PR gets
reviewed.

---------

Co-authored-by: Kristoffer K. <[email protected]>
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.

4 participants