-
Notifications
You must be signed in to change notification settings - Fork 9
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
SSR not working when react integration is added #26
Comments
Hi do you get any errors in console or your Amplify SSR logs? Does that SSR page have |
@alexnguyennz Srry I didn't put logs in the original post, I didn't know where to find them but I finally found them. seems like it doesn't know what react is which is weird since I have it on dependencies I created the app with |
Thanks for that - can you share the repo or create one that I can quickly deploy to Amplify? I'm away at the moment. |
@alexnguyennz sure. This is exactly the repo of the screenshots and this is the deploy. |
@alexnguyennz I just tried adding svelte instead of react and it works. Something is wrong with only react but Im not sure what... |
I'm using pnpm and I have to use this version: 1
frontend:
phases:
preBuild:
commands:
- npm i -g pnpm
- pnpm config set store-dir .pnpm-store
- pnpm i
build:
commands:
- env >> .env
- pnpm run build
- mv .env ./.amplify-hosting/compute/default/.env
artifacts:
baseDirectory: .amplify-hosting
files:
- "**/*"
cache:
paths:
- .pnpm-store/**/* |
More info: With a working svelte integration, I installed the library 21:44:41 [ERROR] Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'swiper' imported from /var/task/chunks/index_Dwwy3-g_.mjs It is weird that in the root page which is static, swiper works properly. But when I go to the SSR page (I didn't put swiper component there), it shows the same as the first post (Just a empty page - doesn't render anything) |
There seems to be an issue now with pnpm deployments with the default build spec example. If I test your project with an npm config (from the repo readme), the SSR page works. For now, if you want to keep using pnpm in dev but use npm in production, you can use a config like:
Copying the node_modules in the pnpm config (similar to npm/Yarn) results in a build output too large issue on my end - will need to do some more testing and try to find a better solution. |
@alexnguyennz we run into same issue now with react and tried your solution with npm but it did not work.
Do you have any other ideas on how to fix this or? It seems like astro team already had some temp folder for build |
Not at the moment - the adapter relies on Astro's Node.js adapter to build for SSR which requires the node modules folder, and Amplify's build size limit is very small compared to other hosting providers. I still need to find out why pnpm has issues now but unfortunately getting support for this from AWS is a bit difficult. There are some things you can do to try and reduce the overall size. |
Much appreciated. I'm currently stuck with the same issue using pnpm. |
@johnajacob Can you try a modified build of:
Moving the node_modules works (previously not required with using pnpm stores but now it seems it is). Note this may result in the build size issue. @tapnicom Have found another issue related to the build problem aws-amplify/amplify-hosting#3863 Let me know if your project is public, I can have a look at seeing if there's anything that can be removed after the build to drop the size down. Otherwise with Amplify's size limit, I really don't know there's much I can do unfortunately. |
Thanks @alexnguyennz. I will create a fresh Astro project with React and a library like Shadcn and, maybe there's something you can spot that I don't. If I remember correctly, last time I tried, I ran into the size issue very quickly. I know there's not much to do on this end, and the size limit should be increased, but it's frustrating. |
@alexnguyennz pnpm build works
when we try to build with npm, we get size limit issue.. We are also not using next but just fork of your blog repo where we tried to add other libraries like react etc. It seems like Vercel is default path for astro projects? |
I wonder if the issue is ouput: hybrid instead of output: server in your astro.build.config |
I encounter a similar issue with an Astro website that integrates a Svelte component. I had to reduce the size because of Amplify limitations by changing from npm to pnpm. I encounter the issue in a specific page that loads a Svelte componente using client:load. This is not working on Amplify. If I change it to client:only="svelte" it work's properly, though i loose all the benefits prerendering my svelte app. This doesn't work: Any suggestions or workarounds to keep prerendering while making client:load work would be greatly appreciated. |
Hello!
I have this static page: (/)
and this SSR page: (/eventos-gratuitos)
they work fine but as soon as I use react js on the project
the SSR page stops working
Im not sure why, it works on local though.
Any ideas on how to solve this? it's driving me crazy
thanks in advance!
The text was updated successfully, but these errors were encountered: