primocms / primo

Primo is a visual CMS with a built-in code editor, Svelte blocks, and static site generator.
https://primocms.org
MIT License
1.92k stars 474 forks source link

Issue deploying to Cloudflare pages #308

Closed Lastofthefirst closed 11 months ago

Lastofthefirst commented 11 months ago

I tried to deploy the primo front end to cloudflare pages but the build failed with the error:

22:41:46.438 | Error: Failed to publish your Function. Got error: Your Functions script is over the 1 MiB size limit (workers.api.error.script_too_large)

Here is a gist with the full build logs https://gist.github.com/Lastofthefirst/1e7bc8bf15f9e49aac94f66400291498

I take this to mean that sveltekit's compilation process creates this function. Is there a way to sidestep this or slim it down?

mateomorris commented 11 months ago

I think this is caused by the worker pulling in the svelte compiler, which is 1.5MB. I'll minify it in the next update and see if that fixes the issue.

mateomorris commented 11 months ago

okay @Lastofthefirst could you pull the latest update and give this another try?

Lastofthefirst commented 11 months ago

Here is the error log now:

2023-07-27T21:43:49.840941Z Cloning repository...
2023-07-27T21:43:50.800046Z From https://github.com/Lastofthefirst/primo
2023-07-27T21:43:50.800772Z  * branch            eba1c1010823affa3b52f5fc8e1dc578e6ec8742 -> FETCH_HEAD
2023-07-27T21:43:50.800969Z 
2023-07-27T21:43:50.889558Z HEAD is now at eba1c10 Merge branch 'primocms:master' into master
2023-07-27T21:43:50.890246Z 
2023-07-27T21:43:51.007956Z 
2023-07-27T21:43:51.039277Z Success: Finished cloning repository files
2023-07-27T21:43:51.696954Z Detected the following tools from environment: npm@9.5.1, nodejs@18.16.1
2023-07-27T21:43:51.697761Z Installing project dependencies: npm clean-install --progress=false
2023-07-27T21:43:53.624003Z npm ERR! code ERESOLVE
2023-07-27T21:43:53.627541Z npm ERR! ERESOLVE could not resolve
2023-07-27T21:43:53.627845Z npm ERR! 
2023-07-27T21:43:53.628051Z npm ERR! While resolving: prettier-plugin-svelte@2.9.0
2023-07-27T21:43:53.628228Z npm ERR! Found: svelte@4.1.1
2023-07-27T21:43:53.628389Z npm ERR! node_modules/svelte
2023-07-27T21:43:53.628532Z npm ERR!   dev svelte@"^4.0.0" from the root project
2023-07-27T21:43:53.628674Z npm ERR!   peer svelte@"^4.0.0" from @primocms/builder@0.0.22
2023-07-27T21:43:53.628816Z npm ERR!   node_modules/@primocms/builder
2023-07-27T21:43:53.628943Z npm ERR!     @primocms/builder@"^0.0.22" from the root project
2023-07-27T21:43:53.629086Z npm ERR!   7 more (@sveltejs/kit, @sveltejs/vite-plugin-svelte, ...)
2023-07-27T21:43:53.629216Z npm ERR! 
2023-07-27T21:43:53.629342Z npm ERR! Could not resolve dependency:
2023-07-27T21:43:53.629466Z npm ERR! peer svelte@"^3.2.0" from prettier-plugin-svelte@2.9.0
2023-07-27T21:43:53.62964Z  npm ERR! node_modules/prettier-plugin-svelte
2023-07-27T21:43:53.629801Z npm ERR!   dev prettier-plugin-svelte@"^2.8.1" from the root project
2023-07-27T21:43:53.62993Z  npm ERR! 
2023-07-27T21:43:53.630074Z npm ERR! Conflicting peer dependency: svelte@3.59.2
2023-07-27T21:43:53.630205Z npm ERR! node_modules/svelte
2023-07-27T21:43:53.630329Z npm ERR!   peer svelte@"^3.2.0" from prettier-plugin-svelte@2.9.0
2023-07-27T21:43:53.630453Z npm ERR!   node_modules/prettier-plugin-svelte
2023-07-27T21:43:53.630602Z npm ERR!     dev prettier-plugin-svelte@"^2.8.1" from the root project
2023-07-27T21:43:53.630754Z npm ERR! 
2023-07-27T21:43:53.630885Z npm ERR! Fix the upstream dependency conflict, or retry
2023-07-27T21:43:53.631058Z npm ERR! this command with --force or --legacy-peer-deps
2023-07-27T21:43:53.631192Z npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
2023-07-27T21:43:53.631331Z npm ERR! 
2023-07-27T21:43:53.631485Z npm ERR! 
2023-07-27T21:43:53.631616Z npm ERR! For a full report see:
2023-07-27T21:43:53.631772Z npm ERR! /opt/buildhome/.npm/_logs/2023-07-27T21_43_53_007Z-eresolve-report.txt
2023-07-27T21:43:53.631908Z 
2023-07-27T21:43:53.632051Z npm ERR! A complete log of this run can be found in:
2023-07-27T21:43:53.632206Z npm ERR!     /opt/buildhome/.npm/_logs/2023-07-27T21_43_53_007Z-debug-0.log
2023-07-27T21:43:53.643418Z Error: Exit with error code: 1
2023-07-27T21:43:53.643671Z     at ChildProcess.<anonymous> (/snapshot/dist/run-build.js)
2023-07-27T21:43:53.643871Z     at Object.onceWrapper (node:events:652:26)
2023-07-27T21:43:53.644048Z     at ChildProcess.emit (node:events:537:28)
2023-07-27T21:43:53.644219Z     at ChildProcess._handle.onexit (node:internal/child_process:291:12)
2023-07-27T21:43:53.650989Z Failed: build command exited with code: 1
2023-07-27T21:43:54.557783Z Failed: error occurred while running build command
mateomorris commented 11 months ago

@Lastofthefirst I think I pushed a couple build fixes right after that, are there upstream updates you can pull down into your fork?

Lastofthefirst commented 11 months ago

@mateomorris Yes, there was another update, I grabbed it, but got the original error:

2023-07-28T02:09:32.44643Z  Cloning repository...
...

23-07-28T02:10:52.651388Z     ✔ done
2023-07-28T02:10:52.652404Z ✓ built in 1m 4s
2023-07-28T02:10:52.883955Z Finished
2023-07-28T02:10:52.884585Z Found _worker.js in output directory. Uploading.
2023-07-28T02:10:54.379535Z ✨ Compiled Worker successfully
2023-07-28T02:10:54.507953Z Found _routes.json in output directory. Uploading.
2023-07-28T02:10:54.523702Z Validating asset output directory
2023-07-28T02:10:55.501318Z Deploying your site to Cloudflare's global network...
2023-07-28T02:11:00.08751Z  Parsed 2 valid header rules.
2023-07-28T02:11:01.801449Z Uploading... (43/65)
2023-07-28T02:11:02.452026Z Uploading... (50/65)
2023-07-28T02:11:03.70873Z  Uploading... (57/65)
2023-07-28T02:11:04.208303Z Uploading... (65/65)
2023-07-28T02:11:04.208745Z ✨ Success! Uploaded 22 files (43 already uploaded) (3.09 sec)
2023-07-28T02:11:04.209003Z 
2023-07-28T02:11:04.788727Z ✨ Upload complete!
2023-07-28T02:11:07.292892Z Success: Assets published!
2023-07-28T02:11:10.29019Z  Error: Failed to publish your Function. Got error: Your Functions script is over the 1 MiB size limit (workers.api.error.script_too_large)

(Edit: rofl sorry that was a huge error log =.=)

mateomorris commented 11 months ago

ah shoot just realized rollup gets pulled into that worker too & that brings it above 1MB. I'll have to see if it can be put into a separate worker

vednolacni commented 11 months ago

any update?

mateomorris commented 11 months ago

Got it! Splitting up the worker worked for that issue but then I realized the app file itself was too big. Took some code splitting and removing bloated dependencies but I was able to get it down to less than a third of its original size; been wanting to slim it down for a while anyway. Just deployed on Cloudflare but I haven't tested extensively, so feel free to reopen if something else cloudflare-specific comes up.