Closed danbars closed 4 years ago
Ok, I figured out that cloudflare worker has to be a single file with no dependencies, and therefore you have to package your code before deploying. I copied webpack config from the example folder, and it works. I think it's worth documenting this step in the getting started guide.
Yes, I've been using webpack to package and serverless to deploy. Would be great to add a section in the documentation about how to simply package it to a single file. Not sure if it would be good to have a look at Wrangler as well?
After failing to use serverless due to authorization problems (I don't have a zone because I use workers.dev subdomain, and it seem to fail on that), I did fall back to deploy using wrangler. It has type="webpack" in its config file that runs webpack and then deploys. This did work for me.
בתאריך יום ה׳, 12 במרץ 2020, 14:04, מאת Markus Ahlstrand < notifications@github.com>:
Yes, I've been using webpack to package and serverless to deploy. Would be great to add a section in the documentation about how to simply package it to a single file. Not sure if it would be good to have a look at Wrangler https://github.com/cloudflare/wranglerl as well?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/markusahlstrand/cloudworker-proxy/issues/46#issuecomment-598150016, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOVDO27ZPT5VZQKK6AKEZDRHDFWFANCNFSM4LGF6IWA .
@danbars Would you like to add some more documentation to make this clearer or could I go ahead and close this issue?
Hi, I'm trying to use a worker with the example copied exactly from the README, and I get the error
Uncaught ReferenceError: require is not defined
I tried to change that to import statement
import Proxy from 'cloudworker-proxy'
and I get the errorUncaught SyntaxError: Cannot use import statement outside a module
I'm probably doing something wrong, I just can't figure out what. It's a clean project with just cloudworker-proxy npm-installed and the index.js copied from the readme.
Thanks