Conversation
1000hz
left a comment
There was a problem hiding this comment.
It seems like it would be better for each snippet to be self-contained (i.e. no importing from lib, also include the addEventListener()) so that the file contents are mirrored 1:1 when these snippets get copied over to the docs.
I think that optimizing for pulling down all of the snippets from the template gallery using wrangler generate is less important than making it easy to keep the docs in sync with the snippets in this repo. In practice, I don't suspect people will be generating a project with every snippet very much since they're more likely to generate a project using one of the other actual boilerplates and copy the few snippets they need from the docs. By keeping the snippets here 1:1 with the code that ends up in the template gallery, you can just edit a snippet in one place and then copy/paste the whole file into the other repo, as opposed to having to make the same edit in both places.
| "singleQuote": true, | ||
| "semi": false, | ||
| "trailingComma": "es5", | ||
| "tabWidth": 4, |
There was a problem hiding this comment.
People typically use "tabWidth": 2 in the JS community (in my experience). This is also the default value for this option, so it might be better to omit this.
There was a problem hiding this comment.
I'd also enforce trailingComma: all because it eliminates the time spent and annoying compilation errors that arise from missing commas.
| #### Wrangler | ||
| To generate using [wrangler](https://github.com/cloudflare/wrangler) | ||
|
|
||
| To generate using [wrangler](https://github.com/cloudflare/wrangler) on a brand new project with all the included snippets. |
There was a problem hiding this comment.
Grammar here is a lil weird. What do you think about changing to:
You can use wrangler to generate a new project including these snippets with the following command:
| Examples of making fetch requests from within your Worker script including: | ||
|
|
||
| [`index.js`](https://github.com/cloudflare/worker-template-fetch/blob/master/index.js) is the content of the Workers script. | ||
| - Generating JSON post requests then reading in the resulting response body |
There was a problem hiding this comment.
"post" should probably be capitalized here (as GET is below). Maybe rewrite as:
Generating POST requests then reading in the resulting response body as JSON
Good point. One of the best examples of this philosophy is material-ui. If we adapted the super-developer-friendly material-ui approach, we would maintain an open-source library called |
This is the new format of the templates for "snippet" templates that I plan to follow. Before the code was like a skeleton/boilerplate.
For some background, snippets are templates that are not necessarily boilerplates like
wrangler generate..(though this combination of 3 snippets technically makes up one boilerplate - sorry if that was terribly confusing) but the more common use case is for copy-pasting the same snippet of code.Please be as strict as possible the more nits the merrier here 😅