You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am attempting to use the default export of a package I made (https://github.com/knpwrs/envariant) in sveltekit. It works fine during development, but during the build process I see the following output:
TypeError: envariant is not a function
at file:///<path_redacted>session.server.js:4:18
at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:541:24)
at async Promise.all (index 0)
at async prerender (file:///<path_redacted>/node_modules/@sveltejs/kit/src/core/prerender/prerender.js:375:19)
I can see similar issues that others have had (#1526, #704). I was confused about why my app was prerendering given that I'm not using the static adapter, but I figured out that I could disable prerendering for the whole project (I don't need prerendering for my project, only SSR):
This works for the build, but then when I run vite preview and open my browser I'm greeted with a pretty error page:
When I move the call to envariant to be inside the load function rather than a top-level call, I'm greeted with gql is not a function. This is just gql-tag from npm and that function is likewise called inside the loader.
Everything works just fine in development. Is there anything I have to do to get default exports working when running my built app?
I've updated this from "annoyance" to "blocking all usage of SvelteKit" because I originally thought that this would only be a build-time error, but it appears to affect the built app as well.
The text was updated successfully, but these errors were encountered:
Granted, the file extension for require is incorrect. I'm not seeing any immediately obvious generalized way for tsc to output cjs files. It seems like rollup or esbuild bundling would be the way to go rather than transpiling a directory with tsc?
And I'll probably end up switching to urql and using the gql export of @urql/core, rather than gql-tag since they appear to be set up incorrectly as well.
Describe the bug
I am attempting to use the default export of a package I made (https://github.com/knpwrs/envariant) in sveltekit. It works fine during development, but during the build process I see the following output:
I can see similar issues that others have had (#1526, #704). I was confused about why my app was prerendering given that I'm not using the static adapter, but I figured out that I could disable prerendering for the whole project (I don't need prerendering for my project, only SSR):
This works for the build, but then when I run
vite preview
and open my browser I'm greeted with a pretty error page:When I move the call to
envariant
to be inside the load function rather than a top-level call, I'm greeted withgql
is not a function. This is justgql-tag
from npm and that function is likewise called inside the loader.Everything works just fine in development. Is there anything I have to do to get default exports working when running my built app?
Reproduction
This reproduces for the about page: https://stackblitz.com/edit/sveltejs-kit-template-default-ag2fwq?file=src%2Froutes%2Fabout%2F%2Bpage.js&terminal=dev
Logs
No response
System Info
Severity
blocking all usage of SvelteKit
Additional Information
I've updated this from "annoyance" to "blocking all usage of SvelteKit" because I originally thought that this would only be a build-time error, but it appears to affect the built app as well.
The text was updated successfully, but these errors were encountered: