You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support file URL resources in command line environment (#34)
## Motivation for the change, related issues
In #25, we want to ship a wp-cli.phar and wordpress-importer.zip with
the Blueprints library in order to eliminate hard-coded references to
the Playground web app (That way, we can host a private Playground
without reference to the public one). In addition, it's probably better
to just version the binary dependencies along with the library.
But this made existing code and tests awkward:
We want to reference a wp-cli.phar shipped with the Blueprints lib but
need to reference it differently depending on whether the Blueprints lib
is running on the command line or in a browser.
It turns out we can use the same resource type to do both if we base
wp-cli.phar URLs on `import.meta.url`. In a browser environment, it is
an http(s):// URL, and in Node.js, the it is a file:// URL. In both
cases, Vite is able to make sure public asset URLs based on
`import.meta.url` are properly set.
## Implementation details
This PR updates the FetchResource abstract type to be able to resolve
data when the specified URL is a file:// URL and the module's URL is
also a file:// URL (indicating a runtime that is loading from local FS).
## Testing Instructions (or ideally a Blueprint)
- Added test for file URLs.
- CI
0 commit comments