Skip to content
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

perf: inline module variables into template #13075

Merged
merged 8 commits into from
Sep 13, 2024
Merged

perf: inline module variables into template #13075

merged 8 commits into from
Sep 13, 2024

Conversation

benmccann
Copy link
Member

@benmccann benmccann commented Aug 29, 2024

ref #12995

helps with sveltejs/kit#12627

based off #10015, but this one only does inlining and no hoisting

Copy link

changeset-bot bot commented Aug 29, 2024

🦋 Changeset detected

Latest commit: 346a8c5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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";
Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Member Author

@benmccann benmccann Sep 11, 2024

Choose a reason for hiding this comment

The 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

Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

Choose a reason for hiding this comment

The 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

Copy link
Member

@paoloricciuti paoloricciuti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering #13048 was reverted in #13132 Rich said

We can worry about a more sophisticated fix when we get round to the work that #13048 was designed to enable.

do we need to tackle this more sophisticated work now?

@benmccann
Copy link
Member Author

Before merging it, Simon updated #13132, so that it didn't revert your PR but implemented the more sophisticated fix you're talking about

@paoloricciuti
Copy link
Member

Before merging it, Simon updated #13132, so that it didn't revert your PR but implemented the more sophisticated fix you're talking about

Uh completely missed the discussion, sorry

Copy link
Member

@paoloricciuti paoloricciuti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If @dominikg is ok with moving the enhancement to a later point this LGTM!

@dominikg
Copy link
Member

separate PR is fine, but it should be on the short list. these extra consts and the interpolation are not for free and we should strive to merge as much as possible into static strings

@benmccann
Copy link
Member Author

I've filed an issue to track it: #13233

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants