miniflare icon indicating copy to clipboard operation
miniflare copied to clipboard

miniflare does not honor `wrangler` lookup for `package.json`

Open jtarchie opened this issue 3 years ago • 1 comments

When I tested with miniflare, the package.json was read at the root directory of the package, not from the `entry-point.

The wrangler.toml had the following config:

[site]
bucket = "./public"
entry-point = "./dist"

The package.json:

{
  "main": "./dist/worker.js"
}

When I performed a wrangler publish, I received an error that the ./dist directory did not have a package.json.

✨  Build completed successfully!
🌀  Created namespace for Workers Site "__fingerprint-workers_sites_assets"
✨  Success
🌀  Uploading site files
Error: Your JavaScript project is missing a `package.json` file; is `/Users/me/workspace/fingerprint/./dist` the wrong directory?

Expected:

miniflare would have the same lookup path for the package.json when the entry-point is configured.

jtarchie avatar Mar 29 '22 03:03 jtarchie

Hey! 👋 Thanks for raising this. Looks like wrangler uses the entry-point as the package directory if [site] is defined: https://github.com/cloudflare/wrangler/blob/6408b15a4961d0bfa3934d76a540e2d1929f8c6d/src/settings/toml/target.rs#L44 Interestingly, this appears to default to workers-site if a bucket is defined without an entry-point: https://github.com/cloudflare/wrangler/blob/881a22984c98730a87d69ef7f3a855b74f76822e/src/settings/toml/site.rs#L38 We should probably be following this behaviour though. 👍

mrbbot avatar Apr 03 '22 16:04 mrbbot

Hey! 👋 I'm going to close this as it's unlikely we'll have time to fix this in Miniflare 2. Our development effort is primarily focused on version 3. I'd recommend you use npx wrangler dev for development instead. 👍

mrbbot avatar Nov 07 '23 15:11 mrbbot