Skip to content

feat: add templating mode selector #1214

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

Merged
merged 13 commits into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
merge main
  • Loading branch information
Rich-Harris committed Mar 31, 2025
commit 9948924526e607eb7cf7b95c06f843b604c4704f
1 change: 1 addition & 0 deletions packages/repl/src/lib/Repl.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
async function rebundle() {
const token = (current_token = Symbol());
const result = await bundler!.bundle(workspace.files as File[], {
tailwind: workspace.tailwind,
// @ts-ignore
templatingMode: workspace.compiler_options.templatingMode
});
Expand Down
18 changes: 1 addition & 17 deletions packages/repl/src/lib/workers/bundler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,6 @@ self.addEventListener('message', async (event: MessageEvent<BundleMessageData>)
}
});

let cached: Record<
'client' | 'server',
Map<string, { code: string; result: ReturnType<typeof svelte.compile>; templatingMode: string }>
> = {
client: new Map(),
server: new Map()
};

const ABORT = { aborted: true };

const FETCH_CACHE: Map<string, Promise<{ url: string; body: string }>> = new Map();
Expand Down Expand Up @@ -474,13 +466,7 @@ async function get_bundle(

let result: CompileResult;

if (
cached_id &&
cached_id.code === code &&
cached_id.templatingMode === (options as any).templatingMode
) {
result = cached_id.result;
} else if (id.endsWith('.svelte')) {
if (id.endsWith('.svelte')) {
const compilerOptions: any = {
filename: name + '.svelte',
generate: Number(svelte.VERSION.split('.')[0]) >= 5 ? 'client' : 'dom',
Expand Down Expand Up @@ -558,8 +544,6 @@ async function get_bundle(
return null;
}

new_cache.set(id, { code, result, templatingMode: (options as any).templatingMode });

// @ts-expect-error
(result.warnings || result.stats?.warnings)?.forEach((warning) => {
// This is required, otherwise postMessage won't work
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.