Skip to content

Commit

Permalink
[dev]: Make it work in reactts-esbuild environment
Browse files Browse the repository at this point in the history
  • Loading branch information
Takuma Kira committed Apr 19, 2024
1 parent 1f10586 commit bf281a7
Show file tree
Hide file tree
Showing 6 changed files with 446 additions and 129 deletions.
18 changes: 18 additions & 0 deletions www/dev.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env node
import * as esbuild from 'esbuild'
import wasmPlugin from './wasmPlugin.mjs'

const ctx = await esbuild.context({
entryPoints: ['./src/index.jsx'],
bundle: true,
outfile: './public/bundle/index.js',
plugins: [wasmPlugin],
})

const { host, port } = await ctx.serve({
servedir: 'public',
onRequest: () => {
console.log('Got request')
},
})
console.log(`http://${host}:${port}`)
5 changes: 3 additions & 2 deletions www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "dist/index.js",
"scripts": {
"dev": "esbuild ./src/index.tsx --bundle --outdir=public/bundle --watch --servedir=public",
"dev": "./dev.mjs",
"build": "./build.mjs",
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand All @@ -15,6 +15,7 @@
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"wasm-game-of-life": "file:../pkg"
}
}
Loading

0 comments on commit bf281a7

Please sign in to comment.