Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions packages/repl/src/lib/workers/bundler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import type { BundleResult } from '$lib/public';
self.window = self;

const ENTRYPOINT = '__entry.js';
const WRAPPER = '__wrapper.svelte';
const STYLES = '__styles.js';
const ESM_ENV = '__esm-env.js';

Expand Down Expand Up @@ -512,15 +513,15 @@ async function bundle(
import { unmount as u } from 'svelte';
import { styles } from '${VIRTUAL}/${STYLES}';
export { mount, untrack } from 'svelte';
export {default as App} from './App.svelte';
export { default as App } from '${VIRTUAL}/${WRAPPER}';
export function unmount(component) {
u(component);
styles.forEach(style => style.remove());
}
`
: `
import { styles } from '${VIRTUAL}/${STYLES}';
export {default as App} from './App.svelte';
export { default as App } from './App.svelte';
export function mount(component, options) {
return new component(options);
}
Expand All @@ -535,6 +536,30 @@ async function bundle(
text: true
});

const wrapper = can_use_experimental_async
? `
<script>
import App from './App.svelte';
</script>

<svelte:boundary>
<App />

{#snippet pending()}{/snippet}
</svelte:boundary>
`
: `
export { default } from './App.svelte';
`;

lookup.set(WRAPPER, {
type: 'file',
name: WRAPPER,
basename: WRAPPER,
contents: wrapper,
text: true
});

lookup.set(STYLES, {
type: 'file',
name: STYLES,
Expand Down