ryoppippi / unplugin-typia

unplugin for Typia with an extra Bun plugin 🫶
https://jsr.io/@ryoppippi/unplugin-typia
MIT License
23 stars 3 forks source link

Vite plugin doesn't seem to work with official Vite scaffold #157

Closed dearlordylord closed 1 day ago

dearlordylord commented 3 days ago

After installing per Vite docs https://vitejs.dev/guide/#scaffolding-your-first-vite-project , I'm adding UnpluginTypia to vite.config.ts.

It seems to get loaded (its message about cache pops up on npm run dev), but it reports that "transform is not configured" in the console and crashes the app.

I successfully ran your example with react+bun though, including with copy-paste of my type/runtime code.

Reproduction and full description (please refer for error message, steps of reproduction; you also can just run this repo to reproduce it): https://github.com/dearlordylord/typia-vite

ryoppippi commented 2 days ago

@dearlordylord Hi So I tested with your reproduction repo(thank you for your clear detailed description!!), and found somethings.

P.S. I also installed vite-plugin-inspect and checked the build result.

ryoppippi commented 2 days ago

OK, so when I delete your package-lock.json and run npm i again, and it works! Also, please delete a cache at node_modules/.cache/unplugin_typia Thanks @dearlordylord

EDIT: I created a PR https://github.com/dearlordylord/typia-vite/pull/1/ I released v0.5.2, but this is only for cache management

dearlordylord commented 1 day ago

@ryoppippi thank you for looking into it

I went with merging/checking out your changes, then

it ended up with the same error, with no extra debug info

(npm --version is 10.2.4)

then, I nuked node_modules and did npm i again

the error / debug output stays the same

the branch https://github.com/dearlordylord/typia-vite/blob/npm-i-after-fix-1/package-lock.json has the updated package-lock

I've also installed vite-plugin-inspect to check it but I'm not sure what I should be looking for (checked in into the same branch)

finally, resetting cache rm -rf node_modules/.cache/unplugin_typia again doesn't seem to have any effect

ryoppippi commented 1 day ago

@dearlordylord So, I uploaded this to vercel typia-vite.vercel.app https://github.com/ryoppippi/typia-vite As you can see, it works fine.

Also, I tested in my local, and it works fine tho. So idk what is wrong

Here is the vercel's build log

[16:49:22.008] Running build in Washington, D.C., USA (East) – iad1
[16:49:22.215] Cloning github.com/ryoppippi/typia-vite (Branch: master, Commit: af9f53c)
[16:49:22.614] Previous build cache not available
[16:49:22.721] Cloning completed: 502.438ms
[16:49:23.289] Running "vercel build"
[16:49:24.117] Vercel CLI 34.2.8
[16:49:25.234] Installing dependencies...
[16:49:32.274] npm WARN deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
[16:49:32.287] npm WARN deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
[16:49:32.356] npm WARN deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
[16:49:32.441] npm WARN deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
[16:49:32.486] npm WARN deprecated @humanwhocodes/config-array@0.11.14: Use @eslint/config-array instead
[16:49:34.733] 
[16:49:34.733] > typia-vite@0.0.0 prepare
[16:49:34.733] > ts-patch install && typia patch
[16:49:34.733] 
[16:49:36.068] [+] ts-patch installed!
[16:49:36.290] ----------------------------------------
[16:49:36.291]  Typia Setup Wizard
[16:49:36.291] ----------------------------------------
[16:49:36.291] Since TypeScript v5.3 update, "tsc" no more parses JSDoc comments.
[16:49:36.291] 
[16:49:36.291] Therefore, "typia" revives the JSDoc parsing feature by patching "tsc".
[16:49:36.291] 
[16:49:36.291] This is a temporary feature of "typia", and it would be removed when "ts-patch" being updated.
[16:49:36.357] 
[16:49:36.358] added 339 packages in 11s
[16:49:36.358] 
[16:49:36.358] 69 packages are looking for funding
[16:49:36.358]   run `npm fund` for details
[16:49:36.378] Detected `package-lock.json` generated by npm 7+
[16:49:36.378] Running "npm run build"
[16:49:36.644] 
[16:49:36.644] > typia-vite@0.0.0 build
[16:49:36.644] > tsc -b && vite build
[16:49:36.644] 
[16:49:38.756] (node:196) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
[16:49:38.756] (Use `node --trace-warnings ...` to show where the warning was created)
[16:49:39.110] 
[16:49:39.111]  > [unplugin-typia] Cache enabled
[16:49:39.111] 
[16:49:39.133] vite v5.3.2 building for production...
[16:49:39.184] transforming...
[16:49:39.199] [warn] [unplugin-typia] Cache miss: /vercel/path0/src/main.tsx
[16:49:40.074] [plugin:unplugin-typia] [plugin unplugin-typia] src/main.tsx: /vercel/path0/src/main.tsx
[16:49:40.075] [plugin:unplugin-typia] [plugin unplugin-typia] src/main.tsx: "strict mode is required."
[16:49:40.078] [success] [unplugin-typia] Transformed: /vercel/path0/src/main.tsx
[16:49:40.078] [success] [unplugin-typia] Cache set: /vercel/path0/src/main.tsx
[16:49:40.099] [warn] [unplugin-typia] Cache miss: /vercel/path0/src/App.tsx
[16:49:40.299] [plugin:unplugin-typia] [plugin unplugin-typia] src/App.tsx: /vercel/path0/src/App.tsx
[16:49:40.299] [plugin:unplugin-typia] [plugin unplugin-typia] src/App.tsx: "strict mode is required."
[16:49:40.304] [success] [unplugin-typia] Transformed: /vercel/path0/src/App.tsx
[16:49:40.305] [success] [unplugin-typia] Cache set: /vercel/path0/src/App.tsx
[16:49:41.118] ✓ 33 modules transformed.
[16:49:41.243] rendering chunks...
[16:49:41.251] computing gzip size...
[16:49:41.335] dist/index.html                   0.46 kB │ gzip:  0.30 kB
[16:49:41.335] dist/assets/index-DiwrgTda.css    1.39 kB │ gzip:  0.72 kB
[16:49:41.335] dist/assets/index-CH64KFfz.js   180.79 kB │ gzip: 57.08 kB
[16:49:41.336] ✓ built in 2.18s
[16:49:41.423] Build Completed in /vercel/output [16s]
[16:49:41.515] Deploying outputs...
[16:49:41.901] Injected preview comments middleware, you can disable this in your project settings.
[16:49:42.246] 
[16:49:42.492] Deployment completed
[16:49:47.101] Uploading build cache [17.64 MB]...
[16:49:47.484] Build cache uploaded: 382.943ms

I would like to help you, but in my env and vercel, it works...

dearlordylord commented 1 day ago
Screenshot 2024-07-01 at 1 46 07 PM

from the PR checked out and link http://localhost:5173/__inspect/#/module?id=/private/tmp/typia-vite/src/App.tsx&index=1

that's a bummer that it seems it doesn't work only for me!

I'll try to deploy the code on my private server / will try to tackle it further, I'll let you know if I find anything useful

dearlordylord commented 1 day ago

I ran it on my Dokku with no issues. I noticed it uses a bit older Node version so downgraded to it locally, cleaned cache and ran again and it worked! I tried to reproduce the issue upgrading node to what it was again (21.6.1), cleaned cache and it worked again... So I have no clue what was it. Probably skill issues. The only difference that my node is installed with n now vs. it being installed with brew before

ryoppippi commented 1 day ago

Maybe because of node version I think. It is not your skill problem. When you use appropriate tools, they work fine for you!

If you need extra supports, please add comments. If you are okay, close this issue!