Skip to content

Conversation

@kevinmarrec
Copy link
Contributor

@kevinmarrec kevinmarrec commented Oct 6, 2022

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

Fixes #46

Using build.transpile for websocket package makes any app using this module broken on Cloudflare Workers (unpublishable).

Therefore, we just keep the viteConfig.optimizeDeps so it correctly works in development, and doing it as well for builds has 0 bundle cost, so this change should be more than ideal to fix the issue !

Update: See #84 (comment)

@larbish
Copy link
Collaborator

larbish commented Oct 7, 2022

Hey :) Thanks for the PR. However, I used to optimise websocket for both env but we faced this issue. That's the reason why I have updated it in v0.1.23 (there are two commits to check).

Nevertheless, it could also have been fixed in https://github.com/unjs/unenv. Can you verify we're not facing this issue again ?

@kevinmarrec
Copy link
Contributor Author

@larbish This fixes indeed does not work with generate, gonna find another way..

@kevinmarrec
Copy link
Contributor Author

kevinmarrec commented Oct 7, 2022

Updated the PR.

Finally, I only implemented a check to not transpile websocket when building using NITRO_PRESET=cloudflare.
If required, we'll add more nitro presets in the array, but the issue should only happen on Workers so this is a good first step.

Tested and worked against :

  • nuxi dev (Dev)
  • nuxi build && nuxi start (Build)
  • nuxi generate && nuxi start (Generate)
  • NITRO_PRESET=cloudflare nuxi build && wrangler publish (Publish to Cloudflare Workers)

This PR makes the latter finally working 🚀

@larbish larbish merged commit 94275e0 into nuxt-modules:main Oct 7, 2022
@kevinmarrec kevinmarrec deleted the fix-cloudflare-workers branch October 7, 2022 09:59
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.

I can't publish to Cloudflare Workers

2 participants