Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect example for CF Workers #10

Open
bryzgaloff opened this issue Apr 5, 2020 · 4 comments
Open

Incorrect example for CF Workers #10

bryzgaloff opened this issue Apr 5, 2020 · 4 comments

Comments

@bryzgaloff
Copy link
Contributor

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
Copy link
Owner

mhart commented Apr 5, 2020

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

@bryzgaloff
Copy link
Contributor Author

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

@mhart
Copy link
Owner

mhart commented Apr 5, 2020

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

@bryzgaloff
Copy link
Contributor Author

I've proposed #11, please see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants