Standardize mapping of browser URLs to file paths (for Resource plugins) #949
Labels
alpha.1
discussion
tied to an ongoing discussion or meeting notes
RFC
Proposal and changes to workflows, architecture, APIs, etc
v0.28.0
Milestone
Discussed in #691
Originally posted by thescientist13 August 7, 2021
Overview
As has come up in a couple recent issues which I believe are part a result of the fallout from #520 (changed the ordering of how default plugins run)
graph.json
always returns an ES module #604204
response #690We have a little bit of a conundrum in this particular section of code which does the bulk of the work to resolve URLs in the browser to actual files on disk for the following (in this order)
Basically given the following types of URLs
something.css?type=css
/api/events?query=something
The issues boil down to
fs.readFile('something.css?type=css
)Considerations
Query Params
graph.json
always returns an ES module #604Because of needing to support query params for API calls or appending hints for non-standard ESM, we have two options
barePathUrl
to strip query paramsAlthough solution 2 has been working, it's a bit of a "hidden" API, so not sure if there is enough docs for it, or a better way to handle this. But it avoid downstream plugins from breaking because of the file reading issue.
Resolvers
204
response #690After Greenwood resolvers go first, the results of those never get passed to next plugins, because we always pass the original URL to each resolvers, instead of saying forwarding the results of the node_modules resolver to any other resolvers that may want to reuse that logic.
There is a referenced issue to just forward the resolved URL, which seems fine for now. But there is another issue that to support relative URLs, which helps with things like #689 (comment), we have to make sure that (for example), user workspace resolver ONLY looks in the user workspaceinstead of trying to a node_modules path and reducing it down to something that might actually be in the user's workspace, by coincidence.
Not sure if we need to something like a negative resolve check to make sure user workspace isn't going to inadvertently resolve to some other legitimate resource? Otherwise, we can't always deny all possibilities, like we can since we know about node_modules
The text was updated successfully, but these errors were encountered: