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

Prerendered load function included in .svelte-kit/output/server #9463

Closed
jhwz opened this issue Mar 20, 2023 · 0 comments · Fixed by #9471
Closed

Prerendered load function included in .svelte-kit/output/server #9463

jhwz opened this issue Mar 20, 2023 · 0 comments · Fixed by #9471
Labels
bug Something isn't working

Comments

@jhwz
Copy link

jhwz commented Mar 20, 2023

Describe the bug

If you have a prerendered load function file, such as +page.server.ts the file is still included in .svelte-kit/output/server leading to errors when trying to adapt the output for another environment (in my case cloudflare pages).

This wasn't the case in version 1.4.0, the issue seemed to be introduced after that.

Reproduction

git clone https://github.com/jhwz/sveltekit-retains-prerender-assets
cd sveltekit-retains-prerender-assets
npm i
npm run build

Logs

npm run build

> sveltekit-retains-prerender-assets@0.0.1 build
> vite build


vite v4.2.1 building SSR bundle for production...
✓ 51 modules transformed.
11:52:53 am [vite-plugin-svelte] ssr compile done.
package                                 files     time    avg
sveltekit-retains-prerender-assets          5   36.6ms  7.3ms

vite v4.2.1 building for production...
✓ 42 modules transformed.
11:52:54 am [vite-plugin-svelte] dom compile done.
package                                 files     time     avg
sveltekit-retains-prerender-assets          3   32.2ms  10.7ms
@sveltejs/kit                               2   13.7ms   6.8ms
.svelte-kit/output/client/_app/version.json                                   0.03 kB
.svelte-kit/output/client/vite-manifest.json                                  3.19 kB
.svelte-kit/output/client/_app/immutable/chunks/2.b8de9f3d.js                 0.08 kB │ gzip: 0.10 kB
.svelte-kit/output/client/_app/immutable/chunks/1.0b92327f.js                 0.08 kB │ gzip: 0.10 kB
.svelte-kit/output/client/_app/immutable/chunks/0.982a38f9.js                 0.09 kB │ gzip: 0.10 kB
.svelte-kit/output/client/_app/immutable/chunks/3.a583bede.js                 0.09 kB │ gzip: 0.10 kB
.svelte-kit/output/client/_app/immutable/entry/test-page.svelte.d7818323.js   0.43 kB │ gzip: 0.31 kB
.svelte-kit/output/client/_app/immutable/entry/_page.svelte.3e0ed68a.js       0.44 kB │ gzip: 0.32 kB
.svelte-kit/output/client/_app/immutable/entry/layout.svelte.b0368388.js      0.54 kB │ gzip: 0.36 kB
.svelte-kit/output/client/_app/immutable/entry/error.svelte.d45f1c66.js       0.98 kB │ gzip: 0.57 kB
.svelte-kit/output/client/_app/immutable/chunks/singletons.0f64ce76.js        2.81 kB │ gzip: 1.44 kB
.svelte-kit/output/client/_app/immutable/entry/app.eb989bb1.js                5.76 kB │ gzip: 2.27 kB
.svelte-kit/output/client/_app/immutable/chunks/index.847936d9.js             7.06 kB │ gzip: 2.86 kB
.svelte-kit/output/client/_app/immutable/entry/start.c881a30f.js             23.31 kB │ gzip: 9.28 kB
✓ built in 274ms
.svelte-kit/output/server/vite-manifest.json                      1.67 kB
.svelte-kit/output/server/internal.js                             0.19 kB
.svelte-kit/output/server/entries/pages/test/_page.server.ts.js   0.22 kB
.svelte-kit/output/server/entries/pages/_page.svelte.js           0.22 kB
.svelte-kit/output/server/entries/fallbacks/layout.svelte.js      0.24 kB
.svelte-kit/output/server/entries/pages/test/_page.svelte.js      0.35 kB
.svelte-kit/output/server/entries/fallbacks/error.svelte.js       0.83 kB
.svelte-kit/output/server/chunks/index.js                         3.27 kB
.svelte-kit/output/server/chunks/internal.js                      5.33 kB
.svelte-kit/output/server/index.js                               84.89 kB

Run npm run preview to preview your production build locally.

> Using @sveltejs/adapter-cloudflare
✘ [ERROR] Could not resolve "fs"

    .svelte-kit/output/server/entries/pages/test/_page.server.ts.js:1:29:
      1 │ import { readFileSync } from "fs";~~~~

  The package "fs" wasn't found on the file system but is built into node. Are you trying to bundle
  for node? You can use "platform: 'node'" to do that, which will remove this error.

error during build:
Error: Build failed with 1 error:
.svelte-kit/output/server/entries/pages/test/_page.server.ts.js:1:29: ERROR: Could not resolve "fs"
    at failureErrorWithLog (/Users/joel/Desktop/sveltekit-retains-prerender-assets/node_modules/@sveltejs/adapter-cloudflare/node_modules/esbuild/lib/main.js:1604:15)
    at /Users/joel/Desktop/sveltekit-retains-prerender-assets/node_modules/@sveltejs/adapter-cloudflare/node_modules/esbuild/lib/main.js:1056:28
    at /Users/joel/Desktop/sveltekit-retains-prerender-assets/node_modules/@sveltejs/adapter-cloudflare/node_modules/esbuild/lib/main.js:1001:67
    at buildResponseToResult (/Users/joel/Desktop/sveltekit-retains-prerender-assets/node_modules/@sveltejs/adapter-cloudflare/node_modules/esbuild/lib/main.js:1054:7)
    at /Users/joel/Desktop/sveltekit-retains-prerender-assets/node_modules/@sveltejs/adapter-cloudflare/node_modules/esbuild/lib/main.js:1166:14
    at responseCallbacks.<computed> (/Users/joel/Desktop/sveltekit-retains-prerender-assets/node_modules/@sveltejs/adapter-cloudflare/node_modules/esbuild/lib/main.js:701:9)
    at handleIncomingPacket (/Users/joel/Desktop/sveltekit-retains-prerender-assets/node_modules/@sveltejs/adapter-cloudflare/node_modules/esbuild/lib/main.js:756:9)
    at Socket.readFromStdout (/Users/joel/Desktop/sveltekit-retains-prerender-assets/node_modules/@sveltejs/adapter-cloudflare/node_modules/esbuild/lib/main.js:677:7)
    at Socket.emit (node:events:527:28)
    at addChunk (node:internal/streams/readable:315:12)

System Info

System:
    OS: macOS 13.1
    CPU: (8) arm64 Apple M1
    Memory: 314.41 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    npm: 8.19.2 - ~/.nvm/versions/node/v16.16.0/bin/npm
  Browsers:
    Brave Browser: 111.1.49.120
    Chrome: 111.0.5563.64
    Safari: 16.2
  npmPackages:
    @sveltejs/adapter-cloudflare: ^2.2.0 => 2.2.0 
    @sveltejs/kit: ^1.5.0 => 1.13.0 
    svelte: ^3.54.0 => 3.57.0 
    vite: ^4.2.0 => 4.2.1 

Severity

blocking an upgrade

Additional Information

No response

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

Successfully merging a pull request may close this issue.

2 participants