Skip to content

Commit 2196e6b

Browse files
committed
Merge branch 'main' of github.com:sveltejs/svelte.dev into feat/playground-add-sv-cmd
2 parents 0926071 + 881603b commit 2196e6b

File tree

6 files changed

+22
-17
lines changed

6 files changed

+22
-17
lines changed

apps/svelte.dev/content/docs/kit/10-getting-started/30-project-structure.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ The `src` directory contains the meat of your project. Everything except `src/ro
5353
- `error.html` is the page that is rendered when everything else fails. It can contain the following placeholders:
5454
- `%sveltekit.status%` — the HTTP status
5555
- `%sveltekit.error.message%` — the error message
56+
- `%sveltekit.version%` — the deployment version, which can be specified with the [`version`](configuration#version) configuration
5657
- `hooks.client.js` contains your client [hooks](hooks)
5758
- `hooks.server.js` contains your server [hooks](hooks)
5859
- `service-worker.js` contains your [service worker](service-workers)

packages/repl/src/lib/Input/ComponentSelector.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@
182182
<input
183183
value={workspace.svelte_version}
184184
placeholder="latest"
185-
onchange={(ev) => (workspace.svelte_version = ev.currentTarget.value || 'latest')}
185+
onchange={(ev) => workspace.set_svelte_version(ev.currentTarget.value || 'latest', true)}
186186
/>
187187
</label>
188188

packages/repl/src/lib/Repl.svelte

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@
127127
...workspace.current!,
128128
contents: migration!.code
129129
});
130-
131-
rebundle();
132130
}
133131
134132
let width = $state(0);
@@ -142,7 +140,7 @@
142140
? new Bundler({
143141
svelte_version: svelteVersion,
144142
onversion: (version) => {
145-
workspace.svelte_version = version;
143+
workspace.set_svelte_version(version);
146144
onversion?.(version);
147145
},
148146
onstatus: (message) => {

packages/repl/src/lib/Workspace.svelte.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -407,14 +407,13 @@ export class Workspace {
407407
selected?: string
408408
) {
409409
this.states.clear();
410-
this.set(new_files, selected);
411-
412-
this.mark_saved();
413-
414410
this.#tailwind = options.tailwind;
415411
this.#aliases = options.aliases;
416412

417-
const bundle = this.#onreset(new_files);
413+
const bundle = this.set(new_files, selected);
414+
415+
this.mark_saved();
416+
418417
const diagnostics = this.#reset_diagnostics();
419418

420419
return Promise.all([bundle, diagnostics])
@@ -458,7 +457,7 @@ export class Workspace {
458457
}
459458
}
460459

461-
this.#onreset?.(this.files);
460+
return this.#onreset?.(this.files);
462461
}
463462

464463
unlink(view: EditorView) {
@@ -507,10 +506,12 @@ export class Workspace {
507506
return this.#svelte_version;
508507
}
509508

510-
set svelte_version(value) {
509+
set_svelte_version(value: string, notify = false) {
511510
this.#svelte_version = value;
512-
this.#update_file(this.#current);
513-
this.#reset_diagnostics();
511+
if (notify) {
512+
this.#update_file(this.#current);
513+
this.#reset_diagnostics();
514+
}
514515
}
515516

516517
get vim() {

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ self.addEventListener('message', async (event: MessageEvent<BundleMessageData>)
7676

7777
console.log('[bundle worker result]', result);
7878

79-
if (JSON.stringify(result.error) === JSON.stringify(ABORT)) return;
79+
// error object might be augmented, see https://github.com/rollup/rollup/blob/76a3b8ede4729a71eb522fc29f7d550a4358827b/docs/plugin-development/index.md#thiserror,
80+
// hence only check that the specific abort property we set is there
81+
if ((result.error as any)?.svelte_bundler_aborted === ABORT.svelte_bundler_aborted) {
82+
return;
83+
}
8084
if (result && uid === current_id) postMessage(result);
8185
});
8286
} catch (e) {
@@ -111,7 +115,7 @@ function get_svelte(svelte_version: string) {
111115
return ready;
112116
}
113117

114-
const ABORT = { aborted: true };
118+
const ABORT = { svelte_bundler_aborted: true };
115119

116120
let previous: {
117121
key: string;

packages/repl/src/lib/workers/bundler/plugins/commonjs.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ const plugin: Plugin = {
4242
context.next();
4343
},
4444
AssignmentExpression: (node, context) => {
45+
// walk children to find nested requires
46+
context.next();
47+
4548
if (node.operator !== '=') return;
4649
if (node.left.type !== 'MemberExpression') return;
4750
if (node.left.object.type !== 'Identifier' || node.left.object.name !== 'exports') return;
@@ -53,8 +56,6 @@ const plugin: Plugin = {
5356
`export const ${node.left.property.name} = module.exports.${node.left.property.name};`
5457
);
5558
}
56-
57-
context.next();
5859
}
5960
});
6061

0 commit comments

Comments
 (0)