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

bug: ESM not supported in Node.js 14 environment #16

Closed
jthegedus opened this issue Mar 4, 2021 · 3 comments
Closed

bug: ESM not supported in Node.js 14 environment #16

jthegedus opened this issue Mar 4, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@jthegedus
Copy link
Owner

jthegedus commented Mar 4, 2021

Describe the bug

Node.js 14 Google Cloud Function environment does not support ESM yet - GoogleCloudPlatform/functions-framework-nodejs#233

This support is required for Firebase Cloud Functions and if we want to use the same handler.js here for both Cloud Run and Cloud Functions.

Since the Vite SSR app.js file imports @sveltejs/kit/renderer via ESM import, and the @sveltejs/kit lib only outputs ESM, we cannot use SvelteKit in Cloud Functions.

Work arounds

Until this is supported, we have a some options:

  1. run the Vite SSR app.js file through Rollup and bundle/compile/transpile/transform the deps
  2. Deprecate Cloud Function support until this is resolved AND migrate Cloud Run support away from Functions Framework so we can recommend that approach in the meantime

I am likely going to go with 2. for now.

@jthegedus
Copy link
Owner Author

jthegedus commented Mar 14, 2021

Tracking these issues as potential solutions:

Hopefully we can just configure SvelteKit to output CJS for SSR 🤞

@jthegedus
Copy link
Owner Author

jthegedus commented Mar 15, 2021

It seems there was a workaround to this issue which is currently working in 0.5.0 for Cloud Run in 0.4.1 and Cloud Functions in #21

This workaround was lifted from the official adapters like adapter-vercel and co.

@jthegedus jthegedus changed the title ESM not supported in Node.js 14 environment bug: ESM not supported in Node.js 14 environment Mar 22, 2021
@jthegedus
Copy link
Owner Author

#39 uses https://esbuild.github.io/ to compile to commonjs working around this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant