-
Notifications
You must be signed in to change notification settings - Fork 734
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
RFC: Static Assets with Workers #1162
Comments
Thank you for addressing this. I've been struggling with this while trying to figure out how to use the platform with a module-based worker despite the documentation around doing so not being 100%. It's more complicated than I would hope for (it's a simple, public repo if you're interested), but I love what you're doing as a company so I'm happy to help. As members of the WinterCG, is your intent to consider what Deno Deploy is doing here too, or are you just collecting ideas? I don't want to clutter the thread up with text that is unwarranted. |
Yeah I personally feel the pain when using Workers Sites, so I've got my own motivation for making this dead simple to use :) I definitely want this to become a discussion among runtimes. Specifically, with Plan 2 (imports), the idea is that it (or whatever it becomes) would be the interface for developers who wish to serve static files, and Deno's |
btw, have you tried Happy to see your repo too! Is it this one? https://github.com/mangs/homepage-solid This seems like a good fit. |
That's the one! Thank you for taking a look. I'll try that out and report back. As for the topic proposal, it seems like some combination of Plan 1 (to actually upload the assets using wrangler) and Plan 2 (to optionally handle the assets) will be required. However, I'd like to propose a Plan 5 to better enable isomorphic applications built on edge-rendered platforms when exact asset paths are known ahead of time. Plan 2 uses a Webpack-like "magic" string to create a fetching function, and considering your interest in potentially standardizing this functionality got me thinking of the Import Assertions and CSS Modules standard proposals which work similarly. Supporting those directly would be really helpful especially for the inevitably increasing number of folks who will learn about import assertions on the frontend; offering web-first compat here could be an easy onramp for new users. Perhaps Plan 2 could benefit from import assertions too to remove the Webpack-like query params and instead offer more direct key-value configuration parameters. Thinking out loud here: import { fetchAssets } from "path/to/bucket" assert { type: "assets", include: 'glob', exclude: 'glob }; using Curious of your thoughts. EDIT: I just re-read your first reply; dunno how I missed your mention of import assertions 🙃 |
I've been messing around with |
Hence the experimental prefix haha. |
Understood, I'll keep my eye on this as it develops. Thank you for sharing this new feature! |
We've talked about it before, but just so it's documented here, I think my vote would be for an option 2 and 4 combo. Importing When Pages Plugins launched, we also launched static asset importing that looks like this: export { onRequest } from 'assets:../public'; It would be pretty easy to also support a regular Serving Serving like Pages does means you adopt our routing conventions (e.g. Local dev would just be done by pointing to your folder, but when you actually publish, you could essentially run We could have a Pages project for:
The one concern about 2 & 3 is that we've recently had to demote the performance of non-aliased traffic (i.e. deployments that you directly access at We could explore hiding these projects from a user in the dash if that made sense. |
Potentially related https://github.com/tc39/proposal-import-reflection |
That's really interesting. Similar to the Twitter feedback so far, I'm surprised it's a string and not following the options object formatting like import assertions and CSS modules. Luca makes a good point that it's still early stages and they're collecting feedback about its use, but I'm still surprised they didn't start there to align with the existing drafts that are farther along. Seemingly oddly enough, that's how dynamic imports work in the proposal. I'm interested to learn more. |
This adds support for defining `assets` in `wrangler.toml`. You can configure it with a string path, or a `{bucket, include, exclude}` object (much like `[site]`). This also renames the `--experimental-public` arg as `--assets` (and adds `--assets-include and `--assets-exclude` for parity with Sites. Via #1162
This adds support for defining `assets` in `wrangler.toml`. You can configure it with a string path, or a `{bucket, include, exclude}` object (much like `[site]`). This also renames the `--experimental-public` arg as `--assets` (and adds `--assets-include and `--assets-exclude` for parity with Sites. Via #1162
I was just thinking out loud how it's cool how it's almost possible to deploy a static eleventy site in 3 commands: echo '# Page header' > README.md
npx @11ty/eleventy
npx wrangler publish --assets _site I'm thinking if an Folks can of course provide their own worker script if they'd like, but I'm thinking it shouldn't be a requirement any more. |
This adds support for defining `assets` in `wrangler.toml`. You can configure it with a string path, or a `{bucket, include, exclude}` object (much like `[site]`). This also renames the `--experimental-public` arg as `--assets` (and adds `--assets-include and `--assets-exclude` for parity with Sites. Via #1162
This adds support for defining `assets` in `wrangler.toml`. You can configure it with a string path, or a `{bucket, include, exclude}` object (much like `[site]`). This also renames the `--experimental-public` arg as `--assets`. Via #1162
This adds support for defining `assets` in `wrangler.toml`. You can configure it with a string path, or a `{bucket, include, exclude}` object (much like `[site]`). This also renames the `--experimental-public` arg as `--assets`. Via #1162
This adds support for defining `assets` in `wrangler.toml`. You can configure it with a string path, or a `{bucket, include, exclude}` object (much like `[site]`). This also renames the `--experimental-public` arg as `--assets`. Via #1162
This adds support for defining `assets` in `wrangler.toml`. You can configure it with a string path, or a `{bucket, include, exclude}` object (much like `[site]`). This also renames the `--experimental-public` arg as `--assets`. Via #1162
This adds support for defining `assets` in `wrangler.toml`. You can configure it with a string path, or a `{bucket, include, exclude}` object (much like `[site]`). This also renames the `--experimental-public` arg as `--assets`. Via #1162
It's not clear what's the difference between |
@Vladi-ed |
Closing this for now since |
@penalosa did you remove the experimental warning? What is the decision on the rest of the action points? |
This one is pretty straightforward. As a website developer, I would like to serve "static" assets on the internet. These are not user generated content, but usually stuff like html file, logos, maybe some images, etc.
The current options are:
[site]
inwrangler.toml
) and code (configuring@cloudflare/kv-asset-handler
). It's incredibly fragile and not particularly liked by the community. It's backed by KV. It also has issues with consistency since there's no efficient way to expire assets, so during deploy it's possible that some assets just 404. It was the only thing folks had for a while.@cloudflare/kv-asset-handler
should still get security updates and bugfixes, but we shouldn't add any new features, and guide people towards newer solutions.--experimental-public <path>
: Exists in wrangler2. Backed by KV and kv-asset-handler, but the implementation is not exposed to the user. Light on features. Faces the same 404 issue as Sites. Particularly nice because it's "zero config"Plan 1:
--assets <path>
--experimental-public
to--assets
--assets <path1> --assets <path2>
)wrangler.toml
asassets
{ bucket: <bucket>, include: <glob>, ... }
Plan 2: imports
Plan 3: File loader
Adds a new type to
rules
configPlan 4: Integrate Pages
We should come up with a plan to integrate Pages for assets directly into a wrangler project
Open questions:
The text was updated successfully, but these errors were encountered: