Comments (7)
@marienz You should be able to workaround the Webpack loading issue by doing this.
I think it would be a good idea for us to include some documentation on how to use wasm-bindgen with Angular.
from wasm_game_of_life.
Got it to work in Angular 8 (without resorting to no-modules
) by using @angular-builders/custom-webpack. The only thing I had to put in extra-webpack.config.js was module.exports = {'resolve': {'extensions': ['.wasm']}};
(I suspect if we get that added here it'll work out of the box).
One slight annoyance is that just importing the wasm-bindgen-generated module triggers a "WebAssembly module is included in initial chunk" error. I guess that's webpack/webpack#6615. Using import() to import the wasm-bindgen module (as suggested by the error message) does work. And I suspect if my import was in a lazily-loaded Angular module that'd also work around it, but I'm barely past "Hello World" in Angular... don't want to try breaking my app into modules before I've actually gotten it to work :)
(It also warns about the circular dependency between the wasm module and the generated js module, I think that's the same thing described on rustwasm/wasm-bindgen#32 and I'll just have to ignore it.)
from wasm_game_of_life.
Does angular use its own bundler or something? I'm not sure what is different about it compared to normal JS applications.
You can always use the web
or no-modules
target and include a <script>
before the rest of your app, and use the wasm library from the global scope.
https://rustwasm.github.io/docs/wasm-bindgen/examples/without-a-bundler.html
from wasm_game_of_life.
@fitzgen Thank you, I have solved it by following your advice.
from wasm_game_of_life.
This is why it does not work with Angular out of the box:
rustwasm/wasm-bindgen#806
Altough I have no idea how to add this extension to the angular.json
and using no-modules
is not the best solution. 😞
from wasm_game_of_life.
angular/angular-cli#14987 was opened a few days ago for getting that extension added in Angular.
from wasm_game_of_life.
That's a trick I wouldn't have thought of, thanks!
from wasm_game_of_life.
Related Issues (20)
- Tutorial does not work due to outdated npm depenencies HOT 3
- SOS: macro_rules log not working. need a correct example
- Write up a CONTRIBUTING.md
- Tutorial link in README is broken
- The instructions in `Sending pull requests` are not clear enough HOT 2
- Webpack error when parsing the wasm file HOT 8
- Unable to build with 'npm run build-debug' in step 8.1.1 HOT 1
- Remove submodules and make only the Ch 3 code in the book
- npm install in chapter-zero warns of high severity vulnerabilities HOT 4
- wasm-bindgen dependency in Cargo.toml is out of date in chapter-zero HOT 3
- "npm init wasm-app www" doesn't produce a www-directory HOT 11
- "npm link" results in "permission denied" HOT 5
- Wasm-pack init takes too long HOT 1
- Missing dependecy in www/package.json HOT 10
- Not able to get passed piping string into javascript HOT 5
- Error on last step of tutorial section 5.1 HOT 2
- "npm init wasm-app www" fails HOT 3
- Move more parts of the tutorial to rust HOT 4
- Build and run instructions HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wasm_game_of_life.