aws4fetch icon indicating copy to clipboard operation
aws4fetch copied to clipboard

Incorrect example for CF Workers

Open bryzgaloff opened this issue 5 years ago • 4 comments

I am new to CF Workers so decided to first create an issue rather than creating a PR with changes to docs. When I try to run your example I get: SyntaxError: Cannot use import statement outside a module

I have tried running it with wrangler preview and only have seen en example.com page without any activity from my worker. Same for wrangler dev. Am I doing it right and is the problem correctly stated?

bryzgaloff avatar Apr 05 '20 13:04 bryzgaloff

You need to make sure you're compiling for ES modules

I'm not sure what the state of wrangler is these days for compilation. It looks from the docs like you might need to set type = "webpack" in your wrangler.toml

I just use rollup in the example:

https://github.com/mhart/aws4fetch/tree/master/example#bundling-and-deploying

mhart avatar Apr 05 '20 14:04 mhart

You are right: setting type to webpack works. I think you'd better clarify it in the example.

bryzgaloff avatar Apr 05 '20 22:04 bryzgaloff

The example doesn't mention wrangler though. The example should work just as documented

mhart avatar Apr 05 '20 22:04 mhart

I've proposed #11, please see.

bryzgaloff avatar Apr 05 '20 22:04 bryzgaloff