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

adapter-static build with dynamic +page.server.ts issue #7244

Closed
fredOpenscop opened this issue Oct 12, 2022 · 3 comments
Closed

adapter-static build with dynamic +page.server.ts issue #7244

fredOpenscop opened this issue Oct 12, 2022 · 3 comments
Labels
bug Something isn't working p3-edge-case SvelteKit cannot be used in an uncommon way
Milestone

Comments

@fredOpenscop
Copy link

Describe the bug

Hello,

I'm not really sure if it is a bug or a misusage on my part, but since migrating to the new page system, I can't build my static website with this error :

error during build:
Error: ENOTDIR: not a directory, copyfile '/home/frederic/dev/openscop/openscop.fr/.svelte-kit/output/prerendered/dependencies/communication/aidepsy.html/__data.js' -> 'build/htdocs/communication/aidepsy.html/__data.js'

The reproduction is a simple example of what I'm doing on the real app with the same issue.

All the pre-rendered pages (all the page ^^) seem to be ok, I can preview the website with npm run preview.
Removing the +page.server.ts of the dynamic folder remove the error.

I did try it with nodejs 16 and 18.

I'm using .html in link for the static website to take the file (he does not find page without extension, this idiot ^^)

It was working fine before with those settings :

{
"devDependencies": {
    "@cypress/vite-dev-server": "^3.0.0",
    "@playwright/test": "^1.24.2",
    "@rollup/plugin-yaml": "^3.1.0",
    "@sveltejs/adapter-static": "^1.0.0-next.39",
    "@sveltejs/kit": "next",
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/svelte": "^3.1.3",
    "@types/lodash-es": "^4.17.6",
    "@types/node": "^18.0.0",
    "autoprefixer": "^10.4.8",
    "jsdom": "^20.0.0",
    "lodash-es": "^4.17.21",
    "postcss": "^8.4.14",
    "svelte": "^3.44.0",
    "svelte-check": "^2.7.1",
    "svelte-preprocess": "^4.10.7",
    "tailwindcss": "^3.1.8",
    "tslib": "^2.3.1",
    "typescript": "^4.7.2",
    "vite": "^3.0.0",
    "vitest": "^0.21.1"
  }
}

I'm hoping I did mention enough information :)

Thanks for the great framework.

Reproduction

https://gitlab.com/FredOpenscop/debug-sveltekit-static.git

Logs

npm run build

> [email protected] build
> vite build

vite v3.1.7 building for production...
✓ 47 modules transformed.
vite v3.1.7 building SSR bundle for production...
✓ 55 modules transformed.
Generated an empty chunk: "hooks"
.svelte-kit/output/server/vite-manifest.json                                        2.63 KiB
.svelte-kit/output/server/index.js                                                  70.80 KiB
.svelte-kit/output/server/entries/pages/_layout.svelte.js                           0.94 KiB
.svelte-kit/output/server/entries/pages/_layout.ts.js                               0.28 KiB
.svelte-kit/output/server/entries/fallbacks/error.svelte.js                         0.60 KiB
.svelte-kit/output/server/entries/pages/(content)/_layout.svelte.js                 0.43 KiB
.svelte-kit/output/server/entries/pages/(home)/_layout.svelte.js                    0.43 KiB
.svelte-kit/output/server/entries/pages/(content)/page/_title_/_page.svelte.js      0.40 KiB
.svelte-kit/output/server/entries/pages/(content)/page/_title_/_page.server.ts.js   0.29 KiB
.svelte-kit/output/server/entries/pages/(home)/_page.svelte.js                      0.39 KiB
.svelte-kit/output/server/entries/pages/(home)/_page.server.ts.js                   0.17 KiB
.svelte-kit/output/server/chunks/index.js                                           3.53 KiB
.svelte-kit/output/server/chunks/stores.js                                          1.00 KiB
.svelte-kit/output/server/chunks/others.js                                          0.19 KiB
.svelte-kit/output/server/chunks/hooks.js                                           0.00 KiB

Run npm run preview to preview your production build locally.
.svelte-kit/output/client/vite-manifest.json                                                                4.66 KiB
.svelte-kit/output/client/_app/immutable/components/pages/_layout.svelte-6d3b8da6.js                        2.56 KiB / gzip: 1.10 KiB
.svelte-kit/output/client/_app/immutable/components/pages/(content)/_layout.svelte-259b1951.js              0.71 KiB / gzip: 0.47 KiB
.svelte-kit/output/client/_app/immutable/components/error.svelte-ba6578a9.js                                1.54 KiB / gzip: 0.71 KiB
.svelte-kit/output/client/_app/immutable/components/pages/(home)/_page.svelte-61f4b924.js                   0.72 KiB / gzip: 0.46 KiB
.svelte-kit/output/client/_app/immutable/components/pages/(home)/_layout.svelte-5359117b.js                 0.71 KiB / gzip: 0.47 KiB
.svelte-kit/output/client/_app/immutable/components/pages/(content)/page/_title_/_page.svelte-9de8c29f.js   0.73 KiB / gzip: 0.46 KiB
.svelte-kit/output/client/_app/immutable/modules/pages/_layout.ts-cc789202.js                               0.09 KiB / gzip: 0.10 KiB
.svelte-kit/output/client/_app/immutable/chunks/singletons-3323fcd0.js                                      1.81 KiB / gzip: 0.99 KiB
.svelte-kit/output/client/_app/immutable/chunks/_layout-63f1ad26.js                                         0.36 KiB / gzip: 0.25 KiB
.svelte-kit/output/client/_app/immutable/chunks/0-d9a6d4a0.js                                               0.15 KiB / gzip: 0.13 KiB
.svelte-kit/output/client/_app/immutable/chunks/stores-7c4b4d7a.js                                          0.61 KiB / gzip: 0.35 KiB
.svelte-kit/output/client/_app/immutable/chunks/1-6ec5fdce.js                                               0.09 KiB / gzip: 0.09 KiB
.svelte-kit/output/client/_app/immutable/chunks/2-36a25ce3.js                                               0.10 KiB / gzip: 0.11 KiB
.svelte-kit/output/client/_app/immutable/chunks/3-3440a889.js                                               0.10 KiB / gzip: 0.11 KiB
.svelte-kit/output/client/_app/immutable/chunks/index-3c01b65e.js                                           6.76 KiB / gzip: 2.74 KiB
.svelte-kit/output/client/_app/immutable/chunks/4-abeee9a2.js                                               0.14 KiB / gzip: 0.13 KiB
.svelte-kit/output/client/_app/immutable/chunks/5-f88263db.js                                               0.12 KiB / gzip: 0.12 KiB
.svelte-kit/output/client/_app/immutable/assets/_layout-8d47e91e.css                                        0.04 KiB / gzip: 0.06 KiB
.svelte-kit/output/client/_app/immutable/assets/_layout-9bb138bb.css                                        0.04 KiB / gzip: 0.06 KiB
.svelte-kit/output/client/_app/immutable/start-89b7e22a.js                                                  26.72 KiB / gzip: 10.01 KiB

> Using @sveltejs/adapter-static
error during build:
Error: ENOTDIR: not a directory, copyfile '/home/frederic/dev/test/debug-svelte/.svelte-kit/output/prerendered/dependencies/page/page_1.html/__data.json' -> 'build/page/page_1.html/__data.json'
    at Object.copyFileSync (node:fs:2866:3)
    at go (file:https:///home/frederic/dev/test/debug-svelte/node_modules/@sveltejs/kit/src/utils/filesystem.js:65:8)
    at file:https:///home/frederic/dev/test/debug-svelte/node_modules/@sveltejs/kit/src/utils/filesystem.js:50:5
    at Array.forEach (<anonymous>)
    at go (file:https:///home/frederic/dev/test/debug-svelte/node_modules/@sveltejs/kit/src/utils/filesystem.js:49:25)
    at file:https:///home/frederic/dev/test/debug-svelte/node_modules/@sveltejs/kit/src/utils/filesystem.js:50:5
    at Array.forEach (<anonymous>)
    at go (file:https:///home/frederic/dev/test/debug-svelte/node_modules/@sveltejs/kit/src/utils/filesystem.js:49:25)
    at file:https:///home/frederic/dev/test/debug-svelte/node_modules/@sveltejs/kit/src/utils/filesystem.js:50:5
    at Array.forEach (<anonymous>)

System Info

System:
    OS: Linux 5.19 Fedora Linux 36 (Workstation Edition)
    CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
    Memory: 21.54 GB / 31.29 GB
    Container: Yes
    Shell: 5.2.2 - /bin/bash
  Binaries:
    Node: 18.7.0 - ~/.nvm/versions/node/v18.7.0/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 8.15.0 - ~/.nvm/versions/node/v18.7.0/bin/npm
  Browsers:
    Chrome: 106.0.5249.103
    Firefox: 105.0.2
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.82 
    @sveltejs/adapter-static: ^1.0.0-next.44 => 1.0.0-next.44 
    @sveltejs/kit: next => 1.0.0-next.514 
    svelte: ^3.44.0 => 3.51.0 
    vite: ^3.1.0 => 3.1.7

Severity

blocking an upgrade

Additional Information

No response

@dummdidumm
Copy link
Member

This happens because of the .html - it creates a conflict because in prerendered/dependencies theres a folder page_1.html, but in prerendered/pages there's also a file with the name page_1.html. They both are tried to be copied to the same location, and that crashes because you can't have a folder and file with the same name. I don't know how to fix this in a good way, and I unfortunately don't have a good workaround for you in the meantime.

@dummdidumm dummdidumm added bug Something isn't working p3-edge-case SvelteKit cannot be used in an uncommon way labels Oct 12, 2022
@fredOpenscop
Copy link
Author

fredOpenscop commented Oct 12, 2022

Thanks for the quick reply,

I will come back if I found a solution to bypass the problem :) (when I have time to look for it)

edit:
for people having this issue and behind a nginx, you can bypass it by

  • removing .html in href
  • using something like that in nginx config :
location / {
    try_files $uri $uri.html /index.html;
}

location ~* .(png|ico|gif|jpg|jpeg|css|js)$ {
    try_files $uri =404;
}

I will continue to search for other solution since our production server doesn't allow us to edit nginx config so removing .html from the link does not work :'(

dummdidumm added a commit that referenced this issue Oct 14, 2022
Rich-Harris added a commit that referenced this issue Oct 18, 2022
* [fix] more info about prerendering errors

Helps with #7183 and #7244

* Apply suggestions from code review

* swap ternary around, remove dead code

* small tweak

* another minor tweak

* drive-by-fix

* tweak when prerender.entries suggestion appears

* tweak

* add strict option

* Apply suggestions from code review

Co-authored-by: Rich Harris <[email protected]>
Co-authored-by: Rich Harris <[email protected]>
@benmccann benmccann changed the title adapter-static build with dynamic +page.serveur.ts issue adapter-static build with dynamic +page.server.ts issue Nov 14, 2022
@Rich-Harris Rich-Harris added this to the whenever milestone Nov 17, 2022
@dummdidumm
Copy link
Member

Closing in favor of #8676 because of a more descriptive issue title etc

@dummdidumm dummdidumm closed this as not planned Won't fix, can't repro, duplicate, stale Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p3-edge-case SvelteKit cannot be used in an uncommon way
Projects
None yet
Development

No branches or pull requests

3 participants