nfnitloop / deno-embedder Goto Github PK
View Code? Open in Web Editor NEWDev tools for embedding static files into Deno as code.
Dev tools for embedding static files into Deno as code.
A main
function is exported from mod.ts
, but is never run.
As a proof of concept, I created a simple CLI script that wraps the main
function.
Proof-of-concept: https://github.com/ethanthatonekid/deno-embedder-cli#readme
deno run -A https://deno.land/x/embedder_cli/main.ts --mappings="[{\"sourceDir\":\"./.vscode\",\"destDir\":\"./examples/00_vscode\"}]"
ESBuild was easy to set up as a plugin, but it currently has a bug/limitation that re-exports (which are a recommended pattern in Deno deps.ts
files) aren't properly removed by tree-shaking.
Add support for Webpack and/or Rollup to support better tree-shaking.
Additionally:
This is a feature I requested and used in rust-embed: pyrossh/rust-embed#140
Would be nice to have it here too.
The current implementation of Deno Embedder creates a dir.ts
file which imports all files for an embed directory.
This means that if you have a large set of embeds, you pay the cost of loading all of those embeds every time you start your application, even if you're not going to use them all.
It would be great if we could create a files list like:
const files = {
"Smiley.svg": () => import("./Smiley.svg_.ts"),
"index.html": () => import("./index.html_.ts"),
} as const
I thought this new feature would allow using dynamic imports:
https://deno.com/blog/v1.32#deno-compile-support-for-web-workers-and-dynamic-import
However, the current implementation seems limited to binaries built with deno compile
.
deno compile
has access to all dynamic imports without requiring additional permissions.deno install
does not install dynamic imports, and they must be imported from network/disk, by granting extra permissions to do so.deno run
also requires extra permissions to load dynamic imports. (This impacts "dev mode".)My goal for Deno Embedder is for it to "just work" for all these cases, so I'm not going to bother supporting dynamic imports until Deno supports the above cases.
Upstream tracking issues:
As part of a build, it would be nice to be able to re-generate embedded files to make sure they're the most up-to-date versions. (that is: without starting up "dev mode" and then having to kill that server.)
Preferably, there would be an option to also just check that the generated files and return an error if they're not up-to-date.
Right now I just point to the sample repo.
While it does have a lot of comments to help guide users, a proper README guiding through setup would be better. :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.