diff --git a/.travis.yml b/.travis.yml
index 92c3bf9868d..8ef712e68da 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -93,14 +93,15 @@ matrix:
- *INSTALL_NODE_VIA_NVM
- *INSTALL_AWS
- npm install
+ - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -s -- -f
script:
+ - cargo build -p wasm-bindgen-cli
+ - ln -snf target/debug/wasm-bindgen $HOME/.cargo/wasm-bindgen
- |
for dir in `ls examples | grep -v README | grep -v asm.js | grep -v raytrace | grep -v no_modules`; do
(cd examples/$dir &&
- sed -i "s|: \"webpack-dev-server\"|: \"webpack --output-path $HOME/$TRAVIS_BUILD_NUMBER/exbuild/$dir\"|" package.json &&
- sed -i 's/npm install//' build.sh &&
ln -fs ../../node_modules . &&
- ./build.sh) || exit 1;
+ npm run build -- --output-path $HOME/$TRAVIS_BUILD_NUMBER/exbuild/$dir) || exit 1;
done
- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then aws s3 sync --quiet ~/$TRAVIS_BUILD_NUMBER s3://wasm-bindgen-ci/$TRAVIS_BUILD_NUMBER; fi
if: branch = master
diff --git a/examples/.gitignore b/examples/.gitignore
new file mode 100644
index 00000000000..20fec396ebc
--- /dev/null
+++ b/examples/.gitignore
@@ -0,0 +1,4 @@
+package-lock.json
+pkg
+dist
+wasm-pack.log
diff --git a/examples/add/.gitignore b/examples/add/.gitignore
deleted file mode 100644
index bdaab9c5794..00000000000
--- a/examples/add/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-package-lock.json
-add.js
-add_bg.wasm
diff --git a/examples/add/README.md b/examples/add/README.md
index 57c508e85e9..a72caf3c703 100644
--- a/examples/add/README.md
+++ b/examples/add/README.md
@@ -9,9 +9,7 @@ online][compiled]
You can build the example locally with:
```
-$ ./build.sh
+$ npm run serve
```
-(or running the commands on Windows manually)
-
and then visiting http://localhost:8080 in a browser should run the example!
diff --git a/examples/add/build.sh b/examples/add/build.sh
deleted file mode 100755
index 8d2dd6e8b89..00000000000
--- a/examples/add/build.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-
-# For more comments about what's going on here, see the `hello_world` example
-
-set -ex
-
-cargo build --target wasm32-unknown-unknown --release
-cargo run --manifest-path ../../crates/cli/Cargo.toml \
- --bin wasm-bindgen -- \
- ../../target/wasm32-unknown-unknown/release/add.wasm --out-dir .
-npm install
-npm run serve
diff --git a/examples/add/index.js b/examples/add/index.js
index bef9fbcc661..e8f5245025d 100644
--- a/examples/add/index.js
+++ b/examples/add/index.js
@@ -1,6 +1,6 @@
// For more comments about what's going on here, check out the `hello_world`
// example
-const rust = import('./add');
+const rust = import('./pkg/add');
rust
.then(m => alert('1 + 2 = ' + m.add(1, 2)))
.catch(console.error);
diff --git a/examples/add/package.json b/examples/add/package.json
index 806119cdb5b..49198ff2cd0 100644
--- a/examples/add/package.json
+++ b/examples/add/package.json
@@ -1,9 +1,10 @@
{
"scripts": {
- "build": "webpack",
- "serve": "webpack-dev-server"
+ "build": "webpack -p",
+ "serve": "webpack-dev-server -p"
},
"devDependencies": {
+ "@wasm-tool/wasm-pack-plugin": "0.2.1",
"text-encoding": "^0.7.0",
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.11.1",
diff --git a/examples/add/webpack.config.js b/examples/add/webpack.config.js
index 53396f30f8a..a6f6e1e930d 100644
--- a/examples/add/webpack.config.js
+++ b/examples/add/webpack.config.js
@@ -1,6 +1,7 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
+const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
module.exports = {
entry: './index.js',
@@ -10,6 +11,9 @@ module.exports = {
},
plugins: [
new HtmlWebpackPlugin(),
+ new WasmPackPlugin({
+ crateDirectory: path.resolve(__dirname, ".")
+ }),
// Have this example work in Edge which doesn't ship `TextEncoder` or
// `TextDecoder` at this time.
new webpack.ProvidePlugin({
diff --git a/examples/canvas/.gitignore b/examples/canvas/.gitignore
deleted file mode 100644
index a5e6169e744..00000000000
--- a/examples/canvas/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-package-lock.json
-canvas.js
-canvas_bg.js
-canvas_bg.wasm
diff --git a/examples/canvas/README.md b/examples/canvas/README.md
index 2ab89e80121..bbd03128895 100644
--- a/examples/canvas/README.md
+++ b/examples/canvas/README.md
@@ -9,9 +9,7 @@ online][compiled]
You can build the example locally with:
```
-$ ./build.sh
+$ npm run serve
```
-(or running the commands on Windows manually)
-
and then visiting http://localhost:8080 in a browser should run the example!
diff --git a/examples/canvas/build.sh b/examples/canvas/build.sh
deleted file mode 100755
index 0198ef80a47..00000000000
--- a/examples/canvas/build.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-# For more comments about what's going on here, see the `hello_world` example
-
-set -ex
-cd "$(dirname $0)"
-
-cargo build --target wasm32-unknown-unknown
-
-cargo run --manifest-path ../../crates/cli/Cargo.toml \
- --bin wasm-bindgen -- \
- ../../target/wasm32-unknown-unknown/debug/canvas.wasm --out-dir .
-
-npm install
-npm run serve
diff --git a/examples/canvas/index.js b/examples/canvas/index.js
index 4b586d9a0f6..a649b473e1e 100644
--- a/examples/canvas/index.js
+++ b/examples/canvas/index.js
@@ -1,4 +1,4 @@
// For more comments about what's going on here, check out the `hello_world`
// example.
-import('./canvas')
+import('./pkg/canvas')
.catch(console.error);
diff --git a/examples/canvas/package.json b/examples/canvas/package.json
index 806119cdb5b..9fafb189ee8 100644
--- a/examples/canvas/package.json
+++ b/examples/canvas/package.json
@@ -4,6 +4,7 @@
"serve": "webpack-dev-server"
},
"devDependencies": {
+ "@wasm-tool/wasm-pack-plugin": "0.2.1",
"text-encoding": "^0.7.0",
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.11.1",
diff --git a/examples/canvas/webpack.config.js b/examples/canvas/webpack.config.js
index f15dc6b56d9..25afd18002a 100644
--- a/examples/canvas/webpack.config.js
+++ b/examples/canvas/webpack.config.js
@@ -1,6 +1,7 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
+const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
module.exports = {
entry: './index.js',
@@ -10,7 +11,10 @@ module.exports = {
},
plugins: [
new HtmlWebpackPlugin({
- template: "index.html"
+ template: 'index.html'
+ }),
+ new WasmPackPlugin({
+ crateDirectory: path.resolve(__dirname, ".")
}),
// Have this example work in Edge which doesn't ship `TextEncoder` or
// `TextDecoder` at this time.
diff --git a/examples/char/.gitignore b/examples/char/.gitignore
deleted file mode 100644
index 937451e4320..00000000000
--- a/examples/char/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-package-lock.json
-char.js
-char_bg.js
-char_bg.wasm
diff --git a/examples/char/README.md b/examples/char/README.md
index 884d9a621db..4f0ec173629 100644
--- a/examples/char/README.md
+++ b/examples/char/README.md
@@ -9,9 +9,7 @@ online][compiled]
You can build the example locally with:
```
-$ ./build.sh
+$ npm run serve
```
-(or running the commands on Windows manually)
-
and then visiting http://localhost:8080 in a browser should run the example!
diff --git a/examples/char/build.sh b/examples/char/build.sh
deleted file mode 100755
index 7e4aa2f14e6..00000000000
--- a/examples/char/build.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-
-set -ex
-
-# Build the `hello_world.wasm` file using Cargo/rustc
-cargo build --target wasm32-unknown-unknown
-
-# Run the `wasm-bindgen` CLI tool to postprocess the wasm file emitted by the
-# Rust compiler to emit the JS support glue that's necessary
-#
-# Here we're using the version of the CLI in this repository, but for external
-# usage you'd use the commented out version below
-cargo run --manifest-path ../../crates/cli/Cargo.toml \
- --bin wasm-bindgen -- \
- ../../target/wasm32-unknown-unknown/debug/char.wasm --out-dir .
-# wasm-bindgen ../../target/wasm32-unknown-unknown/hello_world.wasm --out-dir .
-
-# Finally, package everything up using Webpack and start a server so we can
-# browse the result
-
-npm install
-npm run serve
diff --git a/examples/char/index.js b/examples/char/index.js
index c1d0f4f59c5..caa92b42428 100644
--- a/examples/char/index.js
+++ b/examples/char/index.js
@@ -1,6 +1,6 @@
/* eslint-disable no-unused-vars */
import { chars } from './chars-list.js';
-let imp = import('./char.js');
+let imp = import('./pkg/char');
let mod;
let counters = [];
diff --git a/examples/char/package.json b/examples/char/package.json
index 806119cdb5b..9fafb189ee8 100644
--- a/examples/char/package.json
+++ b/examples/char/package.json
@@ -4,6 +4,7 @@
"serve": "webpack-dev-server"
},
"devDependencies": {
+ "@wasm-tool/wasm-pack-plugin": "0.2.1",
"text-encoding": "^0.7.0",
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.11.1",
diff --git a/examples/char/webpack.config.js b/examples/char/webpack.config.js
index f15dc6b56d9..353fbcafdc9 100644
--- a/examples/char/webpack.config.js
+++ b/examples/char/webpack.config.js
@@ -1,6 +1,7 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
+const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
module.exports = {
entry: './index.js',
@@ -12,6 +13,9 @@ module.exports = {
new HtmlWebpackPlugin({
template: "index.html"
}),
+ new WasmPackPlugin({
+ crateDirectory: path.resolve(__dirname, ".")
+ }),
// Have this example work in Edge which doesn't ship `TextEncoder` or
// `TextDecoder` at this time.
new webpack.ProvidePlugin({
diff --git a/examples/closures/.gitignore b/examples/closures/.gitignore
deleted file mode 100644
index 3e0dcd94898..00000000000
--- a/examples/closures/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-package-lock.json
-closures.js
-closures_bg.js
-closures_bg.wasm
diff --git a/examples/closures/README.md b/examples/closures/README.md
index 5782c28aad6..ddf701710bf 100644
--- a/examples/closures/README.md
+++ b/examples/closures/README.md
@@ -9,9 +9,7 @@ online][compiled]
You can build the example locally with:
```
-$ ./build.sh
+$ npm run serve
```
-(or running the commands on Windows manually)
-
and then visiting http://localhost:8080 in a browser should run the example!
diff --git a/examples/closures/build.sh b/examples/closures/build.sh
deleted file mode 100755
index 9ed029a9440..00000000000
--- a/examples/closures/build.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-
-# For more comments about what's going on here, see the `hello_world` example
-
-set -ex
-
-cargo build --target wasm32-unknown-unknown
-cargo run --manifest-path ../../crates/cli/Cargo.toml \
- --bin wasm-bindgen -- \
- ../../target/wasm32-unknown-unknown/debug/closures.wasm --out-dir .
-npm install
-npm run serve
diff --git a/examples/closures/index.js b/examples/closures/index.js
index cc27e0576d7..5fb5aa35598 100644
--- a/examples/closures/index.js
+++ b/examples/closures/index.js
@@ -1,4 +1,4 @@
// For more comments about what's going on here, check out the `hello_world`
// example
-import('./closures')
+import('./pkg/closures')
.catch(console.error);
diff --git a/examples/closures/package.json b/examples/closures/package.json
index 806119cdb5b..9fafb189ee8 100644
--- a/examples/closures/package.json
+++ b/examples/closures/package.json
@@ -4,6 +4,7 @@
"serve": "webpack-dev-server"
},
"devDependencies": {
+ "@wasm-tool/wasm-pack-plugin": "0.2.1",
"text-encoding": "^0.7.0",
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.11.1",
diff --git a/examples/closures/webpack.config.js b/examples/closures/webpack.config.js
index f15dc6b56d9..a6f6e1e930d 100644
--- a/examples/closures/webpack.config.js
+++ b/examples/closures/webpack.config.js
@@ -1,6 +1,7 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
+const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
module.exports = {
entry: './index.js',
@@ -9,8 +10,9 @@ module.exports = {
filename: 'index.js',
},
plugins: [
- new HtmlWebpackPlugin({
- template: "index.html"
+ new HtmlWebpackPlugin(),
+ new WasmPackPlugin({
+ crateDirectory: path.resolve(__dirname, ".")
}),
// Have this example work in Edge which doesn't ship `TextEncoder` or
// `TextDecoder` at this time.
diff --git a/examples/console_log/.gitignore b/examples/console_log/.gitignore
deleted file mode 100644
index 4fd1390e0ab..00000000000
--- a/examples/console_log/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-package-lock.json
-console_log.js
-console_log_bg.js
-console_log_bg.wasm
diff --git a/examples/console_log/README.md b/examples/console_log/README.md
index c72b418cded..32fa8d49b96 100644
--- a/examples/console_log/README.md
+++ b/examples/console_log/README.md
@@ -9,9 +9,7 @@ online][compiled]
You can build the example locally with:
```
-$ ./build.sh
+$ npm run serve
```
-(or running the commands on Windows manually)
-
and then visiting http://localhost:8080 in a browser should run the example!
diff --git a/examples/console_log/build.sh b/examples/console_log/build.sh
deleted file mode 100755
index f2594d41ca3..00000000000
--- a/examples/console_log/build.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-
-# For more comments about what's going on here, see the `hello_world` example
-
-set -ex
-
-cargo build --target wasm32-unknown-unknown
-cargo run --manifest-path ../../crates/cli/Cargo.toml \
- --bin wasm-bindgen -- \
- ../../target/wasm32-unknown-unknown/debug/console_log.wasm --out-dir .
-npm install
-npm run serve
diff --git a/examples/console_log/index.js b/examples/console_log/index.js
index 824c1371baa..f3dafbcba0b 100644
--- a/examples/console_log/index.js
+++ b/examples/console_log/index.js
@@ -1,4 +1,4 @@
// For more comments about what's going on here, check out the `hello_world`
// example
-import('./console_log')
+import('./pkg/console_log')
.catch(console.error);
diff --git a/examples/console_log/package.json b/examples/console_log/package.json
index 806119cdb5b..9fafb189ee8 100644
--- a/examples/console_log/package.json
+++ b/examples/console_log/package.json
@@ -4,6 +4,7 @@
"serve": "webpack-dev-server"
},
"devDependencies": {
+ "@wasm-tool/wasm-pack-plugin": "0.2.1",
"text-encoding": "^0.7.0",
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.11.1",
diff --git a/examples/console_log/webpack.config.js b/examples/console_log/webpack.config.js
index f15dc6b56d9..a6f6e1e930d 100644
--- a/examples/console_log/webpack.config.js
+++ b/examples/console_log/webpack.config.js
@@ -1,6 +1,7 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
+const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
module.exports = {
entry: './index.js',
@@ -9,8 +10,9 @@ module.exports = {
filename: 'index.js',
},
plugins: [
- new HtmlWebpackPlugin({
- template: "index.html"
+ new HtmlWebpackPlugin(),
+ new WasmPackPlugin({
+ crateDirectory: path.resolve(__dirname, ".")
}),
// Have this example work in Edge which doesn't ship `TextEncoder` or
// `TextDecoder` at this time.
diff --git a/examples/dom/.gitignore b/examples/dom/.gitignore
deleted file mode 100644
index 1fbaedd8631..00000000000
--- a/examples/dom/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-package-lock.json
-dom.js
-dom_bg.js
-dom_bg.wasm
diff --git a/examples/dom/README.md b/examples/dom/README.md
index 6fd6c3727b1..2a7f678914a 100644
--- a/examples/dom/README.md
+++ b/examples/dom/README.md
@@ -9,9 +9,7 @@ online][compiled]
You can build the example locally with:
```
-$ ./build.sh
+$ npm run serve
```
-(or running the commands on Windows manually)
-
and then visiting http://localhost:8080 in a browser should run the example!
diff --git a/examples/dom/build.sh b/examples/dom/build.sh
deleted file mode 100755
index 0b5e4b65a1a..00000000000
--- a/examples/dom/build.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-
-# For more comments about what's going on here, see the `hello_world` example
-
-set -ex
-
-cargo build --target wasm32-unknown-unknown
-cargo run --manifest-path ../../crates/cli/Cargo.toml \
- --bin wasm-bindgen -- \
- ../../target/wasm32-unknown-unknown/debug/dom.wasm --out-dir .
-npm install
-npm run serve
diff --git a/examples/dom/index.js b/examples/dom/index.js
index 0d74f2fa82f..7defc51d681 100644
--- a/examples/dom/index.js
+++ b/examples/dom/index.js
@@ -1,4 +1,4 @@
// For more comments about what's going on here, check out the `hello_world`
// example
-import('./dom')
+import('./pkg/dom')
.catch(console.error);
diff --git a/examples/dom/package.json b/examples/dom/package.json
index 806119cdb5b..9fafb189ee8 100644
--- a/examples/dom/package.json
+++ b/examples/dom/package.json
@@ -4,6 +4,7 @@
"serve": "webpack-dev-server"
},
"devDependencies": {
+ "@wasm-tool/wasm-pack-plugin": "0.2.1",
"text-encoding": "^0.7.0",
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.11.1",
diff --git a/examples/dom/webpack.config.js b/examples/dom/webpack.config.js
index f15dc6b56d9..25afd18002a 100644
--- a/examples/dom/webpack.config.js
+++ b/examples/dom/webpack.config.js
@@ -1,6 +1,7 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
+const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
module.exports = {
entry: './index.js',
@@ -10,7 +11,10 @@ module.exports = {
},
plugins: [
new HtmlWebpackPlugin({
- template: "index.html"
+ template: 'index.html'
+ }),
+ new WasmPackPlugin({
+ crateDirectory: path.resolve(__dirname, ".")
}),
// Have this example work in Edge which doesn't ship `TextEncoder` or
// `TextDecoder` at this time.
diff --git a/examples/duck-typed-interfaces/.gitignore b/examples/duck-typed-interfaces/.gitignore
deleted file mode 100644
index 2a3ddc1528a..00000000000
--- a/examples/duck-typed-interfaces/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-package-lock.json
-rust_duck_typed_interfaces.js
-rust_duck_typed_interfaces_bg.js
-rust_duck_typed_interfaces_bg.wasm
diff --git a/examples/duck-typed-interfaces/README.md b/examples/duck-typed-interfaces/README.md
index 5cd195e5111..f237bdbcf25 100644
--- a/examples/duck-typed-interfaces/README.md
+++ b/examples/duck-typed-interfaces/README.md
@@ -5,10 +5,8 @@ This directory is an example of using duck-typed JS interfaces with `wasm-bindge
You can build and run the example with:
```
-$ ./build.sh
+$ npm run serve
```
-(or running the commands on Windows manually)
-
and then opening up `http://localhost:8080/` in a web browser should show a
smiley face drawn on canvas by Rust and WebAssembly.
diff --git a/examples/duck-typed-interfaces/build.sh b/examples/duck-typed-interfaces/build.sh
deleted file mode 100755
index c0ffd7cf11f..00000000000
--- a/examples/duck-typed-interfaces/build.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-# For more comments about what's going on here, see the `hello_world` example
-
-set -ex
-cd "$(dirname $0)"
-
-cargo build --target wasm32-unknown-unknown
-
-cargo run --manifest-path ../../crates/cli/Cargo.toml \
- --bin wasm-bindgen -- \
- ../../target/wasm32-unknown-unknown/debug/rust_duck_typed_interfaces.wasm --out-dir .
-
-npm install
-npm run serve
diff --git a/examples/duck-typed-interfaces/index.js b/examples/duck-typed-interfaces/index.js
index fe8a21ef45c..beb99169cd2 100644
--- a/examples/duck-typed-interfaces/index.js
+++ b/examples/duck-typed-interfaces/index.js
@@ -1,3 +1,3 @@
// For more comments about what's going on here, check out the `hello_world`
// example.
-import('./duck-typed-interfaces');
+import('./pkg/rust_duck_typed_interfaces');
diff --git a/examples/duck-typed-interfaces/package.json b/examples/duck-typed-interfaces/package.json
index 806119cdb5b..9fafb189ee8 100644
--- a/examples/duck-typed-interfaces/package.json
+++ b/examples/duck-typed-interfaces/package.json
@@ -4,6 +4,7 @@
"serve": "webpack-dev-server"
},
"devDependencies": {
+ "@wasm-tool/wasm-pack-plugin": "0.2.1",
"text-encoding": "^0.7.0",
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.11.1",
diff --git a/examples/duck-typed-interfaces/webpack.config.js b/examples/duck-typed-interfaces/webpack.config.js
index 53396f30f8a..25afd18002a 100644
--- a/examples/duck-typed-interfaces/webpack.config.js
+++ b/examples/duck-typed-interfaces/webpack.config.js
@@ -1,6 +1,7 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
+const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
module.exports = {
entry: './index.js',
@@ -9,7 +10,12 @@ module.exports = {
filename: 'index.js',
},
plugins: [
- new HtmlWebpackPlugin(),
+ new HtmlWebpackPlugin({
+ template: 'index.html'
+ }),
+ new WasmPackPlugin({
+ crateDirectory: path.resolve(__dirname, ".")
+ }),
// Have this example work in Edge which doesn't ship `TextEncoder` or
// `TextDecoder` at this time.
new webpack.ProvidePlugin({
diff --git a/examples/fetch/.gitignore b/examples/fetch/.gitignore
deleted file mode 100644
index cf66a5724f3..00000000000
--- a/examples/fetch/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-fetch.d.ts
-fetch.js
-fetch_bg.wasm
-package-lock.json
diff --git a/examples/fetch/README.md b/examples/fetch/README.md
index c339289623d..a3563373752 100644
--- a/examples/fetch/README.md
+++ b/examples/fetch/README.md
@@ -9,10 +9,7 @@ online][compiled]
You can build the example locally with:
```
-$ ./build.sh
+$ npm run serve
```
-(or running the commands on Windows manually)
-
and then visiting http://localhost:8080 in a browser should run the example!
-
diff --git a/examples/fetch/build.sh b/examples/fetch/build.sh
deleted file mode 100755
index ffaaf4f98b3..00000000000
--- a/examples/fetch/build.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh
-
-# For more comments about what's going on here, see the `hello_world` example
-
-set -ex
-
-cargo build --target wasm32-unknown-unknown
-cargo run --manifest-path ../../crates/cli/Cargo.toml \
- --bin wasm-bindgen -- \
- ../../target/wasm32-unknown-unknown/debug/fetch.wasm --out-dir .
-
-npm install
-npm run serve
diff --git a/examples/fetch/index.js b/examples/fetch/index.js
index 7a525f1c39c..16c31681da3 100644
--- a/examples/fetch/index.js
+++ b/examples/fetch/index.js
@@ -1,8 +1,8 @@
-const rust = import('./fetch');
+const rust = import('./pkg/fetch');
rust
.then(m => {
- m.run().then((data) => {
+ return m.run().then((data) => {
console.log(data);
console.log("The latest commit to the wasm-bindgen %s branch is:", data.name);
diff --git a/examples/fetch/package.json b/examples/fetch/package.json
index 806119cdb5b..9fafb189ee8 100644
--- a/examples/fetch/package.json
+++ b/examples/fetch/package.json
@@ -4,6 +4,7 @@
"serve": "webpack-dev-server"
},
"devDependencies": {
+ "@wasm-tool/wasm-pack-plugin": "0.2.1",
"text-encoding": "^0.7.0",
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.11.1",
diff --git a/examples/fetch/webpack.config.js b/examples/fetch/webpack.config.js
index 53396f30f8a..a6f6e1e930d 100644
--- a/examples/fetch/webpack.config.js
+++ b/examples/fetch/webpack.config.js
@@ -1,6 +1,7 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
+const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
module.exports = {
entry: './index.js',
@@ -10,6 +11,9 @@ module.exports = {
},
plugins: [
new HtmlWebpackPlugin(),
+ new WasmPackPlugin({
+ crateDirectory: path.resolve(__dirname, ".")
+ }),
// Have this example work in Edge which doesn't ship `TextEncoder` or
// `TextDecoder` at this time.
new webpack.ProvidePlugin({
diff --git a/examples/guide-supported-types-examples/.gitignore b/examples/guide-supported-types-examples/.gitignore
deleted file mode 100644
index d0b14fad7d9..00000000000
--- a/examples/guide-supported-types-examples/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-package-lock.json
-guide_supported_types_examples.js
-guide_supported_types_examples_bg.wasm
diff --git a/examples/guide-supported-types-examples/build.sh b/examples/guide-supported-types-examples/build.sh
deleted file mode 100755
index 0ee158b88c8..00000000000
--- a/examples/guide-supported-types-examples/build.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-
-# For more comments about what's going on here, see the `hello_world` example
-
-set -ex
-
-cargo build --target wasm32-unknown-unknown --release
-cargo run --manifest-path ../../crates/cli/Cargo.toml \
- --bin wasm-bindgen -- \
- ../../target/wasm32-unknown-unknown/release/guide_supported_types_examples.wasm --out-dir .
-npm install
-npm run serve
diff --git a/examples/guide-supported-types-examples/index.js b/examples/guide-supported-types-examples/index.js
index a1819bb5f83..c5969879e2e 100644
--- a/examples/guide-supported-types-examples/index.js
+++ b/examples/guide-supported-types-examples/index.js
@@ -1,5 +1,5 @@
// For more comments about what's going on here, check out the `hello_world`
// example
-import('./bootstrap').then(() => {
- console.log("done");
-});
+// import('./pkg/bootstrap').then(() => {
+// console.log("done");
+// });
diff --git a/examples/guide-supported-types-examples/package.json b/examples/guide-supported-types-examples/package.json
index 806119cdb5b..9fafb189ee8 100644
--- a/examples/guide-supported-types-examples/package.json
+++ b/examples/guide-supported-types-examples/package.json
@@ -4,6 +4,7 @@
"serve": "webpack-dev-server"
},
"devDependencies": {
+ "@wasm-tool/wasm-pack-plugin": "0.2.1",
"text-encoding": "^0.7.0",
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.11.1",
diff --git a/examples/guide-supported-types-examples/webpack.config.js b/examples/guide-supported-types-examples/webpack.config.js
index 53396f30f8a..a6f6e1e930d 100644
--- a/examples/guide-supported-types-examples/webpack.config.js
+++ b/examples/guide-supported-types-examples/webpack.config.js
@@ -1,6 +1,7 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
+const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
module.exports = {
entry: './index.js',
@@ -10,6 +11,9 @@ module.exports = {
},
plugins: [
new HtmlWebpackPlugin(),
+ new WasmPackPlugin({
+ crateDirectory: path.resolve(__dirname, ".")
+ }),
// Have this example work in Edge which doesn't ship `TextEncoder` or
// `TextDecoder` at this time.
new webpack.ProvidePlugin({
diff --git a/examples/hello_world/.gitignore b/examples/hello_world/.gitignore
deleted file mode 100644
index f5974ab0b6b..00000000000
--- a/examples/hello_world/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-package-lock.json
-hello_world.js
-hello_world_bg.js
-hello_world_bg.wasm
diff --git a/examples/hello_world/README.md b/examples/hello_world/README.md
index 74eda63cc2a..efaca0de014 100644
--- a/examples/hello_world/README.md
+++ b/examples/hello_world/README.md
@@ -9,9 +9,7 @@ online][compiled]
You can build the example locally with:
```
-$ ./build.sh
+$ npm run serve
```
-(or running the commands on Windows manually)
-
-and then visiting http://localhost:8080 in a browser should show a dialog!
+and then visiting http://localhost:8080 in a browser should run the example!
diff --git a/examples/hello_world/build.sh b/examples/hello_world/build.sh
deleted file mode 100755
index 38691904169..00000000000
--- a/examples/hello_world/build.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-
-set -ex
-
-# Build the `hello_world.wasm` file using Cargo/rustc
-cargo build --target wasm32-unknown-unknown
-
-# Run the `wasm-bindgen` CLI tool to postprocess the wasm file emitted by the
-# Rust compiler to emit the JS support glue that's necessary
-#
-# Here we're using the version of the CLI in this repository, but for external
-# usage you'd use the commented out version below
-cargo run --manifest-path ../../crates/cli/Cargo.toml \
- --bin wasm-bindgen -- \
- ../../target/wasm32-unknown-unknown/debug/hello_world.wasm --out-dir .
-# wasm-bindgen ../../target/wasm32-unknown-unknown/hello_world.wasm --out-dir .
-
-# Finally, package everything up using Webpack and start a server so we can
-# browse the result
-npm install
-npm run serve
diff --git a/examples/hello_world/index.js b/examples/hello_world/index.js
index 99946b153a4..d7d7a65a27d 100644
--- a/examples/hello_world/index.js
+++ b/examples/hello_world/index.js
@@ -1,7 +1,7 @@
// Note that a dynamic `import` statement here is required due to
-// webpack/webpack#6615, but in theory `import { greet } from './hello_world';`
+// webpack/webpack#6615, but in theory `import { greet } from './pkg/hello_world';`
// will work here one day as well!
-const rust = import('./hello_world');
+const rust = import('./pkg/hello_world');
rust
.then(m => m.greet('World!'))
diff --git a/examples/hello_world/package.json b/examples/hello_world/package.json
index 806119cdb5b..9fafb189ee8 100644
--- a/examples/hello_world/package.json
+++ b/examples/hello_world/package.json
@@ -4,6 +4,7 @@
"serve": "webpack-dev-server"
},
"devDependencies": {
+ "@wasm-tool/wasm-pack-plugin": "0.2.1",
"text-encoding": "^0.7.0",
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.11.1",
diff --git a/examples/hello_world/webpack.config.js b/examples/hello_world/webpack.config.js
index 53396f30f8a..a6f6e1e930d 100644
--- a/examples/hello_world/webpack.config.js
+++ b/examples/hello_world/webpack.config.js
@@ -1,6 +1,7 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
+const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
module.exports = {
entry: './index.js',
@@ -10,6 +11,9 @@ module.exports = {
},
plugins: [
new HtmlWebpackPlugin(),
+ new WasmPackPlugin({
+ crateDirectory: path.resolve(__dirname, ".")
+ }),
// Have this example work in Edge which doesn't ship `TextEncoder` or
// `TextDecoder` at this time.
new webpack.ProvidePlugin({
diff --git a/examples/import_js/.gitignore b/examples/import_js/.gitignore
deleted file mode 100644
index bd9c9eb38cf..00000000000
--- a/examples/import_js/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-package-lock.json
-import_js.js
-import_js_bg.js
-import_js_bg.wasm
diff --git a/examples/import_js/README.md b/examples/import_js/README.md
index a8badf7ab05..7a4249eda9a 100644
--- a/examples/import_js/README.md
+++ b/examples/import_js/README.md
@@ -9,9 +9,7 @@ online][compiled]
You can build the example locally with:
```
-$ ./build.sh
+$ npm run serve
```
-(or running the commands on Windows manually)
-
and then visiting http://localhost:8080 in a browser should run the example!
diff --git a/examples/import_js/build.sh b/examples/import_js/build.sh
deleted file mode 100755
index 754509cbb95..00000000000
--- a/examples/import_js/build.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-
-# For more comments about what's going on here, see the `hello_world` example
-
-set -ex
-
-cargo build --target wasm32-unknown-unknown
-cargo run --manifest-path ../../crates/cli/Cargo.toml \
- --bin wasm-bindgen -- \
- ../../target/wasm32-unknown-unknown/debug/import_js.wasm --out-dir .
-npm install
-npm run serve
diff --git a/examples/import_js/index.js b/examples/import_js/index.js
index 9d7e3b1a1ca..0c41f50d3d6 100644
--- a/examples/import_js/index.js
+++ b/examples/import_js/index.js
@@ -1,4 +1,4 @@
// For more comments about what's going on here, check out the `hello_world`
// example
-import('./import_js')
+import('./pkg/import_js')
.catch(console.error);
diff --git a/examples/import_js/package.json b/examples/import_js/package.json
index 806119cdb5b..9fafb189ee8 100644
--- a/examples/import_js/package.json
+++ b/examples/import_js/package.json
@@ -4,6 +4,7 @@
"serve": "webpack-dev-server"
},
"devDependencies": {
+ "@wasm-tool/wasm-pack-plugin": "0.2.1",
"text-encoding": "^0.7.0",
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.11.1",
diff --git a/examples/import_js/src/lib.rs b/examples/import_js/src/lib.rs
index a010ca93ce1..365eddcef44 100644
--- a/examples/import_js/src/lib.rs
+++ b/examples/import_js/src/lib.rs
@@ -1,6 +1,6 @@
use wasm_bindgen::prelude::*;
-#[wasm_bindgen(module = "./defined-in-js")]
+#[wasm_bindgen(module = "../defined-in-js")]
extern "C" {
fn name() -> String;
diff --git a/examples/import_js/webpack.config.js b/examples/import_js/webpack.config.js
index f15dc6b56d9..25afd18002a 100644
--- a/examples/import_js/webpack.config.js
+++ b/examples/import_js/webpack.config.js
@@ -1,6 +1,7 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
+const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
module.exports = {
entry: './index.js',
@@ -10,7 +11,10 @@ module.exports = {
},
plugins: [
new HtmlWebpackPlugin({
- template: "index.html"
+ template: 'index.html'
+ }),
+ new WasmPackPlugin({
+ crateDirectory: path.resolve(__dirname, ".")
}),
// Have this example work in Edge which doesn't ship `TextEncoder` or
// `TextDecoder` at this time.
diff --git a/examples/julia_set/.gitignore b/examples/julia_set/.gitignore
deleted file mode 100644
index b76bec79eb0..00000000000
--- a/examples/julia_set/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-julia_set.js
-julia_set_bg.wasm
\ No newline at end of file
diff --git a/examples/julia_set/README.md b/examples/julia_set/README.md
index 64d37e237a1..913ad8c8d17 100644
--- a/examples/julia_set/README.md
+++ b/examples/julia_set/README.md
@@ -9,9 +9,7 @@ online][compiled]
You can build the example locally with:
```
-$ ./build.sh
+$ npm run serve
```
-(or running the commands on Windows manually)
-
and then visiting http://localhost:8080 in a browser should run the example!
diff --git a/examples/julia_set/build.sh b/examples/julia_set/build.sh
deleted file mode 100755
index 8c887ffb300..00000000000
--- a/examples/julia_set/build.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-
-# For more comments about what's going on here, see the `hello_world` example
-
-set -ex
-
-cargo build --target wasm32-unknown-unknown --release
-cargo run --manifest-path ../../crates/cli/Cargo.toml \
- --bin wasm-bindgen -- \
- ../../target/wasm32-unknown-unknown/release/julia_set.wasm --out-dir .
-npm install
-npm run serve
diff --git a/examples/julia_set/index.js b/examples/julia_set/index.js
index 881047310d9..4e721fe7a7e 100644
--- a/examples/julia_set/index.js
+++ b/examples/julia_set/index.js
@@ -1,4 +1,4 @@
-import('./julia_set')
+import('./pkg/julia_set')
.then(wasm => {
const canvas = document.getElementById('drawing');
const ctx = canvas.getContext('2d');
diff --git a/examples/julia_set/package.json b/examples/julia_set/package.json
index 806119cdb5b..9fafb189ee8 100644
--- a/examples/julia_set/package.json
+++ b/examples/julia_set/package.json
@@ -4,6 +4,7 @@
"serve": "webpack-dev-server"
},
"devDependencies": {
+ "@wasm-tool/wasm-pack-plugin": "0.2.1",
"text-encoding": "^0.7.0",
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.11.1",
diff --git a/examples/julia_set/webpack.config.js b/examples/julia_set/webpack.config.js
index f15dc6b56d9..25afd18002a 100644
--- a/examples/julia_set/webpack.config.js
+++ b/examples/julia_set/webpack.config.js
@@ -1,6 +1,7 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
+const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
module.exports = {
entry: './index.js',
@@ -10,7 +11,10 @@ module.exports = {
},
plugins: [
new HtmlWebpackPlugin({
- template: "index.html"
+ template: 'index.html'
+ }),
+ new WasmPackPlugin({
+ crateDirectory: path.resolve(__dirname, ".")
}),
// Have this example work in Edge which doesn't ship `TextEncoder` or
// `TextDecoder` at this time.
diff --git a/examples/no_modules/.gitignore b/examples/no_modules/.gitignore
deleted file mode 100644
index fe50a54856c..00000000000
--- a/examples/no_modules/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-no_modules.js
-no_modules_bg.wasm
diff --git a/examples/no_modules/README.md b/examples/no_modules/README.md
index c6eb48838b1..54f66e9c2e6 100644
--- a/examples/no_modules/README.md
+++ b/examples/no_modules/README.md
@@ -7,9 +7,7 @@
You can build the example locally with:
```
-$ ./build.sh
+$ wasm-pack build --target no-modules
```
-(or running the commands on Windows manually)
-
and then opening `index.html` in a browser should run the example!
diff --git a/examples/no_modules/build.sh b/examples/no_modules/build.sh
deleted file mode 100755
index 987e01e1e80..00000000000
--- a/examples/no_modules/build.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-
-set -ex
-
-cargo build --target wasm32-unknown-unknown
-
-cargo run --manifest-path ../../crates/cli/Cargo.toml \
- --bin wasm-bindgen -- \
- --no-modules \
- ../../target/wasm32-unknown-unknown/debug/no_modules.wasm --out-dir .
-
-python -m SimpleHTTPServer
diff --git a/examples/no_modules/index.html b/examples/no_modules/index.html
index 50193bc3629..979a8621242 100644
--- a/examples/no_modules/index.html
+++ b/examples/no_modules/index.html
@@ -17,7 +17,7 @@
-
+