Skip to content

Commit

Permalink
Migrate to rsbuild (#737)
Browse files Browse the repository at this point in the history
* Migrate to rsbuild

* symlink public/data/ -> data/
  • Loading branch information
encounter authored Jan 1, 2025
1 parent 89aa596 commit 9bdfeb6
Show file tree
Hide file tree
Showing 11 changed files with 574 additions and 3,739 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ rust/target/
.cache/

data/*
!data/.empty
dist/*
!dist/.htaccess
!data/.gitkeep
dist/

# wasm-pack not working correctly
pkg/index.js
Empty file added data/.gitkeep
Empty file.
16 changes: 4 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,14 @@
"private": true,
"license": "MIT",
"devDependencies": {
"@rspack/cli": "^1.1.3",
"@rspack/core": "^1.1.3",
"@rspack/dev-server": "^1.0.9",
"@swc/helpers": "^0.5.15",
"@swc/register": "^0.1.10",
"@rsbuild/core": "^1.1.12",
"@rsbuild/plugin-type-check": "^1.2.0",
"@types/node": "^22.9.3",
"@types/pngjs": "^6.0.5",
"@types/webxr": "^0.5.20",
"@webgpu/types": "^0.1.51",
"@xmldom/xmldom": "^0.9.5",
"buffer": "^6.0.3",
"clean-webpack-plugin": "^4.0.0",
"cross-env": "^7.0.3",
"fork-ts-checker-webpack-plugin": "^9.0.2",
"git-revision-webpack-plugin": "^5.0.0",
"html-webpack-plugin": "^5.6.3",
"onchange": "^7.1.0",
"pngjs": "^7.0.0",
"tsx": "^4.19.2",
Expand All @@ -33,8 +25,8 @@
"reflect-metadata": "^0.2.2"
},
"scripts": {
"start": "pnpm run build:rust && cross-env NODE_ENV=development rspack dev",
"build": "pnpm run build:rust && cross-env NODE_ENV=production rspack build",
"start": "pnpm run build:rust && rsbuild dev",
"build": "pnpm run build:rust && rsbuild build",
"build:rust": "wasm-pack build -t web rust",
"build:rust-dev": "wasm-pack build --dev -t web rust",
"build:ZeldaWindWaker": "cd src/ZeldaWindWaker/tools && tsx --experimental-wasm-modules zww_extractor.ts",
Expand Down
4,104 changes: 497 additions & 3,607 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

File renamed without changes.
1 change: 1 addition & 0 deletions public/data
63 changes: 63 additions & 0 deletions rsbuild.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { defineConfig } from '@rsbuild/core';
import { pluginTypeCheck } from '@rsbuild/plugin-type-check';
import { execSync } from 'node:child_process';

let gitCommit = '(unknown)';
try {
gitCommit = execSync('git rev-parse --short HEAD').toString().trim();
} catch (e) {
console.warn('Failed to fetch Git commit hash', e);
}

export default defineConfig({
source: {
entry: {
index: './src/main.ts',
embed: './src/main.ts',
},
// Legacy decorators are used with `reflect-metadata`.
// TODO: Migrate to TypeScript 5.0 / TC39 decorators.
decorators: {
version: 'legacy',
},
define: {
__COMMIT_HASH: JSON.stringify(gitCommit),
},
},
html: {
template: './src/index.html',
},
output: {
target: 'web',
// Mark Node.js built-in modules as external.
externals: ['fs', 'path', 'url'],
// TODO: These should be converted to use `new URL('./file.wasm', import.meta.url)`
// so that the bundler can resolve them. In the meantime, they're expected to be
// at the root.
copy: [
{ from: 'src/**/*.wasm', to: '[name][ext]' },
{ from: 'node_modules/librw/lib/librw.wasm' },
],
},
// Enable async TypeScript type checking.
plugins: [pluginTypeCheck()],
tools: {
// Add a rule to treat .glsl files as source assets.
rspack(_config, { addRules }) {
addRules([
{
test: /\.glsl$/,
type: 'asset/source',
},
]);
},
// Disable standards-compliant class field transforms.
swc: {
jsc: {
transform: {
useDefineForClassFields: false,
},
},
},
},
});
111 changes: 0 additions & 111 deletions rspack.config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/Common/JSYSTEM/JPA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { Endianness } from "../../endian.js";
import { GfxDevice, GfxInputLayout, GfxBuffer, GfxFormat, GfxVertexAttributeDescriptor, GfxVertexBufferFrequency, GfxBufferUsage, GfxBufferFrequencyHint, GfxIndexBufferDescriptor, GfxInputLayoutBufferDescriptor, GfxVertexBufferDescriptor } from "../../gfx/platform/GfxPlatform.js";
import { getPointHermite } from "../../Spline.js";
import { getVertexInputLocation, GX_Program } from "../../gx/gx_material.js";
import { Color, colorNewFromRGBA, colorCopy, colorNewCopy, White, colorFromRGBA8, colorLerp, colorMult, colorNewFromRGBA8 } from "../../Color.js";
import { type Color, colorNewFromRGBA, colorCopy, colorNewCopy, White, colorFromRGBA8, colorLerp, colorMult, colorNewFromRGBA8 } from "../../Color.js";
import { MaterialParams, ColorKind, DrawParams, fillIndTexMtx, fillTextureSize, fillTextureBias } from "../../gx/gx_render.js";
import { GXMaterialHelperGfx } from "../../gx/gx_render.js";
import { computeModelMatrixSRT, computeModelMatrixR, lerp, MathConstants, normToLengthAndAdd, normToLength, isNearZeroVec3, transformVec3Mat4w1, transformVec3Mat4w0, getMatrixAxisZ, setMatrixTranslation, setMatrixAxis, Vec3Zero, vec3SetAll } from "../../MathHelpers.js";
Expand Down
2 changes: 1 addition & 1 deletion src/DataFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class DataFetcherRequest {
public async start() {
this.started = true;

if (this.cache !== null) {
if (!IS_DEVELOPMENT && this.cache !== null) {
const match = await this.cache.match(this.request);
if (match !== undefined) {
const arrayBuffer = await match.arrayBuffer();
Expand Down
9 changes: 5 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"compilerOptions": {
"target": "es2017",
"target": "ES2022",
"alwaysStrict": true,
"downlevelIteration": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noImplicitAny": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
Expand All @@ -16,14 +17,14 @@
"useDefineForClassFields": false,
"resolveJsonModule": true,
"lib": [
"ES2020",
"ES2021.String",
"ES2022",
"ES2024.ArrayBuffer",
"dom"
"DOM"
],
"sourceMap": true,
"moduleResolution": "Bundler",
"module": "ESNext",
"isolatedModules": true,
"types": [
"gl-matrix",
"webxr"
Expand Down

0 comments on commit 9bdfeb6

Please sign in to comment.