Skip to content

deno-embedder v2 #21

@NfNitLoop

Description

@NfNitLoop

The release of Deno v2.4 brings a lot of deno-embedder's features to Deno. 🎉
https://deno.com/blog/v2.4

The first two bullet points in the announcement are:

  • deno bundle
  • Importing text and bytes

These are two things deno-embedder (and its ESBuild plugin) were built to provide. I'm glad these are now built-in!

For simple use cases, where you just need a few files embedded into your package, you probably don't need deno-embedder. But, I think there's still a value-add to the API deno-embedder provides:

  • A "directory" interface for accessing embedded files.
    • Gives a single location to see all embeds.
    • Nice type-safe access to embeds by name.
    • option to list all embeds, or access them dynamically (ex: based on the path of a web request).
    • Can lazily load embeds as they're needed, instead of at module initialization (i.e.: application startup) time. (You can do this w/ SADIs directly, but the syntax is noisy, so it's going to be handy to have a single place to handle all that for you.)
  • Optional/automatic compression of embedded assets.
    • Reduces file size.
    • (depending on usage patterns) may reduce memory usage.

So I've been brainstorming about what I might want to accomplish in a major v2 release. Here's my list so far:

  • Deprecate the ESBuild plugin and create a plugin to delegate to deno bundle --platform=browser.
  • Continue to generate the dir.ts, but update it to support different modes:
    • Simple mode: Just add async on-demand statically-analyzable dynamic imports (SADIs) to embedded files, but use the new text/bytes import mechanism.
    • Compression mode: Generate compressed copies of files before embedding them. (Transparently decompressing them when they're read at runtime.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions