Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

Commit

Permalink
fix: fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
luoxuhai committed Jul 23, 2023
1 parent 8e52b95 commit 23c4469
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

## Overview

![](./shot.jpg)
[![](./shot.jpg)](https://clangjs.netlify.app)

[Live Demo](https://clangjs.netlify.app)

This repo is extending the great work from [Ben Smith](https://twitter.com/binjimint) [published in his CppCon 2019 WebAssembly talk](https://www.youtube.com/watch?time_continue=4&v=5N4b-rU-OAA). The WebAssembly binaries are copied from Ben's fork of [llvm-project](https://github.com/binji/llvm-project/releases).

Expand All @@ -26,7 +28,11 @@ import { init, run } from 'clang.js';

async function main() {
await init({
// The path to the wasm resources
// The path to the wasm resources:
// - clang.wasm
// - lld.wasm
// - memfs.wasm
// - sysroot.tar
path: 'https://cdn.jsdelivr.net/npm/clang.js/dist',
});

Expand Down
6 changes: 5 additions & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</div>

<script type="module">
import { init, run } from '../dist/clang.js';
import { init, run } from 'https://cdn.jsdelivr.net/npm/clang.js/+esm';

const codeEl = document.getElementById('code');
const buttonEl = document.getElementById('run');
Expand All @@ -75,6 +75,10 @@
code = e.target.value;
});
buttonEl.addEventListener('click', async () => {
while (consoleEl.firstChild) {
consoleEl.removeChild(consoleEl.firstChild);
}

if (!isInitialed) {
buttonEl.textContent = 'Fetching';
try {
Expand Down

0 comments on commit 23c4469

Please sign in to comment.