-
Notifications
You must be signed in to change notification settings - Fork 337
JSON files included in the worker script #1719
Comments
I'm not sure to understand how your PR is fixing the issue. Could you please share the invalid generated code (privately by email if you need)? |
@xtuc My PR just fixes the regex that catches Here's the repo with the example. The produced worker script is here and you can see a JSON file included in the worker script (line 23) because it is included in the bucket folder to be served as a static asset. Thanks |
I understand the issue now, thanks. I think just emiting a JSON file won't work, the worker still has to get access to it something. Either you can ask webpack to inline it, which will work, or wrangler needs to upload it. |
Is it okay to filter for Thanks but text blobs don't meet our requirements because we can put a |
The filtering make sense to me. However we need to import the file to be able to use it in the worker. I don't think we should require KV. Text blobs are files attached to the worker, similar to injecting them inline. It looks like it's undocumented right now. I suggest we wait for #1677 which will allow to import JSON files and likely will upload them. |
#1677 Looks great for the issue, we will wait. Thanks 🙏 Feel free to close my PR and the issue if you want 😉 |
We can keep it open. As a workaround for now, you can ask webpack to inline the JSON into your script, which will avoid the buggy codepath in wrangler(js). |
🐛 Bug Report
JSON files are included in the worker script processed by the webpack.
This occurs in the
filterByExtension
function inwranglerjs
because it evaluates to true with thejs
extension passed as an argument and matches forjs
andjson
files.Environment
rustc -V
: 1.49.0node -v
: 14.15wrangler -V
: 1.12.3wrangler.toml
Steps to reproduce
wrangler generate my-project https://github.com/flareact/flareact-template
public
folder to be served as a static assetyarn deploy
What did you expect to see?
The content of the JSON file is not included in the worker's script file.
What did you see instead?
The worker script file includes the content of the JSON file.
EDIT:
Here's an incorrectly generated script file and the attempt to publish it:
The text was updated successfully, but these errors were encountered: