Skip to content

Commit 49c3a0d

Browse files
wrap app in boundary (#1416)
Co-authored-by: ComputerGuy <[email protected]>
1 parent 0b9fdfe commit 49c3a0d

File tree

1 file changed

+27
-2
lines changed
  • packages/repl/src/lib/workers/bundler

1 file changed

+27
-2
lines changed

packages/repl/src/lib/workers/bundler/index.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import type { BundleResult } from '$lib/public';
3838
self.window = self;
3939

4040
const ENTRYPOINT = '__entry.js';
41+
const WRAPPER = '__wrapper.svelte';
4142
const STYLES = '__styles.js';
4243
const ESM_ENV = '__esm-env.js';
4344

@@ -512,15 +513,15 @@ async function bundle(
512513
import { unmount as u } from 'svelte';
513514
import { styles } from '${VIRTUAL}/${STYLES}';
514515
export { mount, untrack } from 'svelte';
515-
export {default as App} from './App.svelte';
516+
export { default as App } from '${VIRTUAL}/${WRAPPER}';
516517
export function unmount(component) {
517518
u(component);
518519
styles.forEach(style => style.remove());
519520
}
520521
`
521522
: `
522523
import { styles } from '${VIRTUAL}/${STYLES}';
523-
export {default as App} from './App.svelte';
524+
export { default as App } from './App.svelte';
524525
export function mount(component, options) {
525526
return new component(options);
526527
}
@@ -535,6 +536,30 @@ async function bundle(
535536
text: true
536537
});
537538

539+
const wrapper = can_use_experimental_async
540+
? `
541+
<script>
542+
import App from './App.svelte';
543+
</script>
544+
545+
<svelte:boundary>
546+
<App />
547+
548+
{#snippet pending()}{/snippet}
549+
</svelte:boundary>
550+
`
551+
: `
552+
export { default } from './App.svelte';
553+
`;
554+
555+
lookup.set(WRAPPER, {
556+
type: 'file',
557+
name: WRAPPER,
558+
basename: WRAPPER,
559+
contents: wrapper,
560+
text: true
561+
});
562+
538563
lookup.set(STYLES, {
539564
type: 'file',
540565
name: STYLES,

0 commit comments

Comments
 (0)