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

🚀 Feature Request: inform VSCode, etc. of JSONC parsing for wrangler.json #7948

Open
Cherry opened this issue Jan 28, 2025 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@Cherry
Copy link
Contributor

Cherry commented Jan 28, 2025

Describe the solution

When initialising a new worker with C3 today, you're given a wrangler.json that looks something like this:

/**
 * For more details on how to configure Wrangler, refer to:
 * https://developers.cloudflare.com/workers/wrangler/configuration/
 */
{
	"$schema": "node_modules/wrangler/config-schema.json",
	"name": "solitary-rice-5b9c",
	"main": "src/index.ts",
	"compatibility_date": "2025-01-24",
	"observability": {
		"enabled": true
	},
	"compatibility_flags": [
		"nodejs_compat"
	]
	/**
   * Smart Placement
   * Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
   */
	// "placement": { "mode": "smart" },
	/**
   * Bindings
   * Bindings allow your Worker to interact with resources on the Cloudflare Developer Platform, including
   * databases, object storage, AI inference, real-time communication and more.
   * https://developers.cloudflare.com/workers/runtime-apis/bindings/
   */
	/**
   * Environment Variables
   * https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
   */
	// "vars": { "MY_VARIABLE": "production_value" },
	/**
   * Note: Use secrets to store sensitive data.
   * https://developers.cloudflare.com/workers/configuration/secrets/
   */
	/**
   * Static Assets
   * https://developers.cloudflare.com/workers/static-assets/binding/
   */
	// "assets": { "directory": "./public/", "binding": "ASSETS" },
	/**
   * Service Bindings (communicate between multiple Workers)
   * https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
   */
	// "services": [{ "binding": "MY_SERVICE", "service": "my-service" }]
}

VSCode (and likely other editors) get very upset at this by default, as .json doesn't support comments by default - only with JSONC flavour parsing.

If I add a .vscode/settings.json with this:

{
	"files.associations": {
		"wrangler.json": "jsonc"
	}
}

VSCode stops screaming and is happy with parsing this is as jsonc. I wonder if it could make sense to ship something like this by default? Or a .jsonc by default for better cross-editor compatibility?

@Cherry Cherry added the enhancement New feature or request label Jan 28, 2025
@isaac-mcfadyen
Copy link
Contributor

I'd +1 the .jsonc by default, I'm not sure other editors like Zod look at the .vscode/settings.json and those other editors are becoming more and more popular.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Untriaged
Development

No branches or pull requests

2 participants