mirror of https://github.com/astral-sh/ruff
[ty] fix ty playground initialization and vite optimization issues (#21471)
Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
parent
adf095e889
commit
dd15656deb
|
|
@ -501,7 +501,7 @@ export interface InitializedPlayground {
|
||||||
|
|
||||||
// Run once during startup. Initializes monaco, loads the wasm file, and restores the previous editor state.
|
// Run once during startup. Initializes monaco, loads the wasm file, and restores the previous editor state.
|
||||||
async function startPlayground(): Promise<InitializedPlayground> {
|
async function startPlayground(): Promise<InitializedPlayground> {
|
||||||
const ty = await import("../ty_wasm");
|
const ty = await import("ty_wasm");
|
||||||
await ty.default();
|
await ty.default();
|
||||||
const version = ty.version();
|
const version = ty.version();
|
||||||
const monaco = await loader.init();
|
const monaco = await loader.init();
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import tailwindcss from "@tailwindcss/vite";
|
||||||
import react from "@vitejs/plugin-react-swc";
|
import react from "@vitejs/plugin-react-swc";
|
||||||
import { dirname, join } from "path";
|
import { dirname, join } from "path";
|
||||||
import { fileURLToPath } from "url";
|
import { fileURLToPath } from "url";
|
||||||
|
import { normalizePath } from "vite";
|
||||||
import { viteStaticCopy } from "vite-plugin-static-copy";
|
import { viteStaticCopy } from "vite-plugin-static-copy";
|
||||||
|
|
||||||
const PYODIDE_EXCLUDE = [
|
const PYODIDE_EXCLUDE = [
|
||||||
|
|
@ -15,15 +16,17 @@ const PYODIDE_EXCLUDE = [
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react(), tailwindcss(), viteStaticCopyPyodide()],
|
plugins: [react(), tailwindcss(), viteStaticCopyPyodide()],
|
||||||
optimizeDeps: { exclude: ["pyodide"] },
|
optimizeDeps: { exclude: ["pyodide", "ty_wasm"] },
|
||||||
});
|
});
|
||||||
|
|
||||||
export function viteStaticCopyPyodide() {
|
export function viteStaticCopyPyodide() {
|
||||||
const pyodideDir = dirname(fileURLToPath(import.meta.resolve("pyodide")));
|
const pyodideDir = normalizePath(
|
||||||
|
join(dirname(fileURLToPath(import.meta.resolve("pyodide"))), "*"),
|
||||||
|
);
|
||||||
return viteStaticCopy({
|
return viteStaticCopy({
|
||||||
targets: [
|
targets: [
|
||||||
{
|
{
|
||||||
src: [join(pyodideDir, "*"), ...PYODIDE_EXCLUDE],
|
src: [pyodideDir, ...PYODIDE_EXCLUDE],
|
||||||
dest: "assets",
|
dest: "assets",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue