You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Developers and the bundler know that img is an asset in import img from './myimg.png';. However, the Svelte compiler does not know this, which limits the ability to inline it into the template and otherwise optimize it. The fact that it's an asset means it has a few key properties: it is a string, it is always defined, it is immutable, and it is the same on server and client so does not affect hydration.
Describe the proposed solution
Four options:
Harcode knowledge that .png, .jpg, .svg, etc. file extension represents an asset. This is probably a pretty safe assumption an would minimize API surface area. It's not the ideal long-term solution, but would be a quick win in terms of reducing the output file size
A compiler option such as isAsset. The bundler can provide a function which Svelte can call to determine whether an import URL is an asset. This is still relatively easy to implement, but introduces an API that may eventually be obsoleted by some more general API. I think this is okay as we could deprecate it when that time comes and as it's just an optimization is easy to ignore any value passed in that manner
Describe the problem
Developers and the bundler know that
img
is an asset inimport img from './myimg.png';
. However, the Svelte compiler does not know this, which limits the ability to inline it into the template and otherwise optimize it. The fact that it's an asset means it has a few key properties: it is a string, it is always defined, it is immutable, and it is the same on server and client so does not affect hydration.Describe the proposed solution
Four options:
.png
,.jpg
,.svg
, etc. file extension represents an asset. This is probably a pretty safe assumption an would minimize API surface area. It's not the ideal long-term solution, but would be a quick win in terms of reducing the output file sizeisAsset
. The bundler can provide a function which Svelte can call to determine whether an import URL is an asset. This is still relatively easy to implement, but introduces an API that may eventually be obsoleted by some more general API. I think this is okay as we could deprecate it when that time comes and as it's just an optimization is easy to ignore any value passed in that mannervite-plugin-svelte
could do some preprocessing to turn imports into constants so that they can be inlined in the templatesImportance
nice to have
The text was updated successfully, but these errors were encountered: