Dotty hook for embedding auto-external resources (framework-specific) like in Vite.js/Turbopack and other JS bundlers #25136
MatheusDS4
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Basically in Vite.js you can
import, say, PNGs, and the bundler will decide whether to externalize the resource (e.g. return a URL pointing to an externally-loaded PNG) or to return adata:URL that is embedded in the program (e.g. if the file is too short).Although, in actual TypeScript this is kind of boring as there is no
import.sync()there for inline usage.The motivation is that resources (as in
src/main/resources) will both, e.g. appear in the Scala.js bundle (so it can accumulate a lot of heavy icon bitmaps (in case they use skeumorphic design and not SVGs (I know, gradients may help, but those may be a little more complex))). and will also be loaded inconditionally.In Scala I wanted something like an
Embed("flower.webp")expression, and also extra syntaxes for other use-cases like embedding resources normally (text or octet stream, at the entire-program-lifetime and at the .class/JAR/.js) as an extra convenience compared tosrc/main/resources.Also, I know, I know; Next.js's default
importdoes blur optimization so that resulting modules aren't URLs but objects containing a regular source and a blurry source (for preview purposes). I don't know if this is important at all, but in any case, there could be another syntax for this in the future...Beta Was this translation helpful? Give feedback.
All reactions