Cloudflare Worker Example
iosdeveloper opened this issue Β· comments
Running OS
macOS 13.5.2
Running Node Version
16.19.1
Description
Trying to run examples/cloudflare-worker/webpack5.x using npm run example
fails.
Expected behavior
Local server successfully starts
Steps to reproduce
Execute npm run example
:
> cloudflare-worker@0.0.0 example
> npx wrangler dev --ip 0.0.0.0
β
οΈ wrangler 3.10.0
-------------------
wrangler dev now uses local mode by default, powered by π₯ Miniflare and π· workerd.
To run an edge preview session for your Worker, use wrangler dev --remote
β² [WARNING] Processing wrangler.toml configuration:
- πΆ Ignored: "type":
Most common features now work out of the box with wrangler, including modules, jsx,
typescript, etc. If you need anything more, use a custom build.
- Deprecation: "zone_id":
This is unnecessary since we can deduce this from routes directly.
- The "route" field in your configuration is an empty string and will be ignored.
Please remove the "route" field from your configuration.
- Deprecation: "build.upload.format":
The format is inferred automatically from the code.
Running custom build: npm run build
> cloudflare-worker@0.0.0 build
> npx webpack --config webpack.config.mjs
asset worker.js 751 KiB [compared for emit] [minimized] [big] (name: main) 1 related asset
runtime modules 891 bytes 4 modules
modules by path ./node_modules/ 1.22 MiB
modules by path ./node_modules/node-forge/lib/*.js 820 KiB 42 modules
modules by path ./node_modules/passkit-generator/lib/ 63.8 KiB 19 modules
modules by path ./node_modules/readable-stream/ 95.5 KiB 14 modules
+ 14 modules
asset modules 218 KiB
../../models/exampleBooking.pass/icon.png 2.69 KiB [built] [code generated]
../../models/exampleBooking.pass/icon@2x.png 4.71 KiB [built] [code generated]
../../models/exampleBooking.pass/footer.png 32.2 KiB [built] [code generated]
+ 2 modules
+ 6 modules
WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
worker.js (751 KiB)
WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
main (751 KiB)
worker.js
WARNING in webpack performance recommendations:
You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.
For more info visit https://webpack.js.org/guides/code-splitting/
webpack 5.70.0 compiled with 3 warnings in 4566 ms
β Starting local server...
service core:user:pg-cw-example-webpack5: Uncaught TypeError: n.default.binary is not a function
at core:user:pg-cw-example-webpack5:11501:96 in 5597
at core:user:pg-cw-example-webpack5:13260:19 in r
at core:user:pg-cw-example-webpack5:11536:306 in 4433
at core:user:pg-cw-example-webpack5:13260:19 in r
at core:user:pg-cw-example-webpack5:11115:50 in 2911
at core:user:pg-cw-example-webpack5:13260:19 in r
at core:user:pg-cw-example-webpack5:11163:91 in 7050
at core:user:pg-cw-example-webpack5:13260:19 in r
at core:user:pg-cw-example-webpack5:11477:15 in 8119
at core:user:pg-cw-example-webpack5:13260:19 in r
β [ERROR] MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above.
Were you able to verify it by using (and changing) the examples?
Yes
If yes, which changes did you apply?
Fix missing entry-point error by adding this line to wrangler.toml:
main = "dist/worker.js"
Other details
- I'm available to open a Pull Request to resolve the problem (after the triage)
Since this example is quite old, is there a better way to install this project in Cloudflare Worker?
Hey @iosdeveloper, thanks for using passkit-generator!
Well, I guess something might have changed. I'll take a look and update it.
Thanks for your pointer!
Since this example is quite old, is there a better way to install this project in Cloudflare Worker?
I honestly don't know. I do not work with Cloudflare Workers. I barely used them to create the example when a guy shared their existence with me.
I'll keep you posted about this.
Hi @iosdeveloper, 34a12e3 brings the new reworked cloudflare workers example.
I've removed the two examples there were before as they were completely outdated as you found out. I'd like to thank for reporting me this.
I've been able to run the worker locally without any issue, but I haven't tested a deployed version.
Let me know what do you think of this!
P.s. if you could leave a β on the project, that would be awesome!
It works! Thank you so much. π
Already did π