Skip to content

Commit

Permalink
chore: add wasm build and instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed May 26, 2024
1 parent 0f1129f commit 7080083
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
# playground

## Development

Assuming the oxc repository is in `../oxc`:

- in a different terminal and in the `oxc` repository: `just watch-wasm`
- in this repo: `pnpm run dev`
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"tailwindcss": "^3.4.3",
"ts-node": "^10.9.2",
"typescript": "^5.4.5",
"vite": "^5.2.11"
"vite": "^5.2.11",
"@oxc/oxc_wasm": "link:../oxc/npm/oxc-wasm"
},
"dependencies": {
"@radix-icons/vue": "^1.0.0",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

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

34 changes: 33 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,36 @@ import App from "./App.vue";
import "./assets/index.css";
import "./assets/reset.css";

createApp(App).mount("#app");
import initWasm, {
Oxc,
OxcRunOptions,
OxcParserOptions,
OxcLinterOptions,
OxcMinifierOptions,
OxcCodegenOptions,
} from "@oxc/oxc_wasm";

Check failure on line 13 in src/main.ts

View workflow job for this annotation

GitHub Actions / Build and Deploy

Cannot find module '@oxc/oxc_wasm' or its corresponding type declarations.

async function main() {
await initWasm();

// Just a demo
const oxc = new Oxc();
const runOptions = new OxcRunOptions();
const parserOptions = new OxcParserOptions();
const codegenOptions = new OxcCodegenOptions();
const linterOptions = new OxcLinterOptions();
const minifierOptions = new OxcMinifierOptions();
oxc.sourceText = "const foo = bar;";
oxc.run(
runOptions,
parserOptions,
linterOptions,
codegenOptions,
minifierOptions,
);
console.log(oxc.ast);

createApp(App).mount("#app");
}

main();
5 changes: 5 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ export default defineConfig({
src: path.resolve(__dirname, "./src"),
},
},
server: {
fs: {
allow: [__dirname, "../oxc/npm/oxc-wasm"],
},
},
});

0 comments on commit 7080083

Please sign in to comment.