Skip to content

Commit d908861

Browse files
committed
fix: only move imports relative to non-imports
1 parent f9652b6 commit d908861

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

packages/svelte/src/compiler/phases/3-transform/client/transform-client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ export function client_component(analysis, options) {
459459

460460
// we hoist all the import declarations to the top of the file
461461
const body = [...module.body, ...state.hoisted].sort((body_a, body_b) =>
462-
body_a.type === 'ImportDeclaration' ? -1 : 1
462+
body_a.type === 'ImportDeclaration' && body_b.type !== 'ImportDeclaration' ? -1 : 1
463463
);
464464

465465
const component = b.function_declaration(

packages/svelte/tests/snapshot/samples/bind-component-snippet/_expected/client/index.svelte.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import "svelte/internal/disclose-version";
2-
import TextInput from './Child.svelte';
32
import * as $ from "svelte/internal/client";
3+
import TextInput from './Child.svelte';
44

55
var root = $.template(`<!> `, 1);
66

packages/svelte/tests/snapshot/samples/imports-in-modules/_expected/client/index.svelte.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import "svelte/internal/disclose-version";
2-
import { random } from './module.svelte';
32
import * as $ from "svelte/internal/client";
3+
import { random } from './module.svelte';
44

55
export default function Imports_in_modules($$anchor) {
66

0 commit comments

Comments
 (0)