Skip to content

Commit

Permalink
docs: add and hello_world switched to direct import
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Hanke authored and daxpedda committed Jul 5, 2023
1 parent 7e576ec commit 29205c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
7 changes: 3 additions & 4 deletions examples/add/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// For more comments about what's going on here, check out the `hello_world`
// example
const rust = import('./pkg');
rust
.then(m => alert('1 + 2 = ' + m.add(1, 2)))
.catch(console.error);
import { add } from './pkg';

alert('1 + 2 = ' + add(1, 2))
9 changes: 2 additions & 7 deletions examples/hello_world/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// Note that a dynamic `import` statement here is required due to
// webpack/webpack#6615, but in theory `import { greet } from './pkg';`
// will work here one day as well!
const rust = import('./pkg');
import { greet } from './pkg';

rust
.then(m => m.greet('World!'))
.catch(console.error);
greet('World');

0 comments on commit 29205c5

Please sign in to comment.