From 84d1cfb2b27885692c880d37511a0267f97ae2a6 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Fri, 13 Sep 2024 14:06:46 -0700 Subject: [PATCH] perf: inline default imports into template --- .changeset/seven-shrimps-explode.md | 5 +++++ .../phases/3-transform/client/utils.js | 7 ++----- .../client/visitors/RegularElement.js | 10 +++++++--- .../compiler/utils/sanitize_template_string.js | 1 + .../_expected/client/index.svelte.js | 18 +++++++++++++----- .../_expected/server/index.svelte.js | 4 +++- .../samples/inline-module-vars/index.svelte | 6 ++++++ 7 files changed, 37 insertions(+), 14 deletions(-) create mode 100644 .changeset/seven-shrimps-explode.md diff --git a/.changeset/seven-shrimps-explode.md b/.changeset/seven-shrimps-explode.md new file mode 100644 index 000000000000..306c3feb1aff --- /dev/null +++ b/.changeset/seven-shrimps-explode.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +perf: inline default imports into template diff --git a/packages/svelte/src/compiler/phases/3-transform/client/utils.js b/packages/svelte/src/compiler/phases/3-transform/client/utils.js index 9463d909bc3a..0b6896589ab7 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/utils.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/utils.js @@ -314,15 +314,12 @@ export function create_derived(state, arg) { /** * Whether a variable can be referenced directly from template string. - * @param {import('#compiler').Binding | undefined} binding + * @param {import('#compiler').Binding} binding * @returns {boolean} */ export function can_inline_variable(binding) { return ( - !!binding && // in a ` +