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

Addding config.kit.paths.base breaks npm run build #2230

Closed
marcel0ll opened this issue Aug 17, 2021 · 10 comments · Fixed by #2407
Closed

Addding config.kit.paths.base breaks npm run build #2230

marcel0ll opened this issue Aug 17, 2021 · 10 comments · Fixed by #2407
Labels
bug Something isn't working
Milestone

Comments

@marcel0ll
Copy link

Describe the bug

On versions >1.0.0-next.147 adding a 'base' path to the project makes it no longer build.
This happens while using adapter-static

Reproduction

  1. Create new project

npm init svelte@next my-app
cd my-app
npm install
npm run dev -- --open

  1. Install and config adapter-static

Install with npm i -D @sveltejs/adapter-static@next, then add the adapter to your svelte.config.js:

// svelte.config.js
import adapter from '@sveltejs/adapter-static';

export default {
	kit: {
		adapter: adapter({
			// default options are shown
			pages: 'build',
			assets: 'build',
			fallback: null
		})
	}
};
  1. Config 'base' path
import adapter from '@sveltejs/adapter-static';

/** @type {import('@sveltejs/kit').Config} */
const config = {
	kit: {
		// hydrate the <div id="svelte"> element in src/app.html
		target: '#svelte',
		paths: {
			base: '/something'
		},
		adapter: adapter({
			// default options are shown
			pages: 'build',
			assets: 'build',
			fallback: null
		})
	}
};

export default config;
  1. npm run build

Logs

vite v2.5.0 building SSR bundle for production...
✓ 34 modules transformed.
.svelte-kit/output/server/app.js   68.93 KiB

Run npm run preview to preview your production build locally.

> Using @sveltejs/adapter-static
> 404 /_app/start-518edf61.js (linked from /)
Error: 404 /_app/start-518edf61.js (linked from /)
...

System Info

System:
    OS: Linux 4.15 Linux Mint 19.2 (Tina)
    CPU: (4) x64 Intel(R) Core(TM) i5-6300HQ CPU @ 2.30GHz
    Memory: 7.40 GB / 15.59 GB
    Container: Yes
    Shell: 4.4.20 - /bin/bash
  Binaries:
    Node: 14.17.0 - ~/.nvm/versions/node/v14.17.0/bin/node
    Yarn: 1.22.5 - /usr/bin/yarn
    npm: 6.14.13 - ~/.nvm/versions/node/v14.17.0/bin/npm
  Browsers:
    Brave Browser: 91.1.26.74
    Chrome: 91.0.4472.114
    Firefox: 90.0
  npmPackages:
    @sveltejs/adapter-static: ^1.0.0-next.16 => 1.0.0-next.16
    @sveltejs/kit: next => 1.0.0-next.153
    svelte: ^3.34.0 => 3.42.1

Severity

blocking an upgrade

Additional Information

Changing back to version 1.0.0-next.147 stops the error on my personal repo, but it does not seem to work on the example project.

@benmccann benmccann added the bug Something isn't working label Aug 17, 2021
@benmccann benmccann added this to the 1.0 milestone Aug 21, 2021
@sidharthv96
Copy link
Contributor

Facing the issue in https:/mermaid-js/mermaid-live-editor

@sidharthv96
Copy link
Contributor

Trying to figure out which change is causing the issue. #2189 seems to be related.

@Xananax
Copy link

Xananax commented Aug 23, 2021

I confirm that

pnpm remove @sveltejs/kit 
pnpm add -D @sveltejs/[email protected] 

Allows my site to build statically.

It seems

pnpm add -D @sveltejs/kit@next  

works too

Edit: I was wrong, my path was empty. svelte@next doesn't work with a path.base set. After processing for 30s, the process dies with:

Stacktrace ``` <--- Last few GCs --->

[14791:0x5fb6a90] 40386 ms: Scavenge (reduce) 2037.5 (2052.7) -> 2037.3 (2053.2) MB, 4.0 / 0.0 ms (average mu = 0.132, current mu = 0.059) allocation failure
[14791:0x5fb6a90] 40393 ms: Scavenge (reduce) 2037.9 (2050.2) -> 2037.6 (2051.4) MB, 4.1 / 0.0 ms (average mu = 0.132, current mu = 0.059) allocation failure
[14791:0x5fb6a90] 40400 ms: Scavenge (reduce) 2038.3 (2053.4) -> 2038.1 (2053.9) MB, 4.4 / 0.0 ms (average mu = 0.132, current mu = 0.059) allocation failure

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0xa24ed0 node::Abort() [node]
2: 0x966115 node::FatalError(char const*, char const*) [node]
3: 0xb9acde v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
4: 0xb9b057 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
5: 0xd56ea5 [node]
6: 0xd57a2f [node]
7: 0xd65abb v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
8: 0xd6967c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
9: 0xd2ee1d v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [node]
10: 0xd28ca4 v8::internal::FactoryBasev8::internal::Factory::AllocateRawWithImmortalMap(int, v8::internal::AllocationType, v8::internal::Map, v8::internal::AllocationAlignment) [node]
11: 0xd2a1d9 v8::internal::FactoryBasev8::internal::Factory::NewStruct(v8::internal::InstanceType, v8::internal::AllocationType) [node]
12: 0xd362f6 v8::internal::Factory::NewStackTraceFrame(v8::internal::Handlev8::internal::FrameArray, int) [node]
13: 0xcf6080 [node]
14: 0xcf6b47 v8::internal::Isolate::CaptureAndSetSimpleStackTrace(v8::internal::Handlev8::internal::JSReceiver, v8::internal::FrameSkipMode, v8::internal::Handlev8::internal::Object) [node]
15: 0xd08ab9 v8::internal::ErrorUtils::Construct(v8::internal::Isolate*, v8::internal::Handlev8::internal::JSFunction, v8::internal::Handlev8::internal::Object, v8::internal::Handlev8::internal::Object) [node]
16: 0xc31756 v8::internal::Builtin_ErrorConstructor(int, unsigned long*, v8::internal::Isolate*) [node]
17: 0x1427159 [node]

</details>

Edit 2: Actually no, the older version doesn't work either. Things break in novel and spectacular ways, `path` is empty during some part of the build, so hrefs are wrong (but not always!). The build fails with `Error: 500 (linked from /)`.

I'm dropping the idea of using static for the moment, I can't make it work

@Xananax
Copy link

Xananax commented Aug 24, 2021

Actually no, the older version doesn't work either. Things break in novel and spectacular ways, path is empty during some part of the build, so hrefs are wrong (but not always!). The build fails with Error: 500 (linked from /). Different configurations of hrefs (depending on where I compose them, template/data give me different errors, but nothing works.

I'm dropping the idea of using static for the moment, I can't make it work.

Rectification: it works

@sidharthv96
Copy link
Contributor

sidharthv96 commented Aug 24, 2021

I'm using github pages and static adapter, with base path to deploy mermaid live editor and it works without any issue on 147.

https:/mermaid-js/mermaid-live-editor/blob/master/svelte.config.js
https://mermaid-js.github.io/mermaid-live-editor/beta/

@Xananax
Copy link

Xananax commented Aug 24, 2021

Yes, you're right! After reading your comment, I re-examined my code, and I had a single hard-coded href to the homepage that wasn't using base. Thanks!

@derolf
Copy link

derolf commented Aug 26, 2021

I am getting a 404:

> Using @sveltejs/adapter-static
> 404 /_app/start-4634779f.js (linked from /)

1.0.0-next.147: works
1.0.0-next.148: does not work

@gavinr
Copy link

gavinr commented Aug 28, 2021

I am having this issue too, and just to follow-up on @derolf's comment, for a workaround, if you run:

npm install @sveltejs/[email protected] --save-dev
npm run build

If seems to work.

@SarcevicAntonio
Copy link
Member

Just wanted to note im facing the same issue. setting kit.paths.base gives me the error message > 404 /_app/start-333b5ef8.js (linked from /).

I was using [email protected] and @sveltejs/[email protected], but @sveltejs/[email protected] seems to work.

@terwer
Copy link

terwer commented Nov 6, 2023

https://mermaid-js.github.io/mermaid-live-editor/beta/

Thanks very much, helps me a lot❤

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
8 participants