cloudflare / cloudflare/workers-sdk

🐛 BUG: C3's web framework ts detection is broken

Open
#7,495 2 comments 0 reactions 0 assignees View on GitHub
package:c3
Dominant language
TypeScript
Stars
4.5k
Forks
1.5k
Avg merge
3d 8h
Merged PRs (30d)
187

Description

### Which Cloudflare product(s) does this pertain to?

C3 (npm create cloudflare)

### What version(s) of the tool(s) are you using?

C3@2.33.3

### What version of Node are you using?

20

### What operating system and version are you using?

Mac

### Describe the Bug

This is more an internal issue/bug and not something that's apparent by using the package

We use this `hasTsConfig` function to check if a project has a `tsconfig.json` file and from that fact discern if typescript is being used or not: https://github.com/cloudflare/workers-sdk/blob/669d7ad1e44c07cf74202c4d0fc244a9c50dec81/packages/create-cloudflare/src/templates.ts#L485

This used to work as intended, however now it seems like, for web frameworks this method is called too early, before running the framework's `generate` function, basically making C3 unable to discern if a web framework app is using typescript or not.

This doesn't seem to be a problem right now since the only framework template using js/ts variants is svelteKit, and its js and ts files seem to be identical (https://github.com/cloudflare/workers-sdk/pull/7494), however if we were to have a web framework template with proper js/ts variants it would not currently work.

### Please provide a link to a minimal reproduction

_No response_

### Please provide any relevant error logs

_No response_

Contributor guide

Open the contributing guide

Research direction

Start in packages/create-cloudflare/src/templates.ts around the hasTsConfig function at line 485, then trace when it runs relative to a web framework's generate function. Check the SvelteKit template and its JavaScript/TypeScript variants as the concrete example. Done means framework projects are checked after generation so the correct TypeScript variant can be detected.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.