fix frontend build

This commit is contained in:
Ilion Beyst 2021-12-23 18:22:14 +01:00
parent 96ee00242f
commit c26f72890f
4 changed files with 19 additions and 8 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "pw-frontend", "name": "pw-frontend",
"version": "0.0.0", "version": "0.0.1",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",

View file

@ -1,9 +1,10 @@
import App from './App.svelte' 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({ const app = new App({
target: document.getElementById('app') target: document.getElementById('app')
}) })
}); })

View file

@ -3,7 +3,9 @@
"compilerOptions": { "compilerOptions": {
"target": "esnext", "target": "esnext",
"useDefineForClassFields": true, "useDefineForClassFields": true,
// "module": "esnext",
"module": "esnext", "module": "esnext",
"esModuleInterop": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"baseUrl": ".", "baseUrl": ".",

View file

@ -1,12 +1,20 @@
import { defineConfig } from 'vite' import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte' 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/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [ plugins: [
svelte(), svelte(),
nodePolyfills() viteCommonjs({
transformMixedEsModules: true,
}),
], ],
build: {
commonjsOptions: {
transformMixedEsModules: true,
},
minify: false,
target: "modules",
},
}) })