diff options
Diffstat (limited to 'web')
-rw-r--r-- | web/pw-frontend/package.json | 2 | ||||
-rw-r--r-- | web/pw-frontend/src/main.ts | 9 | ||||
-rw-r--r-- | web/pw-frontend/tsconfig.json | 2 | ||||
-rw-r--r-- | web/pw-frontend/vite.config.js | 14 |
4 files changed, 19 insertions, 8 deletions
diff --git a/web/pw-frontend/package.json b/web/pw-frontend/package.json index 194f7cf..d1c9c72 100644 --- a/web/pw-frontend/package.json +++ b/web/pw-frontend/package.json @@ -1,6 +1,6 @@ { "name": "pw-frontend", - "version": "0.0.0", + "version": "0.0.1", "type": "module", "scripts": { "dev": "vite", diff --git a/web/pw-frontend/src/main.ts b/web/pw-frontend/src/main.ts index eb9e5a0..b9ec466 100644 --- a/web/pw-frontend/src/main.ts +++ b/web/pw-frontend/src/main.ts @@ -1,9 +1,10 @@ import App from './App.svelte' -import load_wasm_module from "planetwars-rs"; +import init_wasm_module from "planetwars-rs"; -load_wasm_module().then(() => { +const wasm_url = new URL("../planetwars-rs/pkg/planetwars_rs_bg.wasm", import.meta.url) + +init_wasm_module(wasm_url).then(() => { const app = new App({ target: document.getElementById('app') }) -}); - +})
\ No newline at end of file diff --git a/web/pw-frontend/tsconfig.json b/web/pw-frontend/tsconfig.json index 2bfc2d3..e242fcf 100644 --- a/web/pw-frontend/tsconfig.json +++ b/web/pw-frontend/tsconfig.json @@ -3,7 +3,9 @@ "compilerOptions": { "target": "esnext", "useDefineForClassFields": true, + // "module": "esnext", "module": "esnext", + "esModuleInterop": true, "resolveJsonModule": true, "baseUrl": ".", diff --git a/web/pw-frontend/vite.config.js b/web/pw-frontend/vite.config.js index 7682f94..bce1f51 100644 --- a/web/pw-frontend/vite.config.js +++ b/web/pw-frontend/vite.config.js @@ -1,12 +1,20 @@ import { defineConfig } from 'vite' import { svelte } from '@sveltejs/vite-plugin-svelte' -import nodePolyfills from 'rollup-plugin-polyfill-node' - +import { viteCommonjs } from '@originjs/vite-plugin-commonjs' // https://vitejs.dev/config/ export default defineConfig({ plugins: [ svelte(), - nodePolyfills() + viteCommonjs({ + transformMixedEsModules: true, + }), ], + build: { + commonjsOptions: { + transformMixedEsModules: true, + }, + minify: false, + target: "modules", + }, }) |