Skip to content
Merged
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
32 changes: 32 additions & 0 deletions build-wasm.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { fileURLToPath } from "url"
import path from "path"
import { spawn } from "child_process"

function runProcess(bin, args, options) {
return new Promise((resolve, reject) => {
const p = spawn(bin, args, options)

p.on("close", (code) => {
if (code === 0) {
resolve()
} else {
reject(new Error("Rust compilation."))
}
})

p.on("error", reject)
})
}

const __dirname = path.dirname(fileURLToPath(import.meta.url))
runProcess("wasm-pack", [
"--verbose",
"build",
path.resolve(__dirname, "crate"),
"--out-dir",
path.resolve(__dirname, "crate", "pkg"),
"--out-name",
"index",
"--target",
"bundler",
])
182 changes: 182 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"scripts": {
"start": "export NODE_ENV=development && webpack serve --open",
"build": "rm -rf lib lib-test && export $(grep -v '^#' .env | xargs) && export NODE_ENV=production && webpack && tsc --project tsconfig.build.json --emitDeclarationOnly ",
"build": "rm -rf lib lib-test && export $(grep -v '^#' .env | xargs) && export NODE_ENV=production && node build-wasm.mjs && webpack && tsc --project tsconfig.build.json --emitDeclarationOnly ",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
"test-e2e": "npx playwright test",
"format": "eslint --fix \"src/**/*.{ts,js}\" \"integration-tests/**/*.{ts,js}\""
Expand All @@ -45,6 +45,7 @@
"ts-node": "^10.9.2",
"typescript": "^5.8.2",
"typescript-eslint": "^8.26.0",
"wasm-pack": "^0.13.1",
"webpack": "^5.97.1",
"webpack-bundle-analyzer": "^4.10.2",
"webpack-cli": "^6.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/run.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import getCanvasRenderDescriptor from "getCanvasRenderDescriptor"
import { drawTexture } from "WebGPU/programs/initPrograms"
import { type State } from "../crate/pkg"
import { State } from "../crate/glue_code"
import getCanvasMatrix from "getCanvasMatrix"

export const transformMatrix = new Float32Array()
Expand Down
4 changes: 2 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const testConfig = {
},
plugins: [
...baseConfig.plugins,
new HtmlWebpackPlugin({
!isProd && new HtmlWebpackPlugin({
template: path.resolve(__dirname, "integration-tests/template.html"),
inject: true,
chunks: ['integrationTest'],
Expand All @@ -106,4 +106,4 @@ const testConfig = {
],
}

export default isProd ? [libConfig, testConfig] : testConfig
export default isProd ? [libConfig, testConfig] : testConfig