Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

"javascript" worker site is still using webpack #1321

Closed
jdanyow opened this issue May 26, 2020 · 9 comments
Closed

"javascript" worker site is still using webpack #1321

jdanyow opened this issue May 26, 2020 · 9 comments
Labels
sites webpack Issues that involve the `webpack` bundler

Comments

@jdanyow
Copy link

jdanyow commented May 26, 2020

🐛 Bug Report

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:
#1287 (comment)

Environment

  • ubuntu
  • node v13.14.0
  • wrangler 1.9.1
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/*"

Steps to reproduce

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.

@jdanyow
Copy link
Author

jdanyow commented May 26, 2020

Came across this issue:
#954 (comment)

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.

@EverlastingBugstopper
Copy link
Contributor

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

@EverlastingBugstopper
Copy link
Contributor

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...

@ashleymichal
Copy link
Contributor

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.

@ashleymichal ashleymichal added this to the wrangler build milestone May 26, 2020
@ashleymichal ashleymichal added the webpack Issues that involve the `webpack` bundler label May 26, 2020
@mathiasrw
Copy link

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.

@jdanyow
Copy link
Author

jdanyow commented Jun 9, 2020

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.

https://www.npmjs.com/package/@cfworker/dev

@stale
Copy link

stale bot commented Aug 8, 2020

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.

@stale stale bot added the wontfix label Aug 8, 2020
@jdanyow
Copy link
Author

jdanyow commented Aug 8, 2020

This should remain open

@stale stale bot removed the wontfix label Aug 8, 2020
@xortive xortive added the sites label Feb 25, 2021
@xortive
Copy link
Contributor

xortive commented Apr 9, 2021

Closed by #1833

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
sites webpack Issues that involve the `webpack` bundler
Projects
None yet
Development

No branches or pull requests

6 participants