mhart/aws4fetch

Incorrect example for CF Workers

bryzgaloff opened this issue · 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?

mhart commented

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

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

mhart commented

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

I've proposed #11, please see.