Parcel: Parcel incorrectly converts linked json to Javascript

Created on 20 Jul 2018  路  9Comments  路  Source: parcel-bundler/parcel

馃悰 bug report


Some user agents require a <link /> tag with some actual JSON (not JSON-compatible JS module). Unfortunately there seems to be no way to prevent Parcel from converting it into some JS module nonsense.

馃帥 Configuration (.babelrc, package.json, cli command)

Completely stock Parcel.

馃 Expected Behavior

Parcel should leave the file alone, keeping the json extension, _maybe_ minifying the JSON data itself but nothing more.

馃槸 Current Behavior


Parcel converts the JSON data into a Javascript object and module export and renames the file to .js.

馃拋 Possible Solution


Please stop converting JSON data.

馃敠 Context


Trying to get Chrome to read the manifest.json from the <link rel="manifest" /> tag in an HTML entry point.

馃捇 Code Sample


manifest.json

{
  "foo": "bar"
}
...
<head>
    <link rel="manifest" href="manifest.json" />
</head>
...

馃實 Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.9.7 |
| Node | 8.9.3 |
| npm/Yarn | 5.5.1 |
| Operating System | Alpine Linux (docker) |

Bug Confirmed Bug

Most helpful comment

For manifest you should use .webmanifest as extension though

Chrome's docs specifically want a manifest.json.

All 9 comments

This has been a known bug for quite a while, we basically have to detect where it is being required from and handle it differently for html as js.

For manifest you should use .webmanifest as extension though

For manifest you should use .webmanifest as extension though

Chrome's docs specifically want a manifest.json.

Any workaround for this?

@serranoarevalo Not that I was aware of. I switched to Rollup.

@Qix- Thanks!

Any news here?

You may want to see #501 , I was able to use the workaround. YMMV

You may want to see #501 , I was able to use the workaround. YMMV

I'm guessing you're referring to the parcel-plugin-json-url-loader workaround? This does not seem to be working for me. Still getting .js output. 馃槩

Was this page helpful?
0 / 5 - 0 ratings