-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow embedding two pages generated into the same page in "embed…
…ded" mode (#9610) * added route leaf hash to global init namespace * changeset * update changelog message * revert leaf hash commit * updated with latest suggestions * workong on test case * added int test for two embedded pages inlined into the same page * Update .changeset/late-toes-cry.md Co-authored-by: Ben McCann <[email protected]> * lint * delete test html pages * updated test case * update lockfile * simplify embed tests * remove some unused files * fix tsconfig * alphabetize * prettier * think i fixed it --------- Co-authored-by: Ben McCann <[email protected]> Co-authored-by: Rich Harris <[email protected]>
- Loading branch information
1 parent
84a5250
commit 367067f
Showing
16 changed files
with
151 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
fix: allow embedding two pages generated into the same page in "embedded" mode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.custom-out-dir | ||
!.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "test-options", | ||
"private": true, | ||
"version": "0.0.1", | ||
"scripts": { | ||
"dev": "vite dev", | ||
"build": "vite build", | ||
"preview": "vite preview", | ||
"check": "svelte-kit sync && tsc && svelte-check", | ||
"test": "pnpm test:dev && pnpm test:build", | ||
"test:dev": "cross-env DEV=true playwright test", | ||
"test:build": "playwright test" | ||
}, | ||
"devDependencies": { | ||
"@sveltejs/kit": "workspace:^", | ||
"cross-env": "^7.0.3", | ||
"svelte": "^3.56.0", | ||
"svelte-check": "^3.0.2", | ||
"typescript": "^4.9.4", | ||
"vite": "^4.2.0" | ||
}, | ||
"type": "module" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { config as default } from '../../utils.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
%sveltekit.head% | ||
<div>%sveltekit.body%</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script> | ||
import { setup } from '../../../../setup.js'; | ||
setup(); | ||
</script> | ||
|
||
<slot /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** @type {import('@sveltejs/kit').Load} */ | ||
export async function load({ fetch }) { | ||
return { | ||
a: fetch('/embed/a').then((x) => x.text()), | ||
b: fetch('/embed/b').then((x) => x.text()) | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<script> | ||
export let data; | ||
</script> | ||
|
||
{@html data.a} | ||
{@html data.b} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
import { browser } from '$app/environment'; | ||
</script> | ||
|
||
<h2 data-testid="a">a ({browser ? 'browser' : 'server'})</h2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
import { browser } from '$app/environment'; | ||
</script> | ||
|
||
<h2 data-testid="b">b ({browser ? 'browser' : 'server'})</h2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** @type {import('@sveltejs/kit').Config} */ | ||
const config = { | ||
kit: { | ||
embedded: true | ||
} | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { expect } from '@playwright/test'; | ||
import { test } from '../../../utils.js'; | ||
|
||
/** @typedef {import('@playwright/test').Response} Response */ | ||
|
||
test.describe.configure({ mode: 'parallel' }); | ||
|
||
test.describe('embed', () => { | ||
test('serves embedded components in page', async ({ page, javaScriptEnabled }) => { | ||
await page.goto('/embed'); | ||
|
||
if (javaScriptEnabled) { | ||
expect(await page.textContent('[data-testid="a"]')).toBe('a (browser)'); | ||
expect(await page.textContent('[data-testid="b"]')).toBe('b (browser)'); | ||
} else { | ||
expect(await page.textContent('[data-testid="a"]')).toBe('a (server)'); | ||
expect(await page.textContent('[data-testid="b"]')).toBe('b (server)'); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"checkJs": true, | ||
"esModuleInterop": true, | ||
"noEmit": true, | ||
"paths": { | ||
"@sveltejs/kit": ["../../../types"], | ||
"$lib": ["./src/lib"], | ||
"$lib/*": ["./src/lib/*"], | ||
"types": ["../../../types/internal"] | ||
}, | ||
"resolveJsonModule": true | ||
}, | ||
"extends": "./.svelte-kit/tsconfig.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as path from 'node:path'; | ||
import { sveltekit } from '@sveltejs/kit/vite'; | ||
|
||
/** @type {import('vite').UserConfig} */ | ||
const config = { | ||
build: { | ||
minify: false | ||
}, | ||
clearScreen: false, | ||
plugins: [sveltekit()], | ||
server: { | ||
fs: { | ||
allow: [path.resolve('../../../src')] | ||
} | ||
} | ||
}; | ||
|
||
export default config; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.