bluwy / create-vite-extra

Extra Vite templates
MIT License
370 stars 55 forks source link

Deno + React + TS + SWC generates a SWC version that doesn't exist #43

Closed alanko0511 closed 8 months ago

alanko0511 commented 8 months ago

I'm using Deno to create a React.js + TS + SWC Vite project, but in the generated vite.config.mts file, it wants a SWC version that doesn't exist today. (the latest version is 3.5.0, but it wants ^4.0.0)

CleanShot 2024-01-05 at 21 35 04@2x

I have to manually change to ^3.5.0 to get this working.

To produce this:

  1. deno run --allow-read --allow-write --allow-env npm:create-vite-extra@latest
  2. Select a template: › deno-react
  3. Select a variant: › TypeScript + SWC
  4. Inside the project directory, run deno task dev
  5. Then it throws an error: TypeError: Could not find npm package '@vitejs/plugin-react-swc' matching '^4.0.0'.

My setup:

% deno --version
deno 1.39.2 (release, aarch64-apple-darwin)
v8 12.0.267.8
typescript 5.3.3
alanko0511 commented 8 months ago

I just cloned this repo on my local machine, and I can successfully create a deno + react + ts + swc project with the correct. I also found that the create-vite-extra downloaded is still 1.1.0.

alanko0511 commented 8 months ago

Found the issue... I used this tool before, and somehow deno doesn't check and download the latest version, so it uses the version it cached back then.

Specifying the version or not including the version number fixes the issue:

deno run --allow-read --allow-write --allow-env npm:create-vite-extra

https://www.npmjs.com/package/create-vite-extra