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

prerendering broken when using a base path #3393

Closed
Tahlaria opened this issue Jan 18, 2022 · 3 comments · Fixed by #3500
Closed

prerendering broken when using a base path #3393

Tahlaria opened this issue Jan 18, 2022 · 3 comments · Fixed by #3500
Labels
bug Something isn't working
Milestone

Comments

@Tahlaria
Copy link

Tahlaria commented Jan 18, 2022

Describe the bug

When using adapter-static with a base path to build a project the pages won't be built (at least don't appear in build).
There is NO error message on build!
Affected versions: 1.0.0-next.231 and 232, <=230 aren't affected

Reproduction

Link to repository:
https://github.com/Tahlaria/svelte-build-bug

Branch main: works - version 230 referenced in package.json
Branch broken: doesn't work - version next referenced in package.json (232 right now)

npm i && npm run build
ls build

How to do yourself:
Checkout a skeleton project:
npm init svelte@next app
cd app

Import adapter-static:
npm i -D @sveltejs/adapter-static@next

Adapt svelte.config.js according to adapter instructions and use a base path:
svelte.config.js:

import adapter from '@sveltejs/adapter-static';

/** @type {import('@sveltejs/kit').Config} */
const config = {
        kit: {
                adapter: adapter({
                        pages: 'build',
                        assets: 'build',
                        fallback: null,
                        precompress: false
                }),

                // hydrate the <div id="svelte"> element in src/app.html
                target: '#svelte',
                paths: {
                        base: "/foo"
                }
        }
};

export default config;

Build:
npm i
npm build

Logs

### Build console output with next (right now 1.0.0-next.232)

<omitted>@<omitted>:~/Temp/app$ npm run build

> app@0.0.1 build /home/<omitted>/Temp/app
> svelte-kit build

vite v2.7.12 building for production...
✓ 13 modules transformed.
.svelte-kit/output/client/_app/manifest.json                    1.15 KiB
.svelte-kit/output/client/_app/layout.svelte-2102a60c.js        0.53 KiB / gzip: 0.35 KiB
.svelte-kit/output/client/_app/error.svelte-ef333d6a.js         1.56 KiB / gzip: 0.75 KiB
.svelte-kit/output/client/_app/pages/index.svelte-fdf0b640.js   0.80 KiB / gzip: 0.47 KiB
.svelte-kit/output/client/_app/chunks/vendor-f0095a1c.js        7.21 KiB / gzip: 2.96 KiB
.svelte-kit/output/client/_app/start-f26d2edf.js                21.60 KiB / gzip: 7.36 KiB
vite v2.7.12 building SSR bundle for production...
✓ 11 modules transformed.
.svelte-kit/output/server/manifest.json                    0.87 KiB
.svelte-kit/output/server/app.js                           48.60 KiB
.svelte-kit/output/server/entries/pages/layout.svelte.js   0.24 KiB
.svelte-kit/output/server/entries/pages/error.svelte.js    0.72 KiB
.svelte-kit/output/server/entries/pages/index.svelte.js    0.32 KiB
.svelte-kit/output/server/chunks/index-2dc61825.js         2.24 KiB

Run npm run preview to preview your production build locally.

> Using @sveltejs/adapter-static
  Wrote site to "build"done
<omitted>@<omitted>:~/Temp/app$ ls build
_app  favicon.png

### Build console output with (1.0.0-next.230 and lower):

> app@0.0.1 build /home/<omitted>/Temp/app
> svelte-kit build

vite v2.7.12 building for production...
✓ 13 modules transformed.
.svelte-kit/output/client/_app/manifest.json                    1.15 KiB
.svelte-kit/output/client/_app/layout.svelte-2102a60c.js        0.53 KiB / gzip: 0.35 KiB
.svelte-kit/output/client/_app/pages/index.svelte-fdf0b640.js   0.80 KiB / gzip: 0.47 KiB
.svelte-kit/output/client/_app/error.svelte-ef333d6a.js         1.56 KiB / gzip: 0.75 KiB
.svelte-kit/output/client/_app/chunks/vendor-f0095a1c.js        7.21 KiB / gzip: 2.96 KiB
.svelte-kit/output/client/_app/start-f26d2edf.js                21.60 KiB / gzip: 7.36 KiB
vite v2.7.12 building SSR bundle for production...
✓ 11 modules transformed.
.svelte-kit/output/server/manifest.json                    0.87 KiB
.svelte-kit/output/server/app.js                           48.42 KiB
.svelte-kit/output/server/entries/pages/layout.svelte.js   0.24 KiB
.svelte-kit/output/server/entries/pages/error.svelte.js    0.72 KiB
.svelte-kit/output/server/entries/pages/index.svelte.js    0.32 KiB
.svelte-kit/output/server/chunks/index-2dc61825.js         2.24 KiB

Run npm run preview to preview your production build locally.

> Using @sveltejs/adapter-static
  Wrote site to "build"done
<omitted>@<omitted>:~/Temp/app$ ls build
_app  favicon.png  index.html

System Info

System:
    OS: Linux 5.11 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (12) x64 Intel(R) Core(TM) i7-6800K CPU @ 3.40GHz
    Memory: 24.02 GB / 31.27 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 14.18.3 - /usr/bin/node
    npm: 6.14.15 - /usr/bin/npm
  Browsers:
    Chrome: 97.0.4692.71
    Firefox: 96.0
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.11 
    @sveltejs/adapter-static: ^1.0.0-next.26 => 1.0.0-next.26 
    @sveltejs/kit: 1.0.0-next.230 => 1.0.0-next.230 
    svelte: ^3.44.0 => 3.46.2 

Note: @sveltejs/kit was tested with multiple versions:
.230 -> OK
.231 -> fail
.232 -> fail

Severity

serious, but I can work around it

Additional Information

Not a problem if it's known that <=230 isn't affected, otherwise it's breaking build functionality with static adapter (other adapters untested!).

@benmccann benmccann added the bug Something isn't working label Jan 18, 2022
@benmccann benmccann added this to the 1.0 milestone Jan 18, 2022
@benmccann
Copy link
Member

When you share a reproduction, please share a broken version! It took me forever to figure out why I couldn't reproduce the issue and that you had pinned an old version of SvelteKit in your package.json

@benmccann benmccann changed the title Builds with adapter static are broken when using a base path prerendering broken when using a base path Jan 20, 2022
@benmccann
Copy link
Member

benmccann commented Jan 20, 2022

This line is being hit, so nothing is being rendered:

if (!decoded.startsWith(options.paths.base)) return;

It looks like prerendering does not include the base path in any of its requests

Probably was broken by #3345

@lemmon
Copy link

lemmon commented Jan 20, 2022

I have [probably] the same issue, starting v 231. However, I haven't applied any special settings for kit.paths nor the adapter. Everything is set to default.

The only affected file is favicon.ico.

HTTP/1.1 404 Not Found
Content-Length: 9

But the very same file renamed to favicon2.ico works just fine:

HTTP/1.1 200 OK
Content-Length: 61

Every other file seems to be working just fine.

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.

3 participants