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

use the new resolve.builtins vite config to specify the cloudflare and node builtins #52

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dario-piotrowicz
Copy link
Contributor

@dario-piotrowicz dario-piotrowicz commented Nov 5, 2024

resolves #46

paired with this PR I created in the Vite repo: vitejs/vite#18584

Note

The changes in vitejs/vite#18584 are most likely going to make it into vite around Jannuary (discord message) so this PR will be blocked until then

@dario-piotrowicz dario-piotrowicz force-pushed the dario/bump-vite-to-beta8 branch from c0ac005 to cd6d5fa Compare November 7, 2024 10:18
@dario-piotrowicz dario-piotrowicz force-pushed the dario/cf-builtins branch 3 times, most recently from 400c034 to 0a95cfa Compare November 8, 2024 10:05
@dario-piotrowicz dario-piotrowicz changed the title [JUST AN IDEA - DO NOT MERGE] add exeprimental support for builtins [JUST AN IDEA - DO NOT MERGE] add experimental support for builtins Nov 8, 2024
@dario-piotrowicz dario-piotrowicz force-pushed the dario/bump-vite-to-beta8 branch from 6b077cc to debe5e0 Compare November 8, 2024 15:34
Base automatically changed from dario/bump-vite-to-beta8 to main November 11, 2024 16:28
@@ -6,7 +6,7 @@ packages:
catalog:
'@cloudflare/workers-types': ^4.20241112.0
'typescript': ^5.6.2
'vite': '6.0.0-beta.10'
'vite': '/Users/dario/Repos/my-repos/vite/packages/vite'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Clearly this PR won't be ready to merge until the version of vite with the resolve.builtins config is (hopefully) released

@dario-piotrowicz dario-piotrowicz changed the title [JUST AN IDEA - DO NOT MERGE] add experimental support for builtins use the new resolve.builtins vite config to specify the cloudflare and node builtins Dec 3, 2024
@@ -155,17 +155,12 @@ export function createCloudflareEnvironmentOptions(
input: userConfig.root
? path.resolve(userConfig.root, options.main)
: path.resolve(options.main),
external: [...cloudflareBuiltInModules, ...getNodeCompatExternals()],
external: [...getNodeCompatExternals()],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@petebacondarwin we set these node externals unconditionally even if the worker is not under nodejs_compat, is that ok?

Or should we do it conditionally? (similarly to the addNodeBuiltinsIfNeeded function that I'm adding here)

Copy link
Contributor

Choose a reason for hiding this comment

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

We can do it conditionally if you like. I was being a bit lazy perhaps?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can do it as part of this PR since I'm already adding the other function, so adding this logic should be quite simple 🙂

I just wanted to double check with you first because maybe them being always external for builds was intentional for some reason and/or it doesn't have real/significative downsides

anyways I can do this conditionally here, thanks 🙂

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.

Investigate the fetchModule's cloudflare: catch
2 participants