-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
perf: inline module variables into template #13075
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
Changes from all commits
cd8b708
fe64b20
0a82796
bab6e9d
317282d
1bfd839
77cff50
346a8c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
|
||
perf: inline module variables into template |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import "svelte/internal/disclose-version"; | ||
import * as $ from "svelte/internal/client"; | ||
|
||
const __DECLARED_ASSET_0__ = "__VITE_ASSET__2AM7_y_a__ 1440w, __VITE_ASSET__2AM7_y_b__ 960w"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are these later inlined completely? it should be possible to have one static string here instead of interpolation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, but that's a bit more complicated to handle here and we've generally tried to avoid adding such complication here in favor of letting general purpose optimizers handle it. Unfortunately esbuild does not yet handle this case, but I've filed a feature request for it: evanw/esbuild#3570. Oxc also does not handle it, so I've file a request there as well so that it will be handled when switching to rolldown, but it was unfortunately closed for the time being: oxc-project/oxc#2646 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so in lieu of external tools supporting it, do we reconsider inlining these ourselves? it would make svelte output more svelte after all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. potentially as a future enhancement if folks agree. i'm still hoping esbuild and oxc will add support. they haven't said they're against it, but just haven't prioritized it. I'd rather not try to do it as part of this PR though to keep things simple for now as this solves 95% of the issue |
||
const __DECLARED_ASSET_1__ = "__VITE_ASSET__2AM7_y_c__ 1440w, __VITE_ASSET__2AM7_y_d__ 960w"; | ||
const __DECLARED_ASSET_2__ = "__VITE_ASSET__2AM7_y_e__ 1440w, __VITE_ASSET__2AM7_y_f__ 960w"; | ||
const __DECLARED_ASSET_3__ = "__VITE_ASSET__2AM7_y_g__"; | ||
var root = $.template(`<picture><source srcset="${__DECLARED_ASSET_0__}" type="image/avif"> <source srcset="${__DECLARED_ASSET_1__}" type="image/webp"> <source srcset="${__DECLARED_ASSET_2__}" type="image/png"> <img src="${__DECLARED_ASSET_3__}" alt="production test" width="1440" height="1440"></picture>`); | ||
benmccann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
export default function Inline_module_vars($$anchor) { | ||
var picture = root(); | ||
var source = $.child(picture); | ||
var source_1 = $.sibling(source, 2); | ||
var source_2 = $.sibling(source_1, 2); | ||
var img = $.sibling(source_2, 2); | ||
|
||
$.reset(picture); | ||
$.append($$anchor, picture); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import * as $ from "svelte/internal/server"; | ||
|
||
const __DECLARED_ASSET_0__ = "__VITE_ASSET__2AM7_y_a__ 1440w, __VITE_ASSET__2AM7_y_b__ 960w"; | ||
const __DECLARED_ASSET_1__ = "__VITE_ASSET__2AM7_y_c__ 1440w, __VITE_ASSET__2AM7_y_d__ 960w"; | ||
const __DECLARED_ASSET_2__ = "__VITE_ASSET__2AM7_y_e__ 1440w, __VITE_ASSET__2AM7_y_f__ 960w"; | ||
const __DECLARED_ASSET_3__ = "__VITE_ASSET__2AM7_y_g__"; | ||
|
||
export default function Inline_module_vars($$payload) { | ||
$$payload.out += `<picture><source${$.attr("srcset", __DECLARED_ASSET_0__)} type="image/avif"> <source${$.attr("srcset", __DECLARED_ASSET_1__)} type="image/webp"> <source${$.attr("srcset", __DECLARED_ASSET_2__)} type="image/png"> <img${$.attr("src", __DECLARED_ASSET_3__)} alt="production test" width="1440" height="1440"></picture>`; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<svelte:options runes={true} /> | ||
|
||
<script module> | ||
const __DECLARED_ASSET_0__ = "__VITE_ASSET__2AM7_y_a__ 1440w, __VITE_ASSET__2AM7_y_b__ 960w"; | ||
const __DECLARED_ASSET_1__ = "__VITE_ASSET__2AM7_y_c__ 1440w, __VITE_ASSET__2AM7_y_d__ 960w"; | ||
const __DECLARED_ASSET_2__ = "__VITE_ASSET__2AM7_y_e__ 1440w, __VITE_ASSET__2AM7_y_f__ 960w"; | ||
const __DECLARED_ASSET_3__ = "__VITE_ASSET__2AM7_y_g__"; | ||
</script> | ||
|
||
<picture> | ||
<source srcset={__DECLARED_ASSET_0__} type="image/avif" /> | ||
<source srcset={__DECLARED_ASSET_1__} type="image/webp" /> | ||
<source srcset={__DECLARED_ASSET_2__} type="image/png" /> | ||
<img src={__DECLARED_ASSET_3__} alt="production test" width=1440 height=1440 /> | ||
</picture> |
Uh oh!
There was an error while loading. Please reload this page.