Skip to content

[ty] fix ty playground initialization and vite optimization issues#21471

Merged
MichaReiser merged 4 commits intoastral-sh:mainfrom
mtshiba:fix-playground-build-win
Nov 25, 2025
Merged

[ty] fix ty playground initialization and vite optimization issues#21471
MichaReiser merged 4 commits intoastral-sh:mainfrom
mtshiba:fix-playground-build-win

Conversation

@mtshiba
Copy link
Collaborator

@mtshiba mtshiba commented Nov 15, 2025

Summary

I tried to build the ty playground on my Windows machine and run it locally, but it didn't work. I got the following error:

$ npm start --workspace ty-playground

> ty-playground@0.0.0 prestart
> npm run dev:wasm


> ty-playground@0.0.0 dev:wasm
> wasm-pack build ../../crates/ty_wasm --dev --target web --out-dir ../../playground/ty/ty_wasm

[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm... 
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.69s
[INFO]: Installing wasm-bindgen...
[INFO]: License key is set in Cargo.toml but no LICENSE file(s) were found; Please add the LICENSE file(s) to your project directory
[INFO]: :-) Done in 5.46s
[INFO]: :-) Your wasm pkg is ready to publish at ..\..\playground\ty\ty_wasm.

> ty-playground@0.0.0 start
> vite

[vite-plugin-static-copy] Error: No file was found to copy to C:\{omitted}\ruff\playground\node_modules\pyodide\*,!**/*.{md,html},!**/*.d.ts,!**/*.whl,!**/node_modules src.
[vite-plugin-static-copy] No items found.

Also, nothing is displayed when I access localhost:5173. The following error appears in the browser console:

ty_wasm.js?v=16eba020:2195 Uncaught TypeError: Cannot read properties of undefined (reading '__wbindgen_malloc')
at new Workspace (ty_wasm.js?v=16eba020:2195:51)
at Playground.tsx:33:27

This PR fixes the above issues.

First, for the first issue with vite-plugin-static-copy, I addressed it by changing backslashes \ to slashes / in the path name. This is a common Windows-specific path handling issue.

For the other issue, I changed the ty_wasm package import from a relative path to a package name, and excluded ty_wasm from optimizeDeps in vite.config.js.
To be honest, I'm not familiar with vite, so I'm not sure why this worked, but I tried the workaround described here:

vitejs/vite#8427

The above changes are for development purposes only and should not affect the content actually delivered.

Test Plan

N/A

@mtshiba mtshiba marked this pull request as ready for review November 15, 2025 13:10
@AlexWaygood AlexWaygood added playground A playground-specific issue ty Multi-file analysis & type inference labels Nov 15, 2025
@mtshiba mtshiba force-pushed the fix-playground-build-win branch from 47ad620 to 6d632b1 Compare November 16, 2025 03:27
@mtshiba mtshiba requested a review from MichaReiser November 25, 2025 02:08
@MichaReiser MichaReiser enabled auto-merge (squash) November 25, 2025 07:38
@MichaReiser MichaReiser merged commit dd15656 into astral-sh:main Nov 25, 2025
36 checks passed
@mtshiba mtshiba deleted the fix-playground-build-win branch November 25, 2025 11:27
carljm added a commit to mtshiba/ruff that referenced this pull request Nov 25, 2025
* main:
  [ty] Implement `typing.override` (astral-sh#21627)
  [ty] Avoid expression reinference for diagnostics (astral-sh#21267)
  [ty] Improve autocomplete suppressions of keywords in variable bindings
  [ty] Only suggest completions based on text before the cursor
  Implement goto-definition and find-references for global/nonlocal statements (astral-sh#21616)
  [ty] Inlay Hint edit follow up (astral-sh#21621)
  [ty] Implement lsp support for string annotations (astral-sh#21577)
  [ty] Add 'remove unused ignore comment' code action (astral-sh#21582)
  [ty] Refactor `CheckSuppressionContext` to use `DiagnosticGuard` (astral-sh#21587)
  [ty] Improve several "Did you mean?" suggestions (astral-sh#21597)
  [ty] Add more and update existing projects in `ty_benchmark` (astral-sh#21536)
  [ty] fix ty playground initialization and vite optimization issues (astral-sh#21471)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

playground A playground-specific issue ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants