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

feat: make wrangler an optional peer dependency #12452

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

benmccann
Copy link
Member

@benmccann benmccann commented Jul 8, 2024

closes #11986

wrangler is heavy and pulls in outdated version of esbuild, deprecated packages, etc. This allows us to avoid installing it

I'm not sure why I need the latter two eslint ignores. Feels like a bug in eslint. I'll have to follow up on that afterwards

Copy link

changeset-bot bot commented Jul 8, 2024

🦋 Changeset detected

Latest commit: 97d0233

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

This PR includes changesets to release 2 packages
Name Type
@sveltejs/adapter-cloudflare-workers Minor
@sveltejs/adapter-cloudflare Minor

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

@@ -1,7 +1,7 @@
lockfileVersion: '9.0'

settings:
autoInstallPeers: true
autoInstallPeers: false
Copy link
Member

Choose a reason for hiding this comment

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

What's this change? Is this what's causing the amp package to no longer have kit as a dependency in the lockfile? Is that a problem?

Copy link
Member

Choose a reason for hiding this comment

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

the default value for that setting was changed from false to true with pnpm 8.0

Copy link
Member Author

Choose a reason for hiding this comment

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

Without setting this wrangler will automatically be installed as a peer

As long as the tests pass, changes to the lockfile shouldn't matter since they won't be shipped to clients

@dominikg
Copy link
Member

is wrangler an optional peer of adapter-cloudflare and not needed for its operation during dev or build?

Or is it needed but we don't have any tests covering its use?

@dominikg
Copy link
Member

what are the wrangler.d.ts files for and if they are copied in from wrangler itself, how do we ensure that they align with the actual version of wrangler peered in by the user?

@eltigerchino
Copy link
Member

is wrangler an optional peer of adapter-cloudflare and not needed for its operation during dev or build?

Or is it needed but we don't have any tests covering its use?

It’s only used during dev at the moment but could be used for builds in the future? (prerendering with remote cloudflare data etc.) However, it’s not optional, which causes stackblitz, alpine, etc. to not work with it #11986

@benmccann
Copy link
Member Author

Hmm, I changed them to optional, but it still seems I need the .npmrc setting in contradiction to the pnpm docs: https://pnpm.io/next/npmrc#auto-install-peers


let wrangler;
try {
wrangler = await import('wrangler');
Copy link
Member

Choose a reason for hiding this comment

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

instead of TLA with swallowing the error, what about lazily importing it when a feature is used that requires it and then logging a message asking the user to install wrangler to support it?

@eltigerchino eltigerchino changed the title chore: avoid installing wrangler feat: make wrangler an optional peer dependency Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make wrangler optional when installing the Cloudflare adapters
4 participants