-
Notifications
You must be signed in to change notification settings - Fork 31
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
Proposal: Support a local:
attribute prefix
#59
Conversation
|
I may be missing some context, but coming in fresh to Astro here are my initial thoughts/expectations:
|
Even though we should prioritize DX over what is easier to implement, I think it’s worth considering that there isn’t a mechanism to support a feature like this in Rollup/Vite at the moment and we’d be forging our own path here. I have open questions about how we could handle this URL scheme in CSS, things like the I would have a lot fewer questions and concerns with a |
Hey @sgruenholz2, I appreciate the feedback. I’ll do my best to address your points.
I feel the same way. I believe others do, too. However, after many conversations I’m convinced we are, at the very least, not a super-majority. 😅
Well, that kinda seems like another
The prior approach has been In a prior proposal I did suggest something like this: ---
import Kitten1x from './my-kitten.avif' assert { type: "url" }
import Kitten2x from './[email protected]' assert { type: "url" }
import linkToScript from './script.js' assert { type: "url" }
--- However, there was still a significant desire to keep links within HTML, which in fairness is how HTML intended it 1. I also bring up "fatigue" in this RFC, because import statements introduce this by requiring authors to come up with names for any asset they’ll want to use, and possibly yet another naming scheme for assets in general. |
Love the exploration happening here, but agreed with other comments here that this takes a step away from previous iterations of this feature in ways that are definitely concerning from a complexity perspective. I'm a bigger fan of the smaller-scoped, more explicit |
This RFC will be updated with the following changes:
|
local:
attribute prefix
LGTM based on notes! For the record books: I'd still love to bikeshed the final client directive name in the implementation RFC (slight preference for Also: is there any reason that you're saying "attribute prefix" instead of "client directive"? Do we need a new term for client directives that can dynamically be applied to any |
The name We didn’t spend much time discussing how the URL is transformed on the call (outside that it would append The intended behavior is to match how one would normally reference the value, so that If the name were <!-- THIS WON’T WORK -->
<link resolve:href="@csstools/normalize.css" type="stylesheet" /> I realize this wasn’t already written down because the earlier proposal made the scheme very clear, sort of like I also realize the lack of scheme may introduce other issues, since it may be unclear to authors that the magic doesn’t include us covering for things some might consider doing the right thing. <!-- THIS WON’T WORK -->
<link import:href="https://unpkg.com/@csstools/normalize.css" type="stylesheet" /> |
If we wanted, we could refer to them as local directives. Thoughts? If there’s consensus, I can use that term. We have a class:list directive. I wouldn’t recommend client directives, since I expect those are focused on a set of features implemented with a |
Let me think about this a bit more, but I'm not sure I agree on the risk vs. reward here. Because we're using
|
To be certain, would you expect this feature to resolve node modules? Currently, as this transformation is static, And for a reference with a leading |
Hi guys, I hope you dont mind me commenting on this, I have bee giving this a fair bit of thought since the call yesterday. I must confess I am torn between the two, its not often I find myself being ambivalent about things, I do not wish to be the one who makes the final decision on this, 😅 |
We may not have expected this feature does the same thing, but I think we can reach consensus on this issue concerning resolution. I recommend that we embrace web platform resolution in Astro HTML, perhaps resembling Deno. I recommend that we do not embrace CommonJS resolution. CommonJS ResolutionIn NodeJS,
Platform Import ResolutionIn JS,
Platform URL ResolutionIn HTML
As Astro blends server-side and client-side functionality, we are caught between these worlds, and others. For example, we support (thru Vite) URLs that are relative to the source file, or relative to the project, or relative to the public directory. Thru Vite and TypeScript, we have also supported aliased URLs. Do we need a resolution unification RFC? I would love to see Astro stick with web platform resolution, except when aliasing is explicitly defined by the project. These would be:
|
After some discussion, we’ll merge this as-is and leave the details to the point of implementation. |
I don't know if I'm too late to the party, but I believe this RFC doesn't address Markdown since there are no attributes to prefix with The main use case I'm interested in is having a colocated image referenced from Markdown, e.g.:
If you have a moment could you provide any pointers, @jonathantneal? I'm having a little trouble finding prior discussion of this and I'm having trouble imagining that anyone likes the current behavior (especially in Markdown)? |
I don’t have pointers, because I believe this RFC is insufficient for Markdown. I believe we should support To be specific, I think we should support And to highlight the restriction, I reject Vite’s current behavior where |
Astro is great (especially given how young the project is) and I have nothing but faith in the process thus far :). I am a little unclear on what you were convinced of and what the future direction is. Is it the merged rfc?
Yeah, that sounds good. I don't even particularly care how we get there or what it looks like exactly as long as the goal of colocation is achieved. Splitting resources between FWIW the biggest head scratcher with the current behavior is how unpredictable the behavior is. This code: ~/src/pages/articles/my-article/index.md: ---
setup: |
import saveReference from './save.png'
---
![Save](./save.png)
<img src={saveReference} /> Gives you (in [email protected]):
|
Summary
This proposal seeks to improve source-relative URL support in Astro files.
Links