-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
URL dependencies using variables instead of hard-coded strings have the wrong origin #7643
Comments
Another errant thought -- I wonder whether when |
…l parcel issues While this is broken right now, I'm trying to fix it/commit and move on I've opened an issue in the parcel repo, will wait to hear back: parcel-bundler/parcel#7643
Does it help if you run parcel and @parcel/* at version 2.2? |
Hi @LeoniePhiline -- sorry for the delay; I made a mistake in the original bug report I wrote. I am, indeed, on v 2.2.1 and still experiencing the issues. |
any thoughts/updates on this? |
I'm still stuck with this also. |
The reason this happened is that Parcel replaces And the only special case here (and the intended way) is But I guess there should be a way to express the current bundle url (= what |
If instead of being a bug, this is a feature request to be able to reference the current bundle url (i.e. localhost in dev, baseurl in prod), I would very much like to see that. I think it's important to be able to dynamically reference files. My current workaround is to create a separate file with functions that explicitly create the URLs for assets that I'm seeking to load and then using a switch statement to evaluate which URL should be returned. It...feels pretty brittle, hacky and gross lol. I imagine there might be challenge with doing that and also having parcel analyze the codebase to know which assets to include in the bundle. Maybe it might be possible to have assets that are dynamically referenced be identified in the .parcelrc? |
I am also blocked by this. There really needs to be a way to do this, as it seems like a table-stakes kind of pattern. I would be happy to take a stab at making the change, but I'm not quite sure where to start. I'm also open to a different pattern for getting the same effect, if perhaps there is a more brute-force way to set the image loading rules in my .parcelrc |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. |
🐛 bug report
Hello, I'm having difficulty resolving URL dependencies in a development environment.
Given the finicky nature of debugging URL dependencies, the best I've been able to show here is using a screenshot (see below)
As you can see from the screenshot, I have declared a
path
variable (line 5) through destructuring the props that have been passed down.The value of the
path
variable is'../assets/animations/other_one.webm'
.As the documentation suggests, I tried to pull in video assets I've created a new URL with the
path
variable andimport.meta.url
(using template strings or not) on line 8. As you can see from the URL object's evaluation, the URL's origin value isfile://
, which is incorrect as the file will not be pass .For the sake of being thorough, on line 9 I pass in the path variable without the template string/string interpolation with the same effect.
On line 10, I also try passing in a different path that references a different video format,
../assets/animations/oppose_angle.mp4
, with the same effect.Where things get very strange is on line 13. When I pass the URL constructor the same value as the
path
variable ('../assets/animations/other_one.webm'
), only this time hard-coded, it returns a URL object with anorigin
that ishttp://localhost:1234
which is the expected behavior.The same correct behavior occurs when using a hard-coded version of the mp4's relative path.
🎛 Configuration (.babelrc, package.json, cli command)
here's my
.babelrc
,.parcelrc
, andjson.package
🤔 Expected Behavior
new URL(varName, import.meta.url)
resolves the origin tohttp://localhost:1234
😯 Current Behavior
new URL(varName, import.meta.url)
resolves the origin tofile://
instead ofhttp://localhost:1234
💁 Possible Solution
Not sure how this is working under the hood or even if it's truly a parcel issue, so hard to know for sure.
🔦 Context
I'm trying to serve video assets from my server so that I can perform transformations on those video files and render them within a PIXI.js app.
💻 Code Sample
I'm running my dev server:
and, when I try to resolve the URL, these issues occur.
🌍 Your Environment
The text was updated successfully, but these errors were encountered: