diff --git a/.eslintignore b/.eslintignore index e4eb5c3..3897265 100644 --- a/.eslintignore +++ b/.eslintignore @@ -11,5 +11,3 @@ node_modules pnpm-lock.yaml package-lock.json yarn.lock -demoparser -src/lib/demoparser diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9b24a56..4e1b5e8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,7 @@ jobs: - name: Install and Build run: | npm ci + npm run fix npm run build - name: Deploy to GitHub Pages diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index a8e9d1d..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "src/lib/demoparser"] - path = src/lib/demoparser - url = https://github.com/LaihoE/demoparser.git diff --git a/.prettierignore b/.prettierignore index 066e0f0..3897265 100644 --- a/.prettierignore +++ b/.prettierignore @@ -11,4 +11,3 @@ node_modules pnpm-lock.yaml package-lock.json yarn.lock -src/lib/demoparser diff --git a/README.md b/README.md index 4fa13e7..a736a42 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,9 @@ Parse crosshair codes out of any CS2 demo you want! **CSGO is not supported.** ## Build -The [wasm demoparser](https://github.com/LaihoE/demoparser) doesn't seem to be on NPM (Only the node version is on npm right now) so I just submoduled it into this project under `src/lib/demoparser` - 1. `npm i` -2. `npm run dev` / `npm run build` +2. `npm run fix` (Fix some issues in the `demoparser2/package.json` due to `wasm-pack`) +3. `npm run dev` / `npm run build` ## Credits diff --git a/package-lock.json b/package-lock.json index 9e0a073..278d20f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/parser": "^6.0.0", "autoprefixer": "^10.4.16", - "demoparser2": "file:src/lib/demoparser/src/wasm/www/pkg", + "demoparser2": "^0.2.0", "eslint": "^8.28.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-svelte": "^2.30.0", @@ -27,7 +27,8 @@ "tailwindcss": "^3.3.5", "tslib": "^2.4.1", "typescript": "^5.0.0", - "vite": "^4.4.2" + "vite": "^4.4.2", + "vite-plugin-wasm-pack": "0.1.11" } }, "demoparser/src/wasm/www/pkg": { @@ -1378,8 +1379,10 @@ } }, "node_modules/demoparser2": { - "resolved": "src/lib/demoparser/src/wasm/www/pkg", - "link": true + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/demoparser2/-/demoparser2-0.2.0.tgz", + "integrity": "sha512-KQnFzHVGz2QoIpMbbgjw+rmjkz0y+Q9kMTEyRJGZ7Oo4ihvbhz9BohnP1kuyQKMGyMgQO0vrqWuCROZfcrRIew==", + "dev": true }, "node_modules/dequal": { "version": "2.0.3", @@ -1855,6 +1858,20 @@ "url": "https://github.com/sponsors/rawify" } }, + "node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -2173,6 +2190,18 @@ "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true }, + "node_modules/jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dev": true, + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", @@ -2399,6 +2428,12 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, + "node_modules/narrowing": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/narrowing/-/narrowing-1.5.0.tgz", + "integrity": "sha512-DUu4XdKgkfAPTAL28k79pdnshDE2W5T24QAnidSPo2F/W1TX6CjNzmEeXQfE5O1lxQvC0GYI6ZRDsLcyzugEYA==", + "dev": true + }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -3615,6 +3650,15 @@ "node": ">=14.0" } }, + "node_modules/universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "dev": true, + "engines": { + "node": ">= 10.0.0" + } + }, "node_modules/update-browserslist-db": { "version": "1.0.13", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", @@ -3715,6 +3759,17 @@ } } }, + "node_modules/vite-plugin-wasm-pack": { + "version": "0.1.11", + "resolved": "https://registry.npmjs.org/vite-plugin-wasm-pack/-/vite-plugin-wasm-pack-0.1.11.tgz", + "integrity": "sha512-eImq3bVNUXd2MAjz9WztqLSKabvWf6/7x2KDJdPYYqQncDOo7IqvuSvQiGW+8ihRgbI3uQuzqAL5AG4vAoHcEg==", + "dev": true, + "dependencies": { + "chalk": "^4.1.2", + "fs-extra": "^10.0.0", + "narrowing": "^1.4.0" + } + }, "node_modules/vitefu": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/vitefu/-/vitefu-0.2.5.tgz", @@ -3780,7 +3835,7 @@ "src/lib/demoparser/src/wasm/www/pkg": { "name": "demoparser2", "version": "0.1.0", - "dev": true + "extraneous": true } } } diff --git a/package.json b/package.json index 5389662..b1301af 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "lint": "prettier --check . && eslint .", - "format": "prettier --write ." + "format": "prettier --write .", + "fix": "node ./scripts/fix.js" }, "devDependencies": { "@sveltejs/adapter-auto": "^2.0.0", @@ -18,7 +19,7 @@ "@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/parser": "^6.0.0", "autoprefixer": "^10.4.16", - "demoparser2": "file:src/lib/demoparser/src/wasm/www/pkg", + "demoparser2": "^0.2.0", "eslint": "^8.28.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-svelte": "^2.30.0", @@ -31,7 +32,8 @@ "tailwindcss": "^3.3.5", "tslib": "^2.4.1", "typescript": "^5.0.0", - "vite": "^4.4.2" + "vite": "^4.4.2", + "vite-plugin-wasm-pack": "0.1.11" }, "type": "module" } diff --git a/scripts/fix.js b/scripts/fix.js new file mode 100644 index 0000000..b1f60e0 --- /dev/null +++ b/scripts/fix.js @@ -0,0 +1,7 @@ +import fs from "fs"; + +// wasm-pack seems to output a not-so-great package.json +const pkg = JSON.parse(fs.readFileSync("./node_modules/demoparser2/package.json", "utf8")); +pkg.main = "demoparser2.js"; +pkg.type = "module"; +fs.writeFileSync("./node_modules/demoparser2/package.json", JSON.stringify(pkg, null, "\t")); diff --git a/src/lib/demoparser b/src/lib/demoparser deleted file mode 160000 index 2101ca0..0000000 --- a/src/lib/demoparser +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2101ca0bfb85ccccc4beebb700a339807f508e23 diff --git a/vite.config.ts b/vite.config.ts index 328b1f5..2228390 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,6 +1,7 @@ import { sveltekit } from "@sveltejs/kit/vite"; import { defineConfig } from "vite"; +import wasmPack from "vite-plugin-wasm-pack"; export default defineConfig({ - plugins: [sveltekit()] + plugins: [wasmPack([], ["demoparser2"]), sveltekit()] });