-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Paths to assets incorrect when importer bundle isn't in root directory. #4172
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
Comments
Your setup in the zip: <script type="module">
import "./index.js";
</script> // index.js
import("./lib.js")
// lib.js
export default "foo"; The HTML asset is transformed and a child asset is generated for the inline JS asset (which gets a path like I think inline assets shouldn't get named by a |
That makes sense. There is no point in namers naming bundles that are never written somewhere. If they need to have a temporary name for processing then you proposal of some function of the name of the parent asset seems good. |
I think it doesn't have to be a real hash. |
Just confirming that bug is still present on 2.8.3. |
This bug is still present on 2.14.1. I've updated the example to be compatible with the new version and simplified it a bit. I also believe that this is a much larger problem than just custom namers. It seems that any file in a subdirectory will have the wrong paths. Here is an example with no plugins and no custom config at all:
npx parcel build index.html subdir/index.html % npx parcel build index.html subdir/index.html ✨ Built in 547ms dist/index.html 542 B 73ms dist/parcel-subdir-bug.b51dd9c4.js 302 B 29ms dist/subdir/index.html 542 B 97ms
(Note: The root HTML file isn't necessary but I wanted to make sure it wasn't some root-finding issue.) Full example: parcel-subdir-bug.zip So it seems that directories in general are pretty broken, at least for inlined assets. I think this would also be fixed by the proposed solution of using the name of the parent asset for inline assets (or at least something in the same directory). |
Uh oh!
There was an error while loading. Please reload this page.
🐛 bug report
When a namer puts different files in different directories import paths between the files are incorrect.
🎛 Configuration (.babelrc, package.json, cli command)
See the attached setup with a trivial namer and some basic files.
parcel-namer-bug.zip
🤔 Expected Behavior
The import statement should reference a file that exists. (
./a/4e3b3082.js
)😯 Current Behavior
The import statement references a file that doesn't exist.
🔦 Context
It is unclear where this reference is being generated relative to. Because if you change the namer to put entires into a subdirectory and other files in the root it generates the exact same path for the import. (the proper path would be
../{hash}.js
)💻 Code Sample
Namer code (also in zip):
🌍 Your Environment
The text was updated successfully, but these errors were encountered: