Skip to content
Snippets Groups Projects
Verified Commit 76cda3c2 authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

feat: initial support for parcel as bundler

parent 7b980afc
No related branches found
No related tags found
No related merge requests found
Pipeline #709 passed
Showing
with 27 additions and 13 deletions
...@@ -40,7 +40,7 @@ build-wasm: ...@@ -40,7 +40,7 @@ build-wasm:
- rustc --version - rustc --version
- cargo install wasm-pack - cargo install wasm-pack
- wasm-pack build --release --target=web --out-dir=examples/web/lib -- --features wasm - wasm-pack build --release --target=web --out-dir=examples/web/lib -- --features wasm
- cd examples/web && npm install && npm run build && rm -rf node_modules package-lock.json - cd examples/web && npm install && npm run build
artifacts: artifacts:
paths: paths:
- examples/web - examples/web
...@@ -48,7 +48,7 @@ build-wasm: ...@@ -48,7 +48,7 @@ build-wasm:
deploy-netlify-preview: deploy-netlify-preview:
stage: deploy stage: deploy
script: script:
- cd examples/web - cd examples/web/dist
- npm_config_yes=true npx --package=netlify-cli netlify deploy --dir=. - npm_config_yes=true npx --package=netlify-cli netlify deploy --dir=.
only: only:
- master - master
...@@ -56,7 +56,7 @@ deploy-netlify-preview: ...@@ -56,7 +56,7 @@ deploy-netlify-preview:
deploy-netlify-prod: deploy-netlify-prod:
stage: deploy stage: deploy
script: script:
- cd examples/web - cd examples/web/dist
- npm_config_yes=true npx --package=netlify-cli netlify deploy --dir=. --prod - npm_config_yes=true npx --package=netlify-cli netlify deploy --dir=. --prod
only: only:
- tags - tags
...@@ -42,7 +42,7 @@ cargo install wasm-pack ...@@ -42,7 +42,7 @@ cargo install wasm-pack
wasm-pack build --release --target=web --out-dir=examples/web/lib -- --features wasm wasm-pack build --release --target=web --out-dir=examples/web/lib -- --features wasm
cd examples/web cd examples/web
npm install && npm run build npm install && npm run build
python3 -m http.server cd dist && python3 -m http.server
``` ```
## Reason ## Reason
......
yarn.lock yarn.lock
package-lock.json package-lock.json
/index.js /.parcel-cache
/index.js.map
/dist
/node_modules /node_modules
{
"extends": "@parcel/config-default",
"transformers": {
"*.{ts,tsx}": ["@parcel/transformer-typescript-tsc"],
"*.ch8": ["@parcel/transformer-raw"]
}
}
...@@ -83,6 +83,6 @@ ...@@ -83,6 +83,6 @@
<div id="footer" class="footer"> <div id="footer" class="footer">
Built with ❤️ by <a href="https://joao.me" target="_blank">João Magalhães</a> Built with ❤️ by <a href="https://joao.me" target="_blank">João Magalhães</a>
</div> </div>
<script type="module" src="index.js"></script> <script type="module" src="index.ts"></script>
</body> </body>
</html> </html>
import { default as wasm, Chip8Neo, Chip8Classic } from "./lib/chip_ahoyto.js"; import { default as wasm, Chip8Neo, Chip8Classic } from "./lib/chip_ahoyto.js";
import info from "./package.json";
const PIXEL_SET_COLOR = 0x50cb93ff; const PIXEL_SET_COLOR = 0x50cb93ff;
const PIXEL_UNSET_COLOR = 0x1b1a17ff; const PIXEL_UNSET_COLOR = 0x1b1a17ff;
...@@ -39,7 +40,8 @@ const KEYS: Record<string, number> = { ...@@ -39,7 +40,8 @@ const KEYS: Record<string, number> = {
v: 0x0f v: 0x0f
}; };
const ROM_PATH = "res/roms/pong.ch8"; // @ts-ignore: ts(2580)
const ROM_PATH = require("../../res/roms/pong.ch8");
type State = { type State = {
chip8: Chip8Neo | Chip8Classic; chip8: Chip8Neo | Chip8Classic;
...@@ -440,8 +442,6 @@ const registerToast = () => { ...@@ -440,8 +442,6 @@ const registerToast = () => {
}; };
const initBase = async () => { const initBase = async () => {
const response = await fetch("package.json");
const info = await response.json();
setVersion(info.version); setVersion(info.version);
}; };
...@@ -607,7 +607,9 @@ const fetchRom = async (romPath: string): Promise<[string, Uint8Array]> => { ...@@ -607,7 +607,9 @@ const fetchRom = async (romPath: string): Promise<[string, Uint8Array]> => {
// extracts the name of the ROM from the provided // extracts the name of the ROM from the provided
// path by splitting its structure // path by splitting its structure
const romPathS = romPath.split(/\//g); const romPathS = romPath.split(/\//g);
const romName = romPathS[romPathS.length - 1]; let romName = romPathS[romPathS.length - 1].split("?")[0];
const romNameS = romName.split(/\./g);
romName = `${romNameS[0]}.${romNameS[romNameS.length - 1]}`;
// loads the ROM data and converts it into the // loads the ROM data and converts it into the
// target byte array buffer (to be used by WASM) // target byte array buffer (to be used by WASM)
......
...@@ -8,12 +8,16 @@ ...@@ -8,12 +8,16 @@
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"scripts": { "scripts": {
"build": "tsc -p .", "build": "parcel build index.html",
"dev": "parcel index.html",
"pretty": "prettier --config .prettierrc \"./**/*.{ts,json}\" --write", "pretty": "prettier --config .prettierrc \"./**/*.{ts,json}\" --write",
"start": "npm run build", "start": "npm run build",
"watch": "tsc-watch" "watch": "parcel watch index.html"
}, },
"source": "index.ts",
"devDependencies": { "devDependencies": {
"@parcel/transformer-typescript-tsc": "^2.6.1",
"parcel": "^2.6.1",
"prettier": "^2.7.1", "prettier": "^2.7.1",
"tsc-watch": "^5.0.3", "tsc-watch": "^5.0.3",
"typescript": "^4.5.5" "typescript": "^4.5.5"
......
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment