├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── approve.yml │ ├── book.yml │ ├── release.yml │ └── test.yml ├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Cargo.lock ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── RELEASE_CHECKLIST.md ├── clippy.toml ├── demo.gif ├── docs ├── _installer │ ├── build-installer.rs │ ├── index.html │ ├── init.sh │ └── wasm-pack.js ├── _theme │ └── header.hbs ├── android-chrome-192x192.png ├── android-chrome-384x384.png ├── apple-touch-icon.png ├── book.toml ├── browserconfig.xml ├── favicon-16x16.png ├── favicon-32x32.png ├── favicon.ico ├── index.html ├── mstile-150x150.png ├── public │ ├── custom.css │ └── img │ │ ├── rustwasm.png │ │ └── wasm-ferris.png ├── safari-pinned-tab.svg ├── site.webmanifest └── src │ ├── SUMMARY.md │ ├── cargo-toml-configuration.md │ ├── commands │ ├── build.md │ ├── index.md │ ├── init.md │ ├── new.md │ ├── pack-and-publish.md │ └── test.md │ ├── contributing.md │ ├── introduction.md │ ├── prerequisites │ ├── considerations.md │ ├── index.md │ ├── non-rustup-setups.md │ └── npm.md │ ├── quickstart.md │ └── tutorials │ ├── hybrid-applications-with-webpack │ ├── getting-started.md │ ├── index.md │ └── using-your-library.md │ ├── index.md │ ├── npm-browser-packages │ ├── building-your-project.md │ ├── getting-started.md │ ├── getting-started │ │ └── manual-setup.md │ ├── index.md │ ├── packaging-and-publishing.md │ ├── template-deep-dive │ │ ├── building-your-project.md │ │ ├── cargo-toml.md │ │ ├── index.md │ │ ├── src-lib-rs.md │ │ ├── src-utils-rs.md │ │ ├── tests-web-rs.md │ │ └── wee_alloc.md │ ├── testing-your-project.md │ └── using-your-library.md │ └── standalone-wasm-binaries │ └── index.md ├── npm ├── .gitignore ├── README.md ├── binary.js ├── install.js ├── package.json ├── run.js └── yarn.lock ├── src ├── bindgen.rs ├── build │ ├── mod.rs │ └── wasm_target.rs ├── cache.rs ├── child.rs ├── command │ ├── build.rs │ ├── generate.rs │ ├── login.rs │ ├── mod.rs │ ├── pack.rs │ ├── publish │ │ ├── access.rs │ │ └── mod.rs │ ├── test.rs │ └── utils.rs ├── emoji.rs ├── generate.rs ├── install │ ├── arch.rs │ ├── krate.rs │ ├── mod.rs │ ├── mode.rs │ ├── os.rs │ └── tool.rs ├── installer.rs ├── lib.rs ├── license.rs ├── lockfile.rs ├── main.rs ├── manifest │ ├── mod.rs │ └── npm │ │ ├── commonjs.rs │ │ ├── esmodules.rs │ │ ├── mod.rs │ │ ├── nomodules.rs │ │ └── repository.rs ├── npm.rs ├── progressbar.rs ├── readme.rs ├── stamps.rs ├── target.rs ├── test │ ├── mod.rs │ ├── webdriver.rs │ └── webdriver │ │ ├── chromedriver.rs │ │ ├── geckodriver.rs │ │ └── safaridriver.rs └── wasm_opt.rs └── tests └── all ├── build.rs ├── download.rs ├── generate.rs ├── license.rs ├── lockfile.rs ├── log_level.rs ├── main.rs ├── manifest.rs ├── readme.rs ├── stamps.rs ├── test.rs ├── utils ├── file.rs ├── fixture.rs ├── manifest.rs └── mod.rs ├── wasm_opt.rs └── webdriver.rs /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 🐛 3 | about: Did something not work as expected? 4 | --- 5 | 6 | ## 🐛 Bug description 7 | Describe your issue in detail. 8 | 9 | #### 🤔 Expected Behavior 10 | What should have happened? 11 | 12 | #### 👟 Steps to reproduce 13 | Clear steps describing how to reproduce the issue, including commands and flags run. If you are seeing an error, please include the full error message and stack trace. 14 | 15 | #### 🌍 Your environment 16 | Include the relevant details of your environment. 17 | wasm-pack version: 18 | rustc version: -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 💡 3 | about: Suggest a new idea for wasm-pack 4 | --- 5 | 6 | ## 💡 Feature description 7 | Brief explanation of the requested feature. 8 | 9 | #### 💻 Basic example 10 | Include a basic code example if possible. Omit this section if not applicable. -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Make sure these boxes are checked! 📦✅ 2 | 3 | - [ ] You have the latest version of `rustfmt` installed 4 | ```bash 5 | $ rustup component add rustfmt 6 | ``` 7 | - [ ] You ran `cargo fmt` on the code base before submitting 8 | - [ ] You reference which issue is being closed in the PR text 9 | 10 | ✨✨ 😄 Thanks so much for contributing to wasm-pack! 😄 ✨✨ 11 | -------------------------------------------------------------------------------- /.github/workflows/approve.yml: -------------------------------------------------------------------------------- 1 | name: Automatic Approve 2 | on: 3 | schedule: 4 | - cron: "0 0 * * *" 5 | workflow_dispatch: 6 | jobs: 7 | automatic-approve: 8 | name: Automatic Approve 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Automatic Approve 12 | uses: mheap/automatic-approve-action@v1.1.0 13 | with: 14 | token: ${{ secrets.GITHUB_TOKEN }} 15 | workflows: "test.yml" 16 | -------------------------------------------------------------------------------- /.github/workflows/book.yml: -------------------------------------------------------------------------------- 1 | name: Build and deploy documentation book 2 | 3 | on: 4 | push: 5 | pull_request: 6 | 7 | jobs: 8 | book: 9 | name: Build and deploy book 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v3 13 | - uses: dtolnay/rust-toolchain@stable 14 | with: 15 | toolchain: stable 16 | 17 | - name: Cache dependencies 18 | uses: actions/cache@v3 19 | env: 20 | cache-name: cache-mdbook 21 | with: 22 | path: | 23 | ~/.cargo/.crates.toml 24 | ~/.cargo/.crates2.json 25 | ~/.cargo/bin 26 | ~/.cargo/registry/index 27 | ~/.cargo/registry/cache 28 | key: ${{ runner.os }}-build-${{ env.cache-name }}-0.3 }} 29 | 30 | - name: Install mdbook 31 | run: | 32 | (test -x $HOME/.cargo/bin/cargo-install-update || cargo install cargo-update) 33 | (test -x $HOME/.cargo/bin/mdbook || cargo install --vers "^0.4" mdbook) 34 | cargo install-update -a 35 | 36 | - name: Build book 37 | run: | 38 | mdbook --version 39 | (cd docs && mv _theme theme && mdbook build) 40 | rustc ./docs/_installer/build-installer.rs 41 | ./build-installer 42 | 43 | - name: Deploy book 44 | uses: JamesIves/github-pages-deploy-action@v4.4.1 45 | if: ${{ github.ref == 'refs/heads/master' }} 46 | with: 47 | branch: gh-pages 48 | folder: docs 49 | token: ${{ secrets.GITHUB_TOKEN }} 50 | single-commit: true 51 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | branches: 9 | - master 10 | 11 | jobs: 12 | test: 13 | name: Test 14 | 15 | runs-on: ${{ matrix.os }} 16 | strategy: 17 | matrix: 18 | build: [linux-stable, macos-stable, windows-stable] 19 | include: 20 | - build: linux-stable 21 | os: ubuntu-latest 22 | rust: stable 23 | - build: macos-stable 24 | os: macos-latest 25 | rust: stable 26 | - build: windows-stable 27 | os: windows-latest 28 | rust: stable 29 | 30 | steps: 31 | - uses: actions/checkout@v3 32 | - uses: nanasess/setup-chromedriver@master 33 | - if: matrix.os == 'macos-latest' 34 | run: brew install --cask firefox 35 | - uses: dtolnay/rust-toolchain@stable 36 | with: 37 | toolchain: ${{ matrix.rust }} 38 | targets: wasm32-unknown-unknown 39 | - uses: actions/setup-node@v2 40 | 41 | - name: Cache dependencies 42 | uses: actions/cache@v3 43 | env: 44 | cache-name: cache-dependencies 45 | with: 46 | path: | 47 | ~/.cargo/.crates.toml 48 | ~/.cargo/.crates2.json 49 | ~/.cargo/bin 50 | ~/.cargo/registry/index 51 | ~/.cargo/registry/cache 52 | target 53 | key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }} 54 | 55 | - name: Run Tests 56 | run: cargo test --all --locked 57 | env: 58 | RUST_BACKTRACE: 1 59 | 60 | - name: Clippy 61 | run: cargo clippy 62 | 63 | - name: Cargo fmt 64 | run: cargo fmt --all -- --check 65 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | **/*.rs.bk 3 | tests/.crates.toml 4 | tests/bin 5 | /build-installer 6 | docs/book 7 | docs/installer 8 | 9 | .idea 10 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # The Rust Code of Conduct 2 | 3 | A version of this document [can be found online](https://www.rust-lang.org/conduct.html). 4 | 5 | ## Conduct 6 | 7 | **Contact**: [rust-mods@rust-lang.org](mailto:rust-mods@rust-lang.org) 8 | 9 | * We are committed to providing a friendly, safe and welcoming environment for all, regardless of level of experience, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, nationality, or other similar characteristic. 10 | * On IRC, please avoid using overtly sexual nicknames or other nicknames that might detract from a friendly, safe and welcoming environment for all. 11 | * Please be kind and courteous. There's no need to be mean or rude. 12 | * Respect that people have differences of opinion and that every design or implementation choice carries a trade-off and numerous costs. There is seldom a right answer. 13 | * Please keep unstructured critique to a minimum. If you have solid ideas you want to experiment with, make a fork and see how it works. 14 | * We will exclude you from interaction if you insult, demean or harass anyone. That is not welcome behavior. We interpret the term "harassment" as including the definition in the Citizen Code of Conduct; if you have any lack of clarity about what might be included in that concept, please read their definition. In particular, we don't tolerate behavior that excludes people in socially marginalized groups. 15 | * Private harassment is also unacceptable. No matter who you are, if you feel you have been or are being harassed or made uncomfortable by a community member, please contact one of the channel ops or any of the [Rust moderation team][mod_team] immediately. Whether you're a regular contributor or a newcomer, we care about making this community a safe place for you and we've got your back. 16 | * Likewise any spamming, trolling, flaming, baiting or other attention-stealing behavior is not welcome. 17 | 18 | ## Moderation 19 | 20 | 21 | These are the policies for upholding our community's standards of conduct. If you feel that a thread needs moderation, please contact the [Rust moderation team][mod_team]. 22 | 23 | 1. Remarks that violate the Rust standards of conduct, including hateful, hurtful, oppressive, or exclusionary remarks, are not allowed. (Cursing is allowed, but never targeting another user, and never in a hateful manner.) 24 | 2. Remarks that moderators find inappropriate, whether listed in the code of conduct or not, are also not allowed. 25 | 3. Moderators will first respond to such remarks with a warning. 26 | 4. If the warning is unheeded, the user will be "kicked," i.e., kicked out of the communication channel to cool off. 27 | 5. If the user comes back and continues to make trouble, they will be banned, i.e., indefinitely excluded. 28 | 6. Moderators may choose at their discretion to un-ban the user if it was a first offense and they offer the offended party a genuine apology. 29 | 7. If a moderator bans someone and you think it was unjustified, please take it up with that moderator, or with a different moderator, **in private**. Complaints about bans in-channel are not allowed. 30 | 8. Moderators are held to a higher standard than other community members. If a moderator creates an inappropriate situation, they should expect less leeway than others. 31 | 32 | In the Rust community we strive to go the extra step to look out for each other. Don't just aim to be technically unimpeachable, try to be your best self. In particular, avoid flirting with offensive or sensitive issues, particularly if they're off-topic; this all too often leads to unnecessary fights, hurt feelings, and damaged trust; worse, it can drive people away from the community entirely. 33 | 34 | And if someone takes issue with something you said or did, resist the urge to be defensive. Just stop doing what it was they complained about and apologize. Even if you feel you were misinterpreted or unfairly accused, chances are good there was something you could've communicated better — remember that it's your responsibility to make your fellow Rustaceans comfortable. Everyone wants to get along and we are all here first and foremost because we want to talk about cool technology. You will find that people will be eager to assume good intent and forgive as long as you earn their trust. 35 | 36 | The enforcement policies listed above apply to all official Rust venues; including official IRC channels (#rust, #rust-internals, #rust-tools, #rust-libs, #rustc, #rust-beginners, #rust-docs, #rust-community, #rust-lang, and #cargo); GitHub repositories under rust-lang, rust-lang-nursery, and rust-lang-deprecated; and all forums under rust-lang.org (users.rust-lang.org, internals.rust-lang.org). For other projects adopting the Rust Code of Conduct, please contact the maintainers of those projects for enforcement. If you wish to use this code of conduct for your own project, consider explicitly mentioning your moderation policy or making a copy with your own moderation policy so as to avoid confusion. 37 | 38 | *Adapted from the [Node.js Policy on Trolling](http://blog.izs.me/post/30036893703/policy-on-trolling) as well as the [Contributor Covenant v1.3.0](https://www.contributor-covenant.org/version/1/3/0/).* 39 | 40 | [mod_team]: https://www.rust-lang.org/team.html#Moderation-team 41 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ## Filing an Issue 4 | 5 | If you are trying to use `wasm-pack` and run into an issue- please file an 6 | issue! We'd love to get you up and running, even if the issue you have might 7 | not be directly related to the code in `wasm-pack`. This tool seeks to make 8 | it easy for developers to get going, so there's a good chance we can do 9 | something to alleviate the issue by making `wasm-pack` better documented or 10 | more robust to different developer environments. 11 | 12 | When filing an issue, do your best to be as specific as possible. Include 13 | the version of rust you are using (`rustc --version`) and your operating 14 | system and version. The faster was can reproduce your issue, the faster we 15 | can fix it for you! 16 | 17 | ## Submitting a PR 18 | 19 | If you are considering filing a pull request, make sure that there's an issue 20 | filed for the work you'd like to do. There might be some discussion required! 21 | Filing an issue first will help ensure that the work you put into your pull 22 | request will get merged :) 23 | 24 | Before you submit your pull request, check that you have completed all of the 25 | steps mentioned in the pull request template. Link the issue that your pull 26 | request is responding to, and format your code using [rustfmt][rustfmt]. 27 | 28 | ### Configuring rustfmt 29 | 30 | Before submitting code in a PR, make sure that you have formatted the codebase 31 | using [rustfmt][rustfmt]. `rustfmt` is a tool for formatting Rust code, which 32 | helps keep style consistent across the project. If you have not used `rustfmt` 33 | before, it is not too difficult. 34 | 35 | If you have not already configured `rustfmt` for the 36 | nightly toolchain, it can be done using the following steps: 37 | 38 | **1. Use Nightly Toolchain** 39 | 40 | Use the `rustup override` command to make sure that you are using the nightly 41 | toolchain. Run this command in the `wasm-pack` directory you cloned. 42 | 43 | ```sh 44 | rustup override set nightly 45 | ``` 46 | 47 | **2. Add the rustfmt component** 48 | 49 | Install the most recent version of `rustfmt` using this command: 50 | 51 | ```sh 52 | rustup component add rustfmt-preview --toolchain nightly 53 | ``` 54 | 55 | **3. Running rustfmt** 56 | 57 | To run `rustfmt`, use this command: 58 | 59 | ```sh 60 | cargo +nightly fmt 61 | ``` 62 | 63 | [rustfmt]: https://github.com/rust-lang-nursery/rustfmt 64 | 65 | ### IDE Configuration files 66 | Machine specific configuration files may be generaged by your IDE while working on the project. Please make sure to add these files to a global .gitignore so they are kept from accidentally being commited to the project and causing issues for other contributors. 67 | 68 | Some examples of these files are the `.idea` folder created by JetBrains products (WebStorm, IntelliJ, etc) as well as `.vscode` created by Visual Studio Code for workspace specific settings. 69 | 70 | For help setting up a global .gitignore check out this [GitHub article]! 71 | 72 | [GitHub article]: https://help.github.com/articles/ignoring-files/#create-a-global-gitignore 73 | 74 | ## Conduct 75 | 76 | As mentioned in the readme file, this project is a part of the [`rust-wasm` working group], 77 | an official working group of the Rust project. We follow the Rust [Code of Conduct and enforcement policies]. 78 | 79 | [`rust-wasm` working group]: https://github.com/rustwasm/team 80 | [Code of Conduct and enforcement policies]: CODE_OF_CONDUCT.md 81 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "wasm-pack" 3 | description = "📦✨ your favorite rust -> wasm workflow tool!" 4 | version = "0.13.1" 5 | authors = ["Ashley Williams ", "Jesper Håkansson "] 6 | repository = "https://github.com/rustwasm/wasm-pack.git" 7 | license = "MIT OR Apache-2.0" 8 | edition = "2021" 9 | readme = "README.md" 10 | categories = ["wasm"] 11 | documentation = "https://rustwasm.github.io/wasm-pack/" 12 | 13 | [dependencies] 14 | anyhow = "1.0.68" 15 | binary-install = "0.4.1" 16 | cargo_metadata = "0.15.2" 17 | chrono = "0.4.23" 18 | console = "0.15.5" 19 | dialoguer = "0.10.3" 20 | env_logger = { version = "0.10.0", default-features = false } 21 | glob = "0.3.1" 22 | human-panic = "1.0.3" 23 | log = "0.4.17" 24 | parking_lot = "0.12.1" 25 | semver = "1.0.16" 26 | serde = "1.0.152" 27 | serde_derive = "1.0.152" 28 | serde_ignored = "0.1.7" 29 | serde_json = "1.0.91" 30 | siphasher = "0.3.10" 31 | strsim = "0.10.0" 32 | clap = { version = "4.2.5", features = ["derive"] } 33 | toml = "0.7.3" 34 | ureq = { version = "2.6.2", features = ["json", "socks-proxy"] } 35 | walkdir = "2.3.2" 36 | which = "4.4.0" 37 | path-clean = "1.0.1" 38 | 39 | [dev-dependencies] 40 | assert_cmd = "2.0.8" 41 | lazy_static = "1.4.0" 42 | predicates = "3.0.3" 43 | serial_test = "2.0.0" 44 | tempfile = "3.3.0" 45 | 46 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Ashley Williams 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 |

📦✨ wasm-pack

4 | 5 |

6 | Your favorite Rust → Wasm workflow tool! 7 |

8 | 9 |

10 | Build Status 11 | crates.io 12 |

13 | 14 |

15 | Docs 16 | | 17 | Contributing 18 | | 19 | Chat 20 |

21 | 22 | Built with 🦀🕸 by The Rust and WebAssembly Working Group 23 | 24 |
25 | 26 | ## About 27 | 28 | This tool seeks to be a one-stop shop for building and working with rust- 29 | generated WebAssembly that you would like to interop with JavaScript, in the 30 | browser or with Node.js. `wasm-pack` helps you build rust-generated 31 | WebAssembly packages that you could publish to the npm registry, or otherwise use 32 | alongside any javascript packages in workflows that you already use, such as [webpack]. 33 | 34 | [bundler-support]: https://github.com/rustwasm/team/blob/master/goals/bundler-integration.md#details 35 | [webpack]: https://webpack.js.org/ 36 | 37 | This project is a part of the [rust-wasm] group. You can find more info by 38 | visiting that repo! 39 | 40 | [rust-wasm]: https://github.com/rustwasm/team 41 | 42 | ![demo](demo.gif) 43 | 44 | ## 🔮 Prerequisites 45 | 46 | This project requires Rust 1.30.0 or later. 47 | 48 | - [Development Environment](https://rustwasm.github.io/wasm-pack/book/prerequisites/index.html) 49 | - [Installation](https://rustwasm.github.io/wasm-pack/installer) 50 | 51 | ## ⚡ Quickstart Guide 52 | 53 | Visit the [quickstart guide] in our documentation. 54 | 55 | [quickstart guide]: https://rustwasm.github.io/wasm-pack/book/quickstart.html 56 | 57 | ## 🎙️ Commands 58 | 59 | - [`new`](https://rustwasm.github.io/wasm-pack/book/commands/new.html): Generate a new RustWasm project using a template 60 | - [`build`](https://rustwasm.github.io/wasm-pack/book/commands/build.html): Generate an npm wasm pkg from a rustwasm crate 61 | - [`test`](https://rustwasm.github.io/wasm-pack/book/commands/test.html): Run browser tests 62 | - [`pack` and `publish`](https://rustwasm.github.io/wasm-pack/book/commands/pack-and-publish.html): Create a tarball of your rustwasm pkg and/or publish to a registry 63 | 64 | ## 📝 Logging 65 | 66 | `wasm-pack` uses [`env_logger`] to produce logs when `wasm-pack` runs. 67 | 68 | To configure your log level, use the `RUST_LOG` environment variable. For example: 69 | 70 | ``` 71 | RUST_LOG=info wasm-pack build 72 | ``` 73 | 74 | [`env_logger`]: https://crates.io/crates/env_logger 75 | 76 | ## 👯 Contributing 77 | 78 | Read our [guide] on getting up and running for developing `wasm-pack`, and 79 | check out our [contribution policy]. 80 | 81 | [guide]: https://rustwasm.github.io/wasm-pack/book/contributing.html 82 | [contribution policy]: CONTRIBUTING.md 83 | 84 | ## 🤹‍♀️ Governance 85 | 86 | This project is part of the [rustwasm Working Group]. 87 | 88 | This project was started by [ashleygwilliams] and is maintained by [drager] and the Rust Wasm Working Group Core Team. 89 | 90 | [ashleygwilliams]: https://github.com/ashleygwilliams 91 | [drager]: https://github.com/drager 92 | [rustwasm working group]: https://github.com/rustwasm/team 93 | -------------------------------------------------------------------------------- /RELEASE_CHECKLIST.md: -------------------------------------------------------------------------------- 1 | # Release Checklist 2 | 3 | This is a list of the things that need to happen during a release. 4 | 5 | 1. Open the associated milestone. All issues and PRs should be closed. If 6 | they are not you should reassign all open issues and PRs to future 7 | milestones. 8 | 1. Go through the commit history since last release. Ensure that all PRs 9 | that have landed are marked with the milestone. You can use this to 10 | show all the PRs that are merged on or after YYY-MM-DD: 11 | `https://github.com/issues?utf8=%E2%9C%93&q=repo%3Arustwasm%2Fwasm-pack+merged%3A%3E%3DYYYY-MM-DD` 12 | 1. Go through the closed PRs in the milestone. Each should have a changelog 13 | label indicating if the change is docs, fix, feature, or maintenance. If 14 | there is a missing label, please add one. 15 | 1. Choose an emoji for the release. Try to make it some sort of transition 16 | from the previous releases emoji (point releases can be a little weirder). 17 | 1. Create a new branch "#.#.#" where "#.#.#" is the release's version. 18 | 1. Add this release to the `CHANGELOG.md`. Use the structure of previous 19 | entries. 20 | 1. Update `DEFAULT_CHROMEDRIVER_VERSION` in `chromedriver.rs`. 21 | Version is the response of `https://chromedriver.storage.googleapis.com/LATEST_RELEASE`. 22 | 1. Update `DEFAULT_GECKODRIVER_VERSION` in `geckodriver.rs`. 23 | Version is the name of the latest tag - `https://github.com/mozilla/geckodriver/releases/latest`. 24 | 1. Update the version in `Cargo.toml`. 25 | 1. Update the version number and date in `docs/index.html`. 26 | 1. Run `cargo update`. 27 | 1. Run `cargo test`. 28 | 1. Run `cargo build`. 29 | 1. Copy `README.md` to `npm/README.md` 30 | 1. Bump the version number in `npm/package.json` 31 | 1. `cd npm && npm install` 32 | 1. Push up a commit with the `Cargo.toml`, `Cargo.lock`, `docs/index.html`, 33 | and `CHANGELOG.md` changes. The commit message can just be "#.#.#". 34 | 1. Request review from `@ashleygwilliams` and `@drager`. 35 | 1. `git commit --amend` all changes into the single commit. 36 | 1. Once ready to merge, tag the commit with the tag `v#.#.#`. 37 | 1. Wait for the CI to go green. 38 | 1. The CI will build the release binaries. Take the `CHANGELOG.md` release 39 | entry and cut and paste it into the release body. 40 | 1. Be sure to add any missing link definitions to the release. 41 | 1. Hit the big green Merge button. 42 | 1. `git checkout master` and `git pull --rebase origin master` 43 | 1. Run `cargo test`. 44 | 1. `cargo publish` 45 | 1. `cd npm && npm publish` 46 | 1. Tweet. 47 | -------------------------------------------------------------------------------- /clippy.toml: -------------------------------------------------------------------------------- 1 | too-many-arguments-threshold = 8 -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rustwasm/wasm-pack/32e52ca893e26c97bbf478c57ae1e9abed23c449/demo.gif -------------------------------------------------------------------------------- /docs/_installer/build-installer.rs: -------------------------------------------------------------------------------- 1 | use std::fs; 2 | 3 | fn main() { 4 | fs::create_dir_all("docs/installer").unwrap(); 5 | fs::copy( 6 | "docs/_installer/wasm-pack.js", 7 | "docs/installer/wasm-pack.js", 8 | ).unwrap(); 9 | let index = fs::read_to_string("docs/_installer/index.html").unwrap(); 10 | fs::write( 11 | "docs/installer/index.html", 12 | fixup(&index), 13 | ).unwrap(); 14 | 15 | let init = fs::read_to_string("docs/_installer/init.sh").unwrap(); 16 | fs::write( 17 | "docs/installer/init.sh", 18 | fixup(&init), 19 | ).unwrap(); 20 | } 21 | 22 | fn fixup(input: &str) -> String { 23 | let manifest = fs::read_to_string("Cargo.toml").unwrap(); 24 | let version = manifest.lines() 25 | .find(|line| line.starts_with("version =")) 26 | .unwrap(); 27 | let version = &version[version.find('"').unwrap() + 1..version.rfind('"').unwrap()]; 28 | 29 | input.replace("$VERSION", &format!("v{}", version)) 30 | } 31 | -------------------------------------------------------------------------------- /docs/_installer/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | wasm-pack 5 | 6 | 7 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 41 |
42 | 43 |

Install wasm-pack

44 |
45 | 56 | 57 | 71 | 72 | 86 | 87 |
88 | 89 |
90 |

91 | To install from source on any platform: 92 |

93 |

cargo install wasm-pack

94 |

95 | On supported platforms, you can also use npm or yarn to download a precompiled binary: 96 |

97 |

npm install -g wasm-pack or yarn global add wasm-pack

98 |
99 |
100 |
101 | 102 | 103 | -------------------------------------------------------------------------------- /docs/_installer/init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2016 The Rust Project Developers. See the COPYRIGHT 3 | # file at the top-level directory of this distribution and at 4 | # http://rust-lang.org/COPYRIGHT. 5 | # 6 | # Licensed under the Apache License, Version 2.0 or the MIT license 8 | # , at your 9 | # option. This file may not be copied, modified, or distributed 10 | # except according to those terms. 11 | 12 | # This is just a little script that can be downloaded from the internet to 13 | # install wasm-pack. It just does platform detection, downloads the installer 14 | # and runs it. 15 | 16 | set -u 17 | 18 | UPDATE_ROOT="https://github.com/rustwasm/wasm-pack/releases/download/$VERSION" 19 | 20 | main() { 21 | downloader --check 22 | need_cmd uname 23 | need_cmd mktemp 24 | need_cmd chmod 25 | need_cmd mkdir 26 | need_cmd rm 27 | need_cmd rmdir 28 | need_cmd tar 29 | need_cmd which 30 | need_cmd dirname 31 | 32 | get_architecture || return 1 33 | local _arch="$RETVAL" 34 | assert_nz "$_arch" "arch" 35 | 36 | local _ext="" 37 | case "$_arch" in 38 | *windows*) 39 | _ext=".exe" 40 | ;; 41 | esac 42 | 43 | which rustup > /dev/null 2>&1 44 | need_ok "failed to find Rust installation, is rustup installed?" 45 | local _rustup=$(which rustup) 46 | local _tardir="wasm-pack-$VERSION-${_arch}" 47 | local _url="$UPDATE_ROOT/${_tardir}.tar.gz" 48 | local _dir="$(mktemp -d 2>/dev/null || ensure mktemp -d -t wasm-pack)" 49 | local _file="$_dir/input.tar.gz" 50 | local _wasmpack="$_dir/wasm-pack$_ext" 51 | local _wasmpackinit="$_dir/wasm-pack-init$_ext" 52 | 53 | printf '%s\n' 'info: downloading wasm-pack' 1>&2 54 | 55 | ensure mkdir -p "$_dir" 56 | downloader "$_url" "$_file" 57 | if [ $? != 0 ]; then 58 | say "failed to download $_url" 59 | say "this may be a standard network error, but it may also indicate" 60 | say "that wasm-pack's release process is not working. When in doubt" 61 | say "please feel free to open an issue!" 62 | exit 1 63 | fi 64 | ensure tar xf "$_file" --strip-components 1 -C "$_dir" 65 | mv "$_wasmpack" "$_wasmpackinit" 66 | 67 | # The installer may want to ask for confirmation on stdin for various 68 | # operations. We were piped through `sh` though so we probably don't have 69 | # access to a tty naturally. If it looks like we're attached to a terminal 70 | # (`-t 1`) then pass the tty down to the installer explicitly. 71 | if [ -t 1 ]; then 72 | "$_wasmpackinit" "$@" < /dev/tty 73 | else 74 | "$_wasmpackinit" "$@" 75 | fi 76 | 77 | local _retval=$? 78 | 79 | ignore rm -rf "$_dir" 80 | 81 | return "$_retval" 82 | } 83 | 84 | get_architecture() { 85 | local _ostype="$(uname -s)" 86 | local _cputype="$(uname -m)" 87 | 88 | # This is when installing inside docker, or can be useful to side-step 89 | # the script's built-in platform detection heuristic (if it drifts again in the future) 90 | set +u 91 | if [ -n "$TARGETOS" ]; then 92 | _ostype="$TARGETOS" # probably always linux 93 | fi 94 | 95 | if [ -n "$TARGETARCH" ]; then 96 | _cputype="$TARGETARCH" 97 | fi 98 | set -u 99 | 100 | 101 | if [ "$_ostype" = Darwin ] && [ "$_cputype" = i386 ]; then 102 | # Darwin `uname -s` lies 103 | if sysctl hw.optional.x86_64 | grep -q ': 1'; then 104 | local _cputype=x86_64 105 | fi 106 | fi 107 | 108 | case "$_ostype" in 109 | Linux | linux) 110 | local _ostype=unknown-linux-musl 111 | ;; 112 | 113 | Darwin) 114 | local _ostype=apple-darwin 115 | ;; 116 | 117 | MINGW* | MSYS* | CYGWIN*) 118 | local _ostype=pc-windows-msvc 119 | ;; 120 | 121 | *) 122 | err "no precompiled binaries available for OS: $_ostype" 123 | ;; 124 | esac 125 | 126 | case "$_cputype" in 127 | x86_64 | x86-64 | x64 | amd64) 128 | local _cputype=x86_64 129 | ;; 130 | arm64 | aarch64) 131 | local _cputype=aarch64 132 | ;; 133 | *) 134 | err "no precompiled binaries available for CPU architecture: $_cputype" 135 | 136 | esac 137 | 138 | # See https://github.com/rustwasm/wasm-pack/pull/1088 139 | if [ "$_cputype" = "aarch64" ] && [ "$_ostype" = "apple-darwin" ]; then 140 | _cputype="x86_64" 141 | fi 142 | 143 | local _arch="$_cputype-$_ostype" 144 | 145 | RETVAL="$_arch" 146 | } 147 | 148 | say() { 149 | echo "wasm-pack-init: $1" 150 | } 151 | 152 | err() { 153 | say "$1" >&2 154 | exit 1 155 | } 156 | 157 | need_cmd() { 158 | if ! check_cmd "$1" 159 | then err "need '$1' (command not found)" 160 | fi 161 | } 162 | 163 | check_cmd() { 164 | command -v "$1" > /dev/null 2>&1 165 | return $? 166 | } 167 | 168 | need_ok() { 169 | if [ $? != 0 ]; then err "$1"; fi 170 | } 171 | 172 | assert_nz() { 173 | if [ -z "$1" ]; then err "assert_nz $2"; fi 174 | } 175 | 176 | # Run a command that should never fail. If the command fails execution 177 | # will immediately terminate with an error showing the failing 178 | # command. 179 | ensure() { 180 | "$@" 181 | need_ok "command failed: $*" 182 | } 183 | 184 | # This is just for indicating that commands' results are being 185 | # intentionally ignored. Usually, because it's being executed 186 | # as part of error handling. 187 | ignore() { 188 | "$@" 189 | } 190 | 191 | # This wraps curl or wget. Try curl first, if not installed, 192 | # use wget instead. 193 | downloader() { 194 | if check_cmd curl 195 | then _dld=curl 196 | elif check_cmd wget 197 | then _dld=wget 198 | else _dld='curl or wget' # to be used in error message of need_cmd 199 | fi 200 | 201 | if [ "$1" = --check ] 202 | then need_cmd "$_dld" 203 | elif [ "$_dld" = curl ] 204 | then curl -sSfL "$1" -o "$2" 205 | elif [ "$_dld" = wget ] 206 | then wget "$1" -O "$2" 207 | else err "Unknown downloader" # should not reach here 208 | fi 209 | } 210 | 211 | main "$@" || exit 1 212 | -------------------------------------------------------------------------------- /docs/_installer/wasm-pack.js: -------------------------------------------------------------------------------- 1 | var platforms = ["unknown", "win64", "unix"]; 2 | var platform_override = null; 3 | 4 | function detect_platform() { 5 | "use strict"; 6 | 7 | if (platform_override !== null) { 8 | return platforms[platform_override]; 9 | } 10 | 11 | var os = "unknown"; 12 | 13 | if (navigator.platform == "Linux x86_64") {os = "unix";} 14 | if (navigator.platform == "Linux i686") {os = "unix";} 15 | if (navigator.platform == "Linux i686 on x86_64") {os = "unix";} 16 | if (navigator.platform == "Linux aarch64") {os = "unix";} 17 | if (navigator.platform == "Linux armv6l") {os = "unix";} 18 | if (navigator.platform == "Linux armv7l") {os = "unix";} 19 | if (navigator.platform == "Linux armv8l") {os = "unix";} 20 | if (navigator.platform == "Linux ppc64") {os = "unix";} 21 | if (navigator.platform == "Linux mips") {os = "unix";} 22 | if (navigator.platform == "Linux mips64") {os = "unix";} 23 | if (navigator.platform == "Mac") {os = "unix";} 24 | // if (navigator.platform == "Win32") {os = "win32";} 25 | if (navigator.platform == "Win64" || 26 | navigator.userAgent.indexOf("WOW64") != -1 || 27 | navigator.userAgent.indexOf("Win64") != -1) { os = "win64"; } 28 | if (navigator.platform == "FreeBSD x86_64") {os = "unix";} 29 | if (navigator.platform == "FreeBSD amd64") {os = "unix";} 30 | if (navigator.platform == "NetBSD x86_64") {os = "unix";} 31 | if (navigator.platform == "NetBSD amd64") {os = "unix";} 32 | 33 | // I wish I knew by now, but I don't. Try harder. 34 | if (os == "unknown") { 35 | // if (navigator.appVersion.indexOf("Win")!=-1) {os = "win32";} 36 | if (navigator.appVersion.indexOf("Mac")!=-1) {os = "unix";} 37 | // rust-www/#692 - FreeBSD epiphany! 38 | if (navigator.appVersion.indexOf("FreeBSD")!=-1) {os = "unix";} 39 | } 40 | 41 | // Firefox Quantum likes to hide platform and appVersion but oscpu works 42 | if (navigator.oscpu) { 43 | // if (navigator.oscpu.indexOf("Win32")!=-1) {os = "win32";} 44 | if (navigator.oscpu.indexOf("Win64")!=-1) {os = "win64";} 45 | if (navigator.oscpu.indexOf("Mac")!=-1) {os = "unix";} 46 | if (navigator.oscpu.indexOf("Linux")!=-1) {os = "unix";} 47 | if (navigator.oscpu.indexOf("FreeBSD")!=-1) {os = "unix";} 48 | if (navigator.oscpu.indexOf("NetBSD")!=-1) {os = "unix";} 49 | } 50 | 51 | return os; 52 | } 53 | 54 | function adjust_for_platform() { 55 | "use strict"; 56 | 57 | var platform = detect_platform(); 58 | 59 | platforms.forEach(function (platform_elem) { 60 | var platform_div = document.getElementById("platform-instructions-" + platform_elem); 61 | platform_div.style.display = "none"; 62 | if (platform === platform_elem) { 63 | platform_div.style.display = "block"; 64 | } 65 | }); 66 | } 67 | 68 | function fill_in_bug_report_values() { 69 | var nav_plat = document.getElementById("nav-plat"); 70 | var nav_app = document.getElementById("nav-app"); 71 | nav_plat.textContent = navigator.platform; 72 | nav_app.textContent = navigator.appVersion; 73 | } 74 | 75 | (function () { 76 | adjust_for_platform(); 77 | fill_in_bug_report_values(); 78 | }()); 79 | -------------------------------------------------------------------------------- /docs/_theme/header.hbs: -------------------------------------------------------------------------------- 1 | 37 |
38 |

39 | This is the unpublished documentation of 40 | wasm-pack, the published documentation is available 41 | 42 | on the main Rust and WebAssembly documentation site 43 | . Features documented here may not be available in released versions of 44 | wasm-pack. 45 |

46 |
47 | -------------------------------------------------------------------------------- /docs/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rustwasm/wasm-pack/32e52ca893e26c97bbf478c57ae1e9abed23c449/docs/android-chrome-192x192.png -------------------------------------------------------------------------------- /docs/android-chrome-384x384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rustwasm/wasm-pack/32e52ca893e26c97bbf478c57ae1e9abed23c449/docs/android-chrome-384x384.png -------------------------------------------------------------------------------- /docs/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rustwasm/wasm-pack/32e52ca893e26c97bbf478c57ae1e9abed23c449/docs/apple-touch-icon.png -------------------------------------------------------------------------------- /docs/book.toml: -------------------------------------------------------------------------------- 1 | [book] 2 | authors = ["Ashley Williams"] 3 | multilingual = false 4 | src = "src" 5 | title = "Hello wasm-pack!" 6 | -------------------------------------------------------------------------------- /docs/browserconfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | #00aba9 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rustwasm/wasm-pack/32e52ca893e26c97bbf478c57ae1e9abed23c449/docs/favicon-16x16.png -------------------------------------------------------------------------------- /docs/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rustwasm/wasm-pack/32e52ca893e26c97bbf478c57ae1e9abed23c449/docs/favicon-32x32.png -------------------------------------------------------------------------------- /docs/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rustwasm/wasm-pack/32e52ca893e26c97bbf478c57ae1e9abed23c449/docs/favicon.ico -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | wasm-pack 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 36 |
37 |
38 |
39 | 44 |
45 | ✨ Install wasm-pack 0.13.1 ✨ 46 |

29 Oct 2024 | 47 | 48 | Release Notes 49 | 50 |

51 |
52 |
53 |
54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /docs/mstile-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rustwasm/wasm-pack/32e52ca893e26c97bbf478c57ae1e9abed23c449/docs/mstile-150x150.png -------------------------------------------------------------------------------- /docs/public/custom.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css?family=Raleway'); 2 | 3 | .navbar { 4 | display: block; 5 | width: 100%; 6 | height: 6.5rem; 7 | background: #fff; 8 | z-index: 99; 9 | border-bottom: 1px solid #eee; 10 | } 11 | 12 | .navbar-list { 13 | list-style: none; 14 | margin-bottom: 0; 15 | } 16 | 17 | .navbar-item { 18 | position: relative; 19 | float: right; 20 | margin-bottom: 0; 21 | } 22 | 23 | .navbar-logo { 24 | position: relative; 25 | float: left; 26 | margin-bottom: 0; 27 | bottom: -5px; 28 | } 29 | 30 | .navbar-logo a img { 31 | width: 50px; 32 | } 33 | 34 | .navbar-item a { 35 | text-transform: uppercase; 36 | font-size: 11px; 37 | font-weight: 600; 38 | letter-spacing: .2rem; 39 | margin-right: 35px; 40 | text-decoration: none; 41 | line-height: 6.5rem; 42 | color: #222; 43 | } 44 | 45 | #logo, #installer { 46 | text-align: center; 47 | } 48 | 49 | #logo { 50 | padding: 50px; 51 | } 52 | 53 | #logo img { 54 | width: 80%; 55 | } 56 | 57 | #logo h1, h2 { 58 | text-align: center; 59 | } 60 | 61 | #logo h2 { 62 | font-size: 1.8rem; 63 | letter-spacing: 0.01rem; 64 | color: #222; 65 | } 66 | 67 | #installer a.button { 68 | width: 100%; 69 | height: 20%; 70 | font-size: 1.8rem; 71 | padding: 1.8rem; 72 | margin: 10rem 0 1.8rem 0; 73 | background-color: #6556EC; 74 | border-color: #6556EC; 75 | } 76 | 77 | #installer img { 78 | padding: 50px; 79 | width: 20%; 80 | } 81 | 82 | pre.primary { 83 | margin: 0 auto 2.5rem auto; 84 | width: fit-content; 85 | 86 | padding: 20px; 87 | font-size: 2rem; 88 | background-color: #000; 89 | color: #fff; 90 | } 91 | 92 | a { 93 | color: #6556EC; 94 | } 95 | -------------------------------------------------------------------------------- /docs/public/img/rustwasm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rustwasm/wasm-pack/32e52ca893e26c97bbf478c57ae1e9abed23c449/docs/public/img/rustwasm.png -------------------------------------------------------------------------------- /docs/public/img/wasm-ferris.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rustwasm/wasm-pack/32e52ca893e26c97bbf478c57ae1e9abed23c449/docs/public/img/wasm-ferris.png -------------------------------------------------------------------------------- /docs/safari-pinned-tab.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | Created by potrace 1.11, written by Peter Selinger 2001-2013 9 | 10 | 12 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /docs/site.webmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wasm-pack ", 3 | "short_name": "wasm-pack ", 4 | "icons": [ 5 | { 6 | "src": "/android-chrome-192x192.png", 7 | "sizes": "192x192", 8 | "type": "image/png" 9 | }, 10 | { 11 | "src": "/android-chrome-384x384.png", 12 | "sizes": "384x384", 13 | "type": "image/png" 14 | } 15 | ], 16 | "theme_color": "#ffffff", 17 | "background_color": "#ffffff", 18 | "display": "standalone" 19 | } 20 | -------------------------------------------------------------------------------- /docs/src/SUMMARY.md: -------------------------------------------------------------------------------- 1 | # Summary 2 | 3 | - [Introduction](./introduction.md) 4 | - [Quickstart](./quickstart.md) 5 | - [Prerequisites](./prerequisites/index.md) 6 | - [npm (optional)](./prerequisites/npm.md) 7 | - [considerations](./prerequisites/considerations.md) 8 | - [Non-`rustup` setups](./prerequisites/non-rustup-setups.md) 9 | - [Commands](./commands/index.md) 10 | - [`new`](./commands/new.md) 11 | - [`build`](./commands/build.md) 12 | - [`test`](./commands/test.md) 13 | - [`pack` and `publish`](./commands/pack-and-publish.md) 14 | - [`init` (DEPRECATED)](./commands/init.md) 15 | - [Tutorials](./tutorials/index.md) 16 | - [Hybrid applications with Webpack](./tutorials/hybrid-applications-with-webpack/index.md) 17 | - [Getting started](./tutorials/hybrid-applications-with-webpack/getting-started.md) 18 | - [Using your library](./tutorials/hybrid-applications-with-webpack/using-your-library.md) 19 | - [npm browser packages](./tutorials/npm-browser-packages/index.md) 20 | - [Getting started](./tutorials/npm-browser-packages/getting-started.md) 21 | - [Manual Setup](./tutorials/npm-browser-packages/getting-started/manual-setup.md) 22 | - [Template deep dive](./tutorials/npm-browser-packages/template-deep-dive/index.md) 23 | - [`Cargo.toml`](./tutorials/npm-browser-packages/template-deep-dive/cargo-toml.md) 24 | - [`src/lib.rs`](./tutorials/npm-browser-packages/template-deep-dive/src-lib-rs.md) 25 | - [`src/utils.rs`](./tutorials/npm-browser-packages/template-deep-dive/src-utils-rs.md) 26 | - [`wee_alloc`](./tutorials/npm-browser-packages/template-deep-dive/wee_alloc.md) 27 | - [`tests/web.rs`](./tutorials/npm-browser-packages/template-deep-dive/tests-web-rs.md) 28 | - [Building your project](./tutorials/npm-browser-packages/building-your-project.md) 29 | - [Testing your project](./tutorials/npm-browser-packages/testing-your-project.md) 30 | - [Packaging and publishing](./tutorials/npm-browser-packages/packaging-and-publishing.md) 31 | - [Using your library](./tutorials/npm-browser-packages/using-your-library.md) 32 | - [`Cargo.toml` Configuration](./cargo-toml-configuration.md) 33 | - [Contributing](./contributing.md) 34 | -------------------------------------------------------------------------------- /docs/src/cargo-toml-configuration.md: -------------------------------------------------------------------------------- 1 | # `Cargo.toml` Configuration 2 | 3 | `wasm-pack` can be configured via the `package.metadata.wasm-pack` key in 4 | `Cargo.toml`. Every option has a default, and is not required. 5 | 6 | There are three profiles: `dev`, `profiling`, and `release`. These correspond to 7 | the `--dev`, `--profiling`, and `--release` flags passed to `wasm-pack build`. 8 | 9 | The available configuration options and their default values are shown below: 10 | 11 | ```toml 12 | [package.metadata.wasm-pack.profile.dev] 13 | # Should `wasm-opt` be used to further optimize the wasm binary generated after 14 | # the Rust compiler has finished? Using `wasm-opt` can often further decrease 15 | # binary size or do clever tricks that haven't made their way into LLVM yet. 16 | # 17 | # Configuration is set to `false` by default for the dev profile, but it can 18 | # be set to an array of strings which are explicit arguments to pass to 19 | # `wasm-opt`. For example `['-Os']` would optimize for size while `['-O4']` 20 | # would execute very expensive optimizations passes 21 | # 22 | # In most cases, the `-O[X]` flag is enough. However, if you require extreme 23 | # optimizations, see the full list of `wasm-opt` optimization flags 24 | # https://github.com/WebAssembly/binaryen/blob/version_117/test/lit/help/wasm-opt.test 25 | wasm-opt = ['-O'] 26 | 27 | [package.metadata.wasm-pack.profile.dev.wasm-bindgen] 28 | # Should we enable wasm-bindgen's debug assertions in its generated JS glue? 29 | debug-js-glue = true 30 | # Should wasm-bindgen demangle the symbols in the "name" custom section? 31 | demangle-name-section = true 32 | # Should we emit the DWARF debug info custom sections? 33 | dwarf-debug-info = false 34 | # Should we omit the default import path? 35 | omit-default-module-path = false 36 | # Controls whether wasm-bindgen will split linked modules out into their own files. Enabling this is recommended, because it allows lazy-loading the linked modules and setting a stricter Content Security Policy. Only available in wasm-bindgen 0.2.95 and later. 37 | split-linked-modules = false 38 | 39 | [package.metadata.wasm-pack.profile.profiling] 40 | wasm-opt = ['-O'] 41 | 42 | [package.metadata.wasm-pack.profile.profiling.wasm-bindgen] 43 | debug-js-glue = false 44 | demangle-name-section = true 45 | dwarf-debug-info = false 46 | omit-default-module-path = false 47 | 48 | # `wasm-opt` is on by default in for the release profile, but it can be 49 | # disabled by setting it to `false` 50 | [package.metadata.wasm-pack.profile.release] 51 | wasm-opt = false 52 | 53 | [package.metadata.wasm-pack.profile.release.wasm-bindgen] 54 | debug-js-glue = false 55 | demangle-name-section = true 56 | dwarf-debug-info = false 57 | omit-default-module-path = false 58 | ``` 59 | -------------------------------------------------------------------------------- /docs/src/commands/index.md: -------------------------------------------------------------------------------- 1 | # Commands 2 | 3 | `wasm-pack` has several commands to help you during the process of building 4 | a Rust-generated WebAssembly project. 5 | 6 | - `new`: This command generates a new project for you using a template. [Learn more][new] 7 | - `build`: This command builds a `pkg` directory for you with compiled wasm and generated JS. [Learn more][build] 8 | - `pack` and `publish`: These commands will create a tarball, and optionally publish it to a registry, such as npm. [Learn more][pack-pub] 9 | 10 | ### Deprecated Commands 11 | 12 | - `init`: This command has been deprecated in favor of `build`. 13 | 14 | [new]: ./new.html 15 | [build]: ./build.html 16 | [pack-pub]: ./pack-and-publish.html 17 | 18 | ### Log levels 19 | 20 | By default `wasm-pack` displays a lot of useful information. 21 | 22 | You can cause it to display even *more* information by using `--verbose`, or you can silence *all* stdout by using `--quiet`. 23 | 24 | You can also use `--log-level` to have fine-grained control over wasm-pack's log output: 25 | 26 | * `--log-level info` is the default, it causes all messages to be logged. 27 | * `--log-level warn` causes warnings and errors to be displayed, but not info. 28 | * `--log-level error` causes only errors to be displayed. 29 | 30 | These flags are global flags, so they can be used with every command, and they must come *before* the command: 31 | 32 | ```sh 33 | wasm-pack --log-level error build 34 | wasm-pack --quiet build 35 | wasm-pack --verbose build 36 | ``` 37 | -------------------------------------------------------------------------------- /docs/src/commands/init.md: -------------------------------------------------------------------------------- 1 | # wasm-pack init (DEPRECATED) 2 | 3 | This command has been deprecated in favor of `build`, which does the same thing, but is 4 | a much more representative name for the command. [Read the docs for `build`.][build] 5 | 6 | [build]: ./build.html 7 | -------------------------------------------------------------------------------- /docs/src/commands/new.md: -------------------------------------------------------------------------------- 1 | # wasm-pack new 2 | 3 | The `wasm-pack new` command creates a new RustWasm project for you, 4 | using [`cargo-generate`] under the hood. 5 | 6 | It takes 3 parameters, name, template, and mode: 7 | 8 | ``` 9 | wasm-pack new --template