-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
ssrLoadModule
does not load nested dependency
#3609
Comments
@michenly One time I encountered the error "Error when evaluating ..." I fixed that specific error by adding it to the SSR externals name: 'vitext',
config: () => ({
ssr: {
external: [
'prop-types',
'react-helmet-async',
'vitext/document',
'vitext/react',
],
},
... |
While This is by design, as bare imports are assumed to be installed in As I understand it, you have two options here:
|
hi @aleclarson the problem is that my alias need to be decided bases on ssr value (use node polyfill= so unless can you tell me a little more about what is consider a |
The See this example for guidance. |
@aleclarson oh interesting! can there be other keyword other than I am assuming the idea is Vite (and maybe webpack?) will automatically use the node & browser field without me having to alias them myself? |
It depends. To support the |
Thank you so much for the explanation Alec! It had been really helpful! |
Hi @michenly, does this issue still relevant in Vite? From Alec's explanation, it does seem like |
I think the correct solution here is to use |
Describe the bug
Original issue discovered: #3464 (reply in thread)
I have a vite plugin that make use of the
ssr
argument in resolveId hook. The main purpose of the plugin is to replace@shopify/polyfills/fetch
with@shopify/polyfills/fetch.node
when its on the server and@shopify/polyfills/fetch.browser
when it is on the client.This plugins work on the client side, but break when
ssrLoadModule
is use to load the server entry point.Some investigations
I have tired to replace
@shopify/polyfills/fetch
with a random virtual module (ie.virtual:fetch-polyfill
) and that work.Reproduction
Use the branch https://github.com/michenly/app-proving-ground/tree/vite-ssr-dep
Case 1: client side only with a index file
yarn dev
Case 2: ssr using vite middleware and
ssrLoadModule
yarn run ssr
Case 3: same as 2, but using virtual module
@shopify/polyfills/fetch
tovirtual:fetch-polyfill
in both the plugin and the client import in GraphQL.tsxyarn run ssr
System Info
Output of
npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers
:Used package manager: yarn
Before submitting the issue, please make sure you do the following
The text was updated successfully, but these errors were encountered: