Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion playground/ty/src/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ export interface InitializedPlayground {

// Run once during startup. Initializes monaco, loads the wasm file, and restores the previous editor state.
async function startPlayground(): Promise<InitializedPlayground> {
const ty = await import("../ty_wasm");
const ty = await import("ty_wasm");
await ty.default();
const version = ty.version();
const monaco = await loader.init();
Expand Down
5 changes: 3 additions & 2 deletions playground/ty/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import tailwindcss from "@tailwindcss/vite";
import react from "@vitejs/plugin-react-swc";
import { dirname, join } from "path";
import { fileURLToPath } from "url";
import { normalizePath } from "vite";
import { viteStaticCopy } from "vite-plugin-static-copy";

const PYODIDE_EXCLUDE = [
Expand All @@ -15,15 +16,15 @@ const PYODIDE_EXCLUDE = [
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), tailwindcss(), viteStaticCopyPyodide()],
optimizeDeps: { exclude: ["pyodide"] },
optimizeDeps: { exclude: ["pyodide", "ty_wasm"] },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use vite for the production builds. Can you verify that the vite build reported sizes are the same before and after your changes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Build results on Ubuntu (@ WSL2):

main:

❯ dust ty/dist
 24K   ┌── Astral.png                │█                                                             │   0%
 20K   │ ┌── pyodide.mjs             │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
 20K   │ ├── solidity-CVYD1GVc.js    │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
 24K   │ ├── tsMode-De4b9PNo.js      │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
 36K   │ ├── cssMode-cNRTyZYV.js     │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
 36K   │ ├── htmlMode-BieFvPPN.js    │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
 44K   │ ├── ffi.d.ts                │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
 44K   │ ├── jsonMode-B6VJCXeF.js    │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
 68K   │ ├── pyodide.d.ts            │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
 84K   │ ├── pyodide.js.map          │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
 84K   │ ├── pyodide.mjs.map         │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
 92K   │ ├── codicon-B_Z2XQ3P.ttf    │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
112K   │ ├── pyodide-lock.json       │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
144K   │ ├── editor-BhPcksyq.css     │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
396K   │ ├── index-BeD-OYFt.js       │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   1%
1.0M   │ ├── pyodide.asm.js          │███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   4%
2.3M   │ ├── python_stdlib.zip       │█████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   8%
3.5M   │ ├── editor.main-ClkAP-6o.js │████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │  12%
8.2M   │ ├── pyodide.asm.wasm        │██████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │  29%
 11M   │ ├── ty_wasm_bg-Bd9OBY4A.wasm│██████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │  41%
 28M   ├─┴ assets                    │█████████████████████████████████████████████████████████████ │ 100%
 28M ┌─┴ dist                        │█████████████████████████████████████████████████████████████ │ 100%

#21471:

❯ dust ty/dist
 24K   ┌── Astral.png                │█                                                             │   0%
 20K   │ ┌── pyodide.mjs             │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
 20K   │ ├── solidity-CVYD1GVc.js    │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
 24K   │ ├── tsMode-Bzlyl_WG.js      │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
 36K   │ ├── cssMode-BItooz1B.js     │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
 36K   │ ├── htmlMode-XS2Ok6yb.js    │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
 44K   │ ├── ffi.d.ts                │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
 44K   │ ├── jsonMode-Bw4_M6_V.js    │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
 68K   │ ├── pyodide.d.ts            │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
 84K   │ ├── pyodide.js.map          │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
 84K   │ ├── pyodide.mjs.map         │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
 92K   │ ├── codicon-B_Z2XQ3P.ttf    │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
112K   │ ├── pyodide-lock.json       │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
144K   │ ├── editor-BhPcksyq.css     │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   0%
396K   │ ├── index-B_J2zKKC.js       │█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   1%
1.0M   │ ├── pyodide.asm.js          │███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   4%
2.3M   │ ├── python_stdlib.zip       │█████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │   8%
3.5M   │ ├── editor.main-CF30gs3G.js │████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │  12%
8.2M   │ ├── pyodide.asm.wasm        │██████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │  29%
 11M   │ ├── ty_wasm_bg-C8Ofe_-K.wasm│██████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │  41%
 28M   ├─┴ assets                    │█████████████████████████████████████████████████████████████ │ 100%
 28M ┌─┴ dist                        │█████████████████████████████████████████████████████████████ │ 100%

This result is consistent with what the vite document states.

});

export function viteStaticCopyPyodide() {
const pyodideDir = dirname(fileURLToPath(import.meta.resolve("pyodide")));
return viteStaticCopy({
targets: [
{
src: [join(pyodideDir, "*"), ...PYODIDE_EXCLUDE],
src: [normalizePath(join(pyodideDir, "*")), ...PYODIDE_EXCLUDE],
dest: "assets",
},
],
Expand Down
Loading