I'm using the javascript type in my wrangler.toml but wrangler still runs webpack on my script.
There are similar issues where folks from Cloudflare have stated this would be a bug:
https://github.com/cloudflare/wrangler/issues/1287#issuecomment-631097951
name = "xxxx-dev"
type = "javascript"
zone_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
account_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
route = "dev.xxxx.com/*"
workers_dev = false
[site]
bucket = "./packages/public/dist"
entry-point = "./packages/worker"
# :point_up: this folder has a package.json with "main":"dist/index.js" (already bundled with rollup)
[env.staging]
name = "xxxx-staging"
route = "staging.xxxx.com/*"
[env.production]
name = "xxxx-production"
route = "xxxx.com/*"
wrangler publish results in the following output:
✔ ~/repos/xxxx [master L|…1]
22:27 $ wrangler publish
Built successfully, built project size is 13 KiB.
Using namespace for Workers Site "__xxxx-dev-workers_sites_assets"
Success
Deployed to the following routes:
dev.xxxx.com/* => stayed the same
A new folder is added under my existing ./packages/worker folder. The new folder is called worker and contains a single file, script.js with what appears to be the result of webpacking my packages/worker/dist/index.js file.
I expected wrangler to publish my packages/worker/dist/index.js file as-is, and not create a new folder.
Came across this issue:
https://github.com/cloudflare/wrangler/issues/954#issuecomment-567858596
And this:
https://github.com/cloudflare/wrangler/blob/master/src/settings/toml/manifest.rs#L181-L185
Would it be possible to remove these lines? My script has a custom static asset handler, I only need wrangler to do the KV portion of site publishing.
ooooooo - now i see why it would do this. We use webpack for Workers Sites because the worker itself imports packages and we need to combine those packages into a single script.
I can totally see how this is confusing and I don't think we document this anywhere. That being said I don't think there's any way to get it to _not_ use webpack for Workers Sites given the constraints.
cc @ashleymichal - would love your thoughts on this one
your use case is interesting though - i guess if you have your own custom static asset handler it feels like it should be possible to override...
i'm going to pull this under the wrangler build milestone, since it's again about giving control to users over their build. i'll be writing an RFC for that this week.
We use webpack for Workers Sites because the worker itself imports packages and we need to combine those packages into a single script.
If you document what to include and add the option "type": "raw" users can have whatever crazy pipeline they want and include the needed files them selfs.
As a workaround I've created a CLI for local development of workers using headless chrome to simulate the workers runtime. It supports sites, HTMLRewriter, the cache, etc.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This should remain open
Most helpful comment
i'm going to pull this under the wrangler build milestone, since it's again about giving control to users over their build. i'll be writing an RFC for that this week.