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: externalize cloudflare:sockets imports #409

Merged
merged 6 commits into from
Oct 27, 2024

Conversation

alexanderniebuhr
Copy link
Member

@alexanderniebuhr alexanderniebuhr commented Sep 30, 2024

UPDATE: I changed the approach to use a vite plugin to externalize the imports based on resolveId, this should be more flexible and work for all modes.

Changes

Testing

  • existing tests

Docs

  • bugfix not needed

Copy link

changeset-bot bot commented Sep 30, 2024

🦋 Changeset detected

Latest commit: 2da4e18

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

This PR includes changesets to release 10 packages
Name Type
@astrojs/cloudflare Patch
@test/astro-cloudflare-astro-dev-platform Patch
@test/astro-cloudflare-astro-env Patch
@test/astro-cloudflare-compile-image-service Patch
@test/astro-cloudflare-external-image-service Patch
@test/astro-cloudflare-wasm Patch
@test/astro-cloudflare-no-output Patch
@test/astro-cloudflare-routes-json Patch
@test/astro-cloudflare-with-solid-js Patch
@test/astro-cloudflare-wrangler-preview-platform 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

'@astrojs/cloudflare': minor
---

Improves default config to support `cloudflare:sockets` imports
Copy link
Member

@ematipico ematipico Oct 1, 2024

Choose a reason for hiding this comment

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

nit: since it's a minor, maybe the changeset should contain more information e.g. what it means for the users and they can do now

Copy link
Member

Choose a reason for hiding this comment

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

Is it even a breaking change? I don't see how this would break any case that was working. It might change the error in some scenarios, but not add new ones.

Copy link

@irvinebroque irvinebroque left a comment

Choose a reason for hiding this comment

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

Added one more that should be externalized, thanks for this @alexanderniebuhr !!!

packages/cloudflare/src/index.ts Outdated Show resolved Hide resolved
packages/cloudflare/src/index.ts Outdated Show resolved Hide resolved
@alexanderniebuhr
Copy link
Member Author

I changed the approach to use a vite plugin to externalize the imports based on resolveId, this should be more flexible and work for all modes, which follows this suggestion

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

The code looks good to me. I think we should craft a proper changeset, and maybe consider updating the docs, since now all cloudflare: specifiers are treated differently.

And maybe @Fryuni is onto something, because we actually change the behaviour of the build under hood. If want to avoid a breaking change, maybe this new behaviour should be opt-in, with a new config, and then make a major where it will be the default one.

@alexanderniebuhr
Copy link
Member Author

alexanderniebuhr commented Oct 21, 2024

I still don't think this is a breaking change or that we need to update the docs, because without this change, user had to add the code manually before, in there astro.config.js.

cloudflare: imports can't be bundled, since those are runtime features AFAIK. So before if the user did not externalize those imports manually, they ended up with an error during astro build 🤔

But happy to discuss this further.

@ematipico
Copy link
Member

I see. Sounds like more a bugfix then.

Copy link
Member

@Fryuni Fryuni left a comment

Choose a reason for hiding this comment

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

Code seems great. Changeset needs update.

I agree with Ema that it's a bugfix.

@alexanderniebuhr alexanderniebuhr merged commit d63bed8 into main Oct 27, 2024
8 checks passed
@alexanderniebuhr alexanderniebuhr deleted the cloudflare-sockets branch October 27, 2024 07:39
@github-actions github-actions bot mentioned this pull request Oct 27, 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.

Consider treating cloudflare:sockets as external in rollupOptions set in @astrojs/cloudflare
5 participants