parcel: ๐ Problem with loading manifest.json
๐ Bug report
While building or running in dev mode with parcel, if I include manifest.json in html, then parcel returnโs me .js file path.
๐ค Expected Behavior
<link rel="manifest" href="/dist/manifest.json">
๐ฏ Current Behavior
<link rel="manifest" href="/dist/05bfa35095e6bfacdb8b334d1023872b.js">
๐ Your Environment
Software | Version(s) |
---|---|
Parcel | 1.2.0 |
Node | node 8.9.2 |
npm/Yarn | yarn 1.3.2 |
Operating System | macOS Sierra 10.12.6 |
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 47
- Comments: 29 (9 by maintainers)
Commits related to this issue
- Prevent manifest.json getting converted to a JS file by Parcel This caused the PWA to open in a full browser on iOS - Rename manifest.json to manifest.webmanifest (https://github.com/parcel-bundler/... — committed to akshaysmurthy/home-pwa by akshaysmurthy 6 years ago
- wip: rename manifest.json file Given the discusison here: https://github.com/parcel-bundler/parcel/issues/235 This needs to be done for parcel not to rename it as a json file refs #82 — committed to LonnyGomes/covid-sankey-vizualization by LonnyGomes 4 years ago
Parcel will have to process the file as it may contain links to assets (images mostly).
Did you try
<link rel='manifest' href='/src/manifest.webmanifest'>
. This is supposed to work.@aminnairi Yep, thatโs what I did too. Mine is now named
manifest.webmanifest
and it works.Thanks for reporting this ๐
It looks like you have a mistake in your code. Instead of using the path to the
manifest.json
indist
, you should be setting the path to your originalmanifest.json
, and Parcel will handle transforming it to the correct path withindist
.You should be doing something like:
I was using the
manifest.json
naming convention from the Google Web App Manifest documentation. While MDN was using themanifest.webmanifest
naming convention. Using the later solved the issue (which was Parcel.js converting themanifest.json
to a javascript file). Hope this helps!Still encountering this bug in June 25, 2021
@devongovett @DeMoorJasper hey! Just wanted to drop a quick note here for parcel v2. In talking to some friends at Google, itโs important for how browsers handle web manifests specifically that the final filename stays the same between builds.
Otherwise itโs interpreted as a different app, somehow. Maybe @slightlyoff or @addyosmani can elaborate a bit.
In order to work around this Iโve had to do some HTML manipulation after the fact to inject the manifest.
I just wanted to drop note in hopes that there would be some way to control the final filename in v2.
Thanks for all your work on Parcel! โค๏ธ
This is expected bahaviour looking at the code but in reality shouldnโt happen, marked this as bug
With all the years of experience Iโve had thinking about these graph problems while implementing Assetgraph, I can tell you that you wonโt be able to infer from the asset alone what format you need to keep it in. Knowing the parent type will only be enough in the most naive cases as well. What you need is a model that also keep the information of what type of relation is between these two assets.
In Assegraph each way any asset can refer to a different asset is modelled as different relation type. This information has turned out to be much more valuable than the assets themselves, as you can infer a lot of things from the relation types alone. Itโs especially valuable when you start to traverse the graph for processing.
In this single case you might be able to hack it with a condition that excludes json files linked from html from being interpreted as js. But a bit further in the future you might want to cover the case where
fetch('data.json')
is picked up as a file reference, and the application logic of runtime json loading would fail if the file changes extension as well.You probably also want to start treating the webmanifest as a separate asset type inheriting from JSON, since it has well defined properties that also describe asset relations.
Ah interesting issue. The
type
needs to bejs
so JSON files can be imported from JavaScript. Ideally the assets could return multiple renditions of different types and the correct one could be chosen based on the parent asset type. Let me think about this a bit and see what I can come up with. If you have suggestions on how this could work let me know!Can confirm this behavior. Any JSON file referenced in html entry is transformed to js module