Closed
Description
Describe the bug
I'm trying to import a built svelte-kit site within another one, and it is not possible because importing import { handler } from 'sub-site/build/handler'
has side-effects, namely calling __fetch_polyfill
.
Reproduction
- Create a svelte-kit website that uses adapter-node
- Build this website
- Create another svelte-kit website with the following configuration
import adapter from '@sveltejs/adapter-node'
import preprocess from 'svelte-preprocess'
import { handler } from 'sub-site/build/handler'
/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: preprocess(),
kit: {
adapter: adapter(),
target: '#svelte',
vite: {
plugins: [
{
name: 'sub-site',
configureServer({ middlewares }) {
middlewares.use(handler) // Load the sub-site here
},
},
],
},
},
}
export default config
Logs
> Cannot redefine property: fetch
at Function.defineProperties (<anonymous>)
at __fetch_polyfill (file:///home/.../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.229_svelte@3.46.1/node_modules/@sveltejs/kit/dist/install-fetch.js:6494:9)
System Info
SvelteKit v1.0.0-next.229
Adapter Node v1.0.0-next.61
Severity
annoyance
Additional Information
I'll submit a PR in a few minutes that fixes this issue, the solution is to add configurable: true
to all definitions here:
kit/packages/kit/src/install-fetch.js
Lines 4 to 23 in f92c3e2
Metadata
Metadata
Assignees
Labels
No labels