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

@builder.io/sdk-vue runtime is not honored on Vercel #2111

Closed
20x-dz opened this issue Jan 23, 2024 · 6 comments
Closed

@builder.io/sdk-vue runtime is not honored on Vercel #2111

20x-dz opened this issue Jan 23, 2024 · 6 comments

Comments

@20x-dz
Copy link

20x-dz commented Jan 23, 2024

Environment

Nuxt 3.9.3, Vercel default (nodejs 18), nitropack 2.8.1

Reproduction

When building a minimal Nuxt3 project integrating the builder.io toolkit and deploying it on vercel, the output does not use the vercel-light edge export defined in the package's package.json.

See https://github.com/20x-dz/builder-vue-test for a simple project and https://builder-vue-test.vercel.app/ for the current output.

Describe the bug

After deploying to vercel, the package export for the edge-light environment is not used, but the default node environment is used instead, resulting in the following error: Cannot find module 'isolated-vm' Require stack: - /var/task/node_modules/@builder.io/sdk-vue/lib/node/index.29fcda33.js

As mentioned in BuilderIO/builder#2933 (comment) adjusting the import to use the edge export directly fixes this issue (import { Content, fetchOneEntry, isPreviewing } from "@builder.io/sdk-vue/edge";), but then breaks when developing locally.

Additional context

No response

Logs

No response

@20x-dz 20x-dz changed the title @builder.io/sdk-vue runtime is not honored on vercel @builder.io/sdk-vue runtime is not honored on Vercel Jan 23, 2024
@pi0
Copy link
Member

pi0 commented Jan 23, 2024

Hi. Please note that edge-light condition should be used for vercel_edge preset (not lambda which is default). For this, you might need to set NITRO_PRESET=vercel_edge environment variable or locally use build --preset vercel_edge

@20x-dz
Copy link
Author

20x-dz commented Jan 23, 2024

Thx @pi0 . I am using NITRO_PRESET=vercel because NITRO_PRESET=vercel_edge fails building with sentry (getsentry/profiling-node#170). I just quoted edge-light because it was mentioned in the linked builder io PR.

@pi0
Copy link
Member

pi0 commented Jan 23, 2024

These are two completely different runtimes:

  • vercel: Uses AWS Lambda and Node.js (resolving libraries with node condition)
  • vercel_edge: Uses a Worker to run your code in edge (resolving libraries with edge-light

One deployment/project can be against one of these. From your requirements, it seems you both need Node.js for sentry profiling and builder.io with edge-light conditions.

Also I notice that your reproduction the SDK is imported pages/[...app].vue (it is bundled by Vite and Nuxt not Nitro directly).

Have you tried to update your import to @builder.io/sdk-vue/edge?

@pi0 pi0 added the nuxt label Jan 23, 2024
@20x-dz
Copy link
Author

20x-dz commented Jan 24, 2024

Have you tried to update your import to @builder.io/sdk-vue/edge?

Yes, that works fine. On Vercel. Locally (running npm run dev, so node runtime I would guess?) this does not work.

From what I understand, using the import @builder.io/sdk-vue should resolve to the correct runtime automagically depending on the context given the exports defined in package.json, shouldn't it?

@pi0
Copy link
Member

pi0 commented Jan 24, 2024

Yes it should work and if i were a library author, I would use main subpath export for universal builds (not a Node.js dependent variant).

Thanka for confirming that @builder.io/sdk-vue/edge works fine.

I think there is nothing much for us to do (vercel is a node preset and they never request any different condition that I am aware of. if there is one, both Nitro and libraries can use them. Best luck ;)

@pi0 pi0 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 24, 2024
@20x-dz
Copy link
Author

20x-dz commented Jan 24, 2024

Thank you very much for your swift and detailed reponses. Very much appreciated! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants