Compare commits

..

11 Commits

Author SHA1 Message Date
Jesper Håkansson 32e52ca893
Merge pull request #1423 from ArhanChaudhary/docs-elaboration 6 months ago
Jesper Håkansson ba5fef3206
Merge pull request #1443 from codeart1st/split-linked-modules 6 months ago
Paul Lange 4ea2a23716 feat: allow bindgen-cli --split-linked-modules #1092 6 months ago
Jesper Håkansson 513feba51b
Merge pull request #1428 from rafaelbeckel/master 6 months ago
Jesper Håkansson 0227505a08
Merge pull request #1440 from rustwasm/0.13.1 6 months ago
Jesper Håkansson 24bdca457a 0.13.1 6 months ago
Rafael Beckel ad86c68093 removes unused lines from fixture 8 months ago
Rafael Beckel 60e18c1538 implements custom build profile 8 months ago
Arhan Chaudhary 6f3339352b
chore: Note to update docs wasm-opt version 8 months ago
Arhan Chaudhary 3820cdf97d
docs: Fix typo for wasm-opt version 8 months ago
Arhan Chaudhary 3343b53440
doc: Be more explicit with available wasm-opt flags 8 months ago
  1. 2
      .github/workflows/release.yml
  2. 38
      CHANGELOG.md
  3. 473
      Cargo.lock
  4. 2
      Cargo.toml
  5. 6
      docs/index.html
  6. 6
      docs/src/cargo-toml-configuration.md
  7. 2
      npm/package.json
  8. 46
      npm/yarn.lock
  9. 8
      src/bindgen.rs
  10. 3
      src/build/mod.rs
  11. 31
      src/command/build.rs
  12. 2
      src/install/mod.rs
  13. 42
      src/manifest/mod.rs
  14. 2
      src/test/webdriver/geckodriver.rs
  15. 15
      tests/all/build.rs
  16. 52
      tests/all/utils/fixture.rs

@ -100,7 +100,7 @@ jobs:
run: 7z a -ttar -so -an ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }} | 7z a -si ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.tar.gz run: 7z a -ttar -so -an ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }} | 7z a -si ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.tar.gz
- name: Upload Zip - name: Upload Zip
uses: actions/upload-artifact@v1 uses: actions/upload-artifact@v4
with: with:
name: ${{ matrix.target }} name: ${{ matrix.target }}
path: ./${{ env.RELEASE_DIR }} path: ./${{ env.RELEASE_DIR }}

@ -2,6 +2,44 @@
## 🤍 Unreleased ## 🤍 Unreleased
## ☀ 0.13.1
- ### ✨ Features
- **Requests using proxy settings from env - [jjyr], [pull/1438]**
This enables ureq to use proxy settings from env, it solves lots of pain in network restricted environments.
[pull/1438]: https://github.com/rustwasm/wasm-pack/pull/1438
[jjyr]: https://github.com/jjyr
- ### 🤕 Fixes
- **Update binary-install to v0.4.1 - [drager], [pull/1407]**
Release v0.4.0 of binary-install introduced a regression that caused failures on some platforms. This release fixes that regression.
[pull/1407]: https://github.com/rustwasm/wasm-pack/pull/1407
[drager]: https://github.com/drager
- ** Allow npm binary upgrades - [net], [pull/1439]**
Fixes an issue where upgrading `wasm-pack` via NPM would not update the underlying binary.
Previously, the binary was stored in the `binary-install` package's directory without versioning, causing version upgrades to silently fail as the old binary continued to be used.
The binary is now stored in `node_modules/wasm-pack/binary/`, ensuring proper version updates when upgrading the package.
**Before:** Upgrading from `0.12.1` to `0.13.0` would continue using the `0.12.1` binary
**After:** Each `wasm-pack` version manages its own binary, enabling proper version upgrades
[pull/1439]: https://github.com/rustwasm/wasm-pack/pull/1439
[net]: https://github.com/net
- ### 🛠 Maintenance
- ** Remove unmaintained dependency atty in favor of stdlib - [mariusvniekerk], [pull/1436]**
[pull/1436]: https://github.com/rustwasm/wasm-pack/pull/1436
[mariusvniekerk]: https://github.com/mariusvniekerk
## ☀ 0.13.0 ## ☀ 0.13.0
- ### ✨ Features - ### ✨ Features

473
Cargo.lock generated

File diff suppressed because it is too large Load Diff

@ -1,7 +1,7 @@
[package] [package]
name = "wasm-pack" name = "wasm-pack"
description = "📦✨ your favorite rust -> wasm workflow tool!" description = "📦✨ your favorite rust -> wasm workflow tool!"
version = "0.13.0" version = "0.13.1"
authors = ["Ashley Williams <ashley666ashley@gmail.com>", "Jesper Håkansson <jesper@jesperh.se>"] authors = ["Ashley Williams <ashley666ashley@gmail.com>", "Jesper Håkansson <jesper@jesperh.se>"]
repository = "https://github.com/rustwasm/wasm-pack.git" repository = "https://github.com/rustwasm/wasm-pack.git"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"

@ -42,9 +42,9 @@
<h2>📦✨ your favorite rust -> wasm workflow tool!</h2> <h2>📦✨ your favorite rust -> wasm workflow tool!</h2>
</div> </div>
<div class="five columns" id="installer"> <div class="five columns" id="installer">
<a class="button button-primary" href="/wasm-pack/installer">✨ Install wasm-pack 0.13.0</a> <a class="button button-primary" href="/wasm-pack/installer">✨ Install wasm-pack 0.13.1</a>
<p>1 July 2024 | <p>29 Oct 2024 |
<a href="https://github.com/rustwasm/wasm-pack/releases/tag/v0.13.0"> <a href="https://github.com/rustwasm/wasm-pack/releases/tag/v0.13.1">
Release Notes Release Notes
</a> </a>
</p> </p>

@ -18,6 +18,10 @@ The available configuration options and their default values are shown below:
# be set to an array of strings which are explicit arguments to pass to # be set to an array of strings which are explicit arguments to pass to
# `wasm-opt`. For example `['-Os']` would optimize for size while `['-O4']` # `wasm-opt`. For example `['-Os']` would optimize for size while `['-O4']`
# would execute very expensive optimizations passes # would execute very expensive optimizations passes
#
# In most cases, the `-O[X]` flag is enough. However, if you require extreme
# optimizations, see the full list of `wasm-opt` optimization flags
# https://github.com/WebAssembly/binaryen/blob/version_117/test/lit/help/wasm-opt.test
wasm-opt = ['-O'] wasm-opt = ['-O']
[package.metadata.wasm-pack.profile.dev.wasm-bindgen] [package.metadata.wasm-pack.profile.dev.wasm-bindgen]
@ -29,6 +33,8 @@ demangle-name-section = true
dwarf-debug-info = false dwarf-debug-info = false
# Should we omit the default import path? # Should we omit the default import path?
omit-default-module-path = false omit-default-module-path = false
# 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.
split-linked-modules = false
[package.metadata.wasm-pack.profile.profiling] [package.metadata.wasm-pack.profile.profiling]
wasm-opt = ['-O'] wasm-opt = ['-O']

@ -1,6 +1,6 @@
{ {
"name": "wasm-pack", "name": "wasm-pack",
"version": "0.13.0", "version": "0.13.1",
"description": "📦✨ your favorite rust -> wasm workflow tool!", "description": "📦✨ your favorite rust -> wasm workflow tool!",
"main": "binary.js", "main": "binary.js",
"scripts": { "scripts": {

@ -15,9 +15,9 @@ balanced-match@^1.0.0:
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
binary-install@^1.0.1: binary-install@^1.0.1:
version "1.0.6" version "1.1.0"
resolved "https://registry.yarnpkg.com/binary-install/-/binary-install-1.0.6.tgz#7d603003da4f890d13d3e887773e86776e0d24a3" resolved "https://registry.npmjs.org/binary-install/-/binary-install-1.1.0.tgz"
integrity sha512-h3K4jaC4jEauK3csXI9GxGBJldkpuJlHCIBv8i+XBNhPuxnlERnD1PWVczQYDqvhJfv0IHUbB3lhDrZUMHvSgw== integrity sha512-rkwNGW+3aQVSZoD0/o3mfPN6Yxh3Id0R/xzTVBVVpGNlVz8EGwusksxRlbk/A5iKTZt9zkMn3qIqmAt3vpfbzg==
dependencies: dependencies:
axios "^0.26.1" axios "^0.26.1"
rimraf "^3.0.2" rimraf "^3.0.2"
@ -39,12 +39,12 @@ chownr@^2.0.0:
concat-map@0.0.1: concat-map@0.0.1:
version "0.0.1" version "0.0.1"
resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz"
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==
follow-redirects@^1.14.8: follow-redirects@^1.14.8:
version "1.15.6" version "1.15.9"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.6.tgz#7f815c0cda4249c74ff09e95ef97c23b5fd0399b" resolved "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz"
integrity sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA== integrity sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==
fs-minipass@^2.0.0: fs-minipass@^2.0.0:
version "2.1.0" version "2.1.0"
@ -56,24 +56,24 @@ fs-minipass@^2.0.0:
fs.realpath@^1.0.0: fs.realpath@^1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==
glob@^7.1.3: glob@^7.1.3:
version "7.2.0" version "7.2.3"
resolved "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz" resolved "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz"
integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==
dependencies: dependencies:
fs.realpath "^1.0.0" fs.realpath "^1.0.0"
inflight "^1.0.4" inflight "^1.0.4"
inherits "2" inherits "2"
minimatch "^3.0.4" minimatch "^3.1.1"
once "^1.3.0" once "^1.3.0"
path-is-absolute "^1.0.0" path-is-absolute "^1.0.0"
inflight@^1.0.4: inflight@^1.0.4:
version "1.0.6" version "1.0.6"
resolved "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz" resolved "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz"
integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==
dependencies: dependencies:
once "^1.3.0" once "^1.3.0"
wrappy "1" wrappy "1"
@ -83,23 +83,23 @@ inherits@2:
resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz" resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz"
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
minimatch@^3.0.4: minimatch@^3.1.1:
version "3.1.2" version "3.1.2"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz"
integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
dependencies: dependencies:
brace-expansion "^1.1.7" brace-expansion "^1.1.7"
minipass@^3.0.0: minipass@^3.0.0:
version "3.1.6" version "3.3.6"
resolved "https://registry.npmjs.org/minipass/-/minipass-3.1.6.tgz" resolved "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz"
integrity sha512-rty5kpw9/z8SX9dmxblFA6edItUmwJgMeYDZRrwlIVN27i8gysGbznJwUggw2V/FVqFSDdWy040ZPS811DYAqQ== integrity sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==
dependencies: dependencies:
yallist "^4.0.0" yallist "^4.0.0"
minipass@^5.0.0: minipass@^5.0.0:
version "5.0.0" version "5.0.0"
resolved "https://registry.yarnpkg.com/minipass/-/minipass-5.0.0.tgz#3e9788ffb90b694a5d0ec94479a45b5d8738133d" resolved "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz"
integrity sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ== integrity sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==
minizlib@^2.1.1: minizlib@^2.1.1:
@ -118,14 +118,14 @@ mkdirp@^1.0.3:
once@^1.3.0: once@^1.3.0:
version "1.4.0" version "1.4.0"
resolved "https://registry.npmjs.org/once/-/once-1.4.0.tgz" resolved "https://registry.npmjs.org/once/-/once-1.4.0.tgz"
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==
dependencies: dependencies:
wrappy "1" wrappy "1"
path-is-absolute@^1.0.0: path-is-absolute@^1.0.0:
version "1.0.1" version "1.0.1"
resolved "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz" resolved "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz"
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==
rimraf@^3.0.2: rimraf@^3.0.2:
version "3.0.2" version "3.0.2"
@ -136,7 +136,7 @@ rimraf@^3.0.2:
tar@^6.1.11: tar@^6.1.11:
version "6.2.1" version "6.2.1"
resolved "https://registry.yarnpkg.com/tar/-/tar-6.2.1.tgz#717549c541bc3c2af15751bea94b1dd068d4b03a" resolved "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz"
integrity sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A== integrity sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==
dependencies: dependencies:
chownr "^2.0.0" chownr "^2.0.0"
@ -149,7 +149,7 @@ tar@^6.1.11:
wrappy@1: wrappy@1:
version "1.0.2" version "1.0.2"
resolved "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" resolved "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz"
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==
yallist@^4.0.0: yallist@^4.0.0:
version "4.0.0" version "4.0.0"

@ -23,9 +23,10 @@ pub fn wasm_bindgen_build(
profile: BuildProfile, profile: BuildProfile,
extra_options: &Vec<String>, extra_options: &Vec<String>,
) -> Result<()> { ) -> Result<()> {
let release_or_debug = match profile { let profile_name = match profile.clone() {
BuildProfile::Release | BuildProfile::Profiling => "release", BuildProfile::Release | BuildProfile::Profiling => "release",
BuildProfile::Dev => "debug", BuildProfile::Dev => "debug",
BuildProfile::Custom(profile_name) => &profile_name.clone(),
}; };
let out_dir = out_dir.to_str().unwrap(); let out_dir = out_dir.to_str().unwrap();
@ -41,7 +42,7 @@ pub fn wasm_bindgen_build(
let wasm_path = target_directory let wasm_path = target_directory
.join("wasm32-unknown-unknown") .join("wasm32-unknown-unknown")
.join(release_or_debug) .join(profile_name)
.join(data.crate_name()) .join(data.crate_name())
.with_extension("wasm"); .with_extension("wasm");
@ -91,6 +92,9 @@ pub fn wasm_bindgen_build(
if profile.wasm_bindgen_omit_default_module_path() { if profile.wasm_bindgen_omit_default_module_path() {
cmd.arg("--omit-default-module-path"); cmd.arg("--omit-default-module-path");
} }
if profile.wasm_bindgen_split_linked_modules() {
cmd.arg("--split-linked-modules");
}
child::run(cmd, "wasm-bindgen").context("Running the wasm-bindgen CLI")?; child::run(cmd, "wasm-bindgen").context("Running the wasm-bindgen CLI")?;
Ok(()) Ok(())

@ -104,6 +104,9 @@ pub fn cargo_build_wasm(
// Plain cargo builds use the dev cargo profile, which includes // Plain cargo builds use the dev cargo profile, which includes
// debug info by default. // debug info by default.
} }
BuildProfile::Custom(arg) => {
cmd.arg("--profile").arg(arg);
}
} }
cmd.arg("--target").arg("wasm32-unknown-unknown"); cmd.arg("--target").arg("wasm32-unknown-unknown");

@ -100,7 +100,7 @@ impl FromStr for Target {
/// The build profile controls whether optimizations, debug info, and assertions /// The build profile controls whether optimizations, debug info, and assertions
/// are enabled or disabled. /// are enabled or disabled.
#[derive(Clone, Copy, Debug)] #[derive(Clone, Debug)]
pub enum BuildProfile { pub enum BuildProfile {
/// Enable assertions and debug info. Disable optimizations. /// Enable assertions and debug info. Disable optimizations.
Dev, Dev,
@ -108,6 +108,8 @@ pub enum BuildProfile {
Release, Release,
/// Enable optimizations and debug info. Disable assertions. /// Enable optimizations and debug info. Disable assertions.
Profiling, Profiling,
/// User-defined profile with --profile flag
Custom(String),
} }
/// Everything required to configure and run the `wasm-pack build` command. /// Everything required to configure and run the `wasm-pack build` command.
@ -160,6 +162,10 @@ pub struct BuildOptions {
/// Create a profiling build. Enable optimizations and debug info. /// Create a profiling build. Enable optimizations and debug info.
pub profiling: bool, pub profiling: bool,
#[clap(long = "profile")]
/// User-defined profile with --profile flag
pub profile: Option<String>,
#[clap(long = "out-dir", short = 'd', default_value = "pkg")] #[clap(long = "out-dir", short = 'd', default_value = "pkg")]
/// Sets the output directory with a relative path. /// Sets the output directory with a relative path.
pub out_dir: String, pub out_dir: String,
@ -196,6 +202,7 @@ impl Default for BuildOptions {
no_opt: false, no_opt: false,
release: false, release: false,
profiling: false, profiling: false,
profile: None,
out_dir: String::new(), out_dir: String::new(),
out_name: None, out_name: None,
extra_options: Vec::new(), extra_options: Vec::new(),
@ -221,13 +228,19 @@ impl Build {
let out_dir = crate_path.join(PathBuf::from(build_opts.out_dir)).clean(); let out_dir = crate_path.join(PathBuf::from(build_opts.out_dir)).clean();
let dev = build_opts.dev || build_opts.debug; let dev = build_opts.dev || build_opts.debug;
let profile = match (dev, build_opts.release, build_opts.profiling) { let profile = match (
(false, false, false) | (false, true, false) => BuildProfile::Release, dev,
(true, false, false) => BuildProfile::Dev, build_opts.release,
(false, false, true) => BuildProfile::Profiling, build_opts.profiling,
build_opts.profile,
) {
(false, false, false, None) | (false, true, false, None) => BuildProfile::Release,
(true, false, false, None) => BuildProfile::Dev,
(false, false, true, None) => BuildProfile::Profiling,
(false, false, false, Some(profile)) => BuildProfile::Custom(profile),
// Unfortunately, `clap` doesn't expose clap's `conflicts_with` // Unfortunately, `clap` doesn't expose clap's `conflicts_with`
// functionality yet, so we have to implement it ourselves. // functionality yet, so we have to implement it ourselves.
_ => bail!("Can only supply one of the --dev, --release, or --profiling flags"), _ => bail!("Can only supply one of the --dev, --release, --profiling, or --profile 'name' flags"),
}; };
Ok(Build { Ok(Build {
@ -355,7 +368,7 @@ impl Build {
fn step_build_wasm(&mut self) -> Result<()> { fn step_build_wasm(&mut self) -> Result<()> {
info!("Building wasm..."); info!("Building wasm...");
build::cargo_build_wasm(&self.crate_path, self.profile, &self.extra_options)?; build::cargo_build_wasm(&self.crate_path, self.profile.clone(), &self.extra_options)?;
info!( info!(
"wasm built at {:#?}.", "wasm built at {:#?}.",
@ -430,7 +443,7 @@ impl Build {
self.weak_refs, self.weak_refs,
self.reference_types, self.reference_types,
self.target, self.target,
self.profile, self.profile.clone(),
&self.extra_options, &self.extra_options,
)?; )?;
info!("wasm bindings were built at {:#?}.", &self.out_dir); info!("wasm bindings were built at {:#?}.", &self.out_dir);
@ -440,7 +453,7 @@ impl Build {
fn step_run_wasm_opt(&mut self) -> Result<()> { fn step_run_wasm_opt(&mut self) -> Result<()> {
let mut args = match self let mut args = match self
.crate_data .crate_data
.configured_profile(self.profile) .configured_profile(self.profile.clone())
.wasm_opt_args() .wasm_opt_args()
{ {
Some(args) => args, Some(args) => args,

@ -203,7 +203,7 @@ pub fn prebuilt_url_for(tool: &Tool, version: &str, arch: &Arch, os: &Os) -> Res
Tool::WasmOpt => { Tool::WasmOpt => {
Ok(format!( Ok(format!(
"https://github.com/WebAssembly/binaryen/releases/download/{vers}/binaryen-{vers}-{target}.tar.gz", "https://github.com/WebAssembly/binaryen/releases/download/{vers}/binaryen-{vers}-{target}.tar.gz",
vers = "version_117", vers = "version_117", // Make sure to update the version in docs/src/cargo-toml-configuration.md as well
target = target, target = target,
)) ))
} }

@ -85,6 +85,12 @@ struct CargoWasmPackProfiles {
deserialize_with = "CargoWasmPackProfile::deserialize_profiling" deserialize_with = "CargoWasmPackProfile::deserialize_profiling"
)] )]
profiling: CargoWasmPackProfile, profiling: CargoWasmPackProfile,
#[serde(
default = "CargoWasmPackProfile::default_custom",
deserialize_with = "CargoWasmPackProfile::deserialize_custom"
)]
custom: CargoWasmPackProfile,
} }
impl Default for CargoWasmPackProfiles { impl Default for CargoWasmPackProfiles {
@ -93,6 +99,7 @@ impl Default for CargoWasmPackProfiles {
dev: CargoWasmPackProfile::default_dev(), dev: CargoWasmPackProfile::default_dev(),
release: CargoWasmPackProfile::default_release(), release: CargoWasmPackProfile::default_release(),
profiling: CargoWasmPackProfile::default_profiling(), profiling: CargoWasmPackProfile::default_profiling(),
custom: CargoWasmPackProfile::default_custom(),
} }
} }
} }
@ -120,6 +127,9 @@ struct CargoWasmPackProfileWasmBindgen {
#[serde(default, rename = "omit-default-module-path")] #[serde(default, rename = "omit-default-module-path")]
omit_default_module_path: Option<bool>, omit_default_module_path: Option<bool>,
#[serde(default, rename = "split-linked-modules")]
split_linked_modules: Option<bool>,
} }
/// Struct for storing information received from crates.io /// Struct for storing information received from crates.io
@ -276,6 +286,7 @@ impl CargoWasmPackProfile {
demangle_name_section: Some(true), demangle_name_section: Some(true),
dwarf_debug_info: Some(false), dwarf_debug_info: Some(false),
omit_default_module_path: Some(false), omit_default_module_path: Some(false),
split_linked_modules: Some(false),
}, },
wasm_opt: None, wasm_opt: None,
} }
@ -288,6 +299,7 @@ impl CargoWasmPackProfile {
demangle_name_section: Some(true), demangle_name_section: Some(true),
dwarf_debug_info: Some(false), dwarf_debug_info: Some(false),
omit_default_module_path: Some(false), omit_default_module_path: Some(false),
split_linked_modules: Some(false),
}, },
wasm_opt: Some(CargoWasmPackProfileWasmOpt::Enabled(true)), wasm_opt: Some(CargoWasmPackProfileWasmOpt::Enabled(true)),
} }
@ -300,6 +312,20 @@ impl CargoWasmPackProfile {
demangle_name_section: Some(true), demangle_name_section: Some(true),
dwarf_debug_info: Some(false), dwarf_debug_info: Some(false),
omit_default_module_path: Some(false), omit_default_module_path: Some(false),
split_linked_modules: Some(false),
},
wasm_opt: Some(CargoWasmPackProfileWasmOpt::Enabled(true)),
}
}
fn default_custom() -> Self {
CargoWasmPackProfile {
wasm_bindgen: CargoWasmPackProfileWasmBindgen {
debug_js_glue: Some(false),
demangle_name_section: Some(true),
dwarf_debug_info: Some(false),
omit_default_module_path: Some(false),
split_linked_modules: Some(false),
}, },
wasm_opt: Some(CargoWasmPackProfileWasmOpt::Enabled(true)), wasm_opt: Some(CargoWasmPackProfileWasmOpt::Enabled(true)),
} }
@ -332,6 +358,15 @@ impl CargoWasmPackProfile {
Ok(profile) Ok(profile)
} }
fn deserialize_custom<'de, D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let mut profile = <Option<Self>>::deserialize(deserializer)?.unwrap_or_default();
profile.update_with_defaults(&Self::default_custom());
Ok(profile)
}
fn update_with_defaults(&mut self, defaults: &Self) { fn update_with_defaults(&mut self, defaults: &Self) {
macro_rules! d { macro_rules! d {
( $( $path:ident ).* ) => { ( $( $path:ident ).* ) => {
@ -342,6 +377,7 @@ impl CargoWasmPackProfile {
d!(wasm_bindgen.demangle_name_section); d!(wasm_bindgen.demangle_name_section);
d!(wasm_bindgen.dwarf_debug_info); d!(wasm_bindgen.dwarf_debug_info);
d!(wasm_bindgen.omit_default_module_path); d!(wasm_bindgen.omit_default_module_path);
d!(wasm_bindgen.split_linked_modules);
if self.wasm_opt.is_none() { if self.wasm_opt.is_none() {
self.wasm_opt = defaults.wasm_opt.clone(); self.wasm_opt = defaults.wasm_opt.clone();
@ -368,6 +404,11 @@ impl CargoWasmPackProfile {
self.wasm_bindgen.omit_default_module_path.unwrap() self.wasm_bindgen.omit_default_module_path.unwrap()
} }
/// Get this profile's configured `[wasm-bindgen.split-linked-modules]` value.
pub fn wasm_bindgen_split_linked_modules(&self) -> bool {
self.wasm_bindgen.split_linked_modules.unwrap()
}
/// Get this profile's configured arguments for `wasm-opt`, if enabled. /// Get this profile's configured arguments for `wasm-opt`, if enabled.
pub fn wasm_opt_args(&self) -> Option<Vec<String>> { pub fn wasm_opt_args(&self) -> Option<Vec<String>> {
match self.wasm_opt.as_ref()? { match self.wasm_opt.as_ref()? {
@ -490,6 +531,7 @@ impl CrateData {
BuildProfile::Dev => &self.manifest.package.metadata.wasm_pack.profile.dev, BuildProfile::Dev => &self.manifest.package.metadata.wasm_pack.profile.dev,
BuildProfile::Profiling => &self.manifest.package.metadata.wasm_pack.profile.profiling, BuildProfile::Profiling => &self.manifest.package.metadata.wasm_pack.profile.profiling,
BuildProfile::Release => &self.manifest.package.metadata.wasm_pack.profile.release, BuildProfile::Release => &self.manifest.package.metadata.wasm_pack.profile.release,
BuildProfile::Custom(_) => &self.manifest.package.metadata.wasm_pack.profile.custom,
} }
} }

@ -9,7 +9,7 @@ use std::path::PathBuf;
// Keep it up to date with each `wasm-pack` release. // Keep it up to date with each `wasm-pack` release.
// https://github.com/mozilla/geckodriver/releases/latest // https://github.com/mozilla/geckodriver/releases/latest
const DEFAULT_GECKODRIVER_VERSION: &str = "v0.34.0"; const DEFAULT_GECKODRIVER_VERSION: &str = "v0.35.0";
const DEFAULT_WINDOWS_GECKODRIVER_VERSION: &str = "v0.24.0"; const DEFAULT_WINDOWS_GECKODRIVER_VERSION: &str = "v0.24.0";
const GECKODRIVER_LAST_UPDATED_STAMP: &str = "geckodriver_last_updated"; const GECKODRIVER_LAST_UPDATED_STAMP: &str = "geckodriver_last_updated";

@ -212,6 +212,21 @@ fn build_different_profiles() {
} }
} }
#[test]
fn build_custom_profile() {
let profile_name = "my-custom-profile";
let fixture = utils::fixture::js_hello_world_with_custom_profile(profile_name);
fixture.install_local_wasm_bindgen();
fixture
.wasm_pack()
.arg("build")
.arg("--profile")
.arg(profile_name)
.assert()
.success();
}
#[test] #[test]
fn build_with_and_without_wasm_bindgen_debug() { fn build_with_and_without_wasm_bindgen_debug() {
for debug in [true, false].iter().cloned() { for debug in [true, false].iter().cloned() {

@ -154,6 +154,49 @@ impl Fixture {
) )
} }
/// Add a `Cargo.toml` with a correctly configured `wasm-bindgen`
/// dependency, `wasm-bindgen-test` dev-dependency, and `crate-type =
/// ["cdylib"]`.
///
/// `name` is the crate's name.
/// `profile` is the custom profile name.
pub fn cargo_toml_with_custom_profile(&self, name: &str, profile_name: &str) -> &Self {
self.file(
"Cargo.toml",
&format!(
r#"
[package]
authors = ["The wasm-pack developers"]
description = "so awesome rust+wasm package"
license = "WTFPL"
name = "{}"
repository = "https://github.com/rustwasm/wasm-pack.git"
version = "0.1.0"
[lib]
crate-type = ["cdylib"]
[dependencies]
# Note that this uses and `=` dependency because there are
# various tests which assert that the version of wasm
# bindgen downloaded is what we expect, and if `=` is
# removed then it will download whatever the newest version
# of wasm-bindgen is which may not be what's listed here.
wasm-bindgen = "=0.2.74"
[dev-dependencies]
wasm-bindgen-test = "0.3"
[profile.{}]
inherits = "release"
opt-level = 'z'
lto = true
"#,
name, profile_name
),
)
}
/// Add a `Cargo.toml` with a correctly configured `wasm-bindgen` /// Add a `Cargo.toml` with a correctly configured `wasm-bindgen`
/// dependency, `wasm-bindgen-test` dev-dependency, and `crate-type = /// dependency, `wasm-bindgen-test` dev-dependency, and `crate-type =
/// ["cdylib"]`. /// ["cdylib"]`.
@ -404,6 +447,15 @@ pub fn js_hello_world() -> Fixture {
fixture fixture
} }
pub fn js_hello_world_with_custom_profile(profile_name: &str) -> Fixture {
let fixture = Fixture::new();
fixture
.readme()
.cargo_toml_with_custom_profile("js-hello-world", profile_name)
.hello_world_src_lib();
fixture
}
pub fn no_cdylib() -> Fixture { pub fn no_cdylib() -> Fixture {
let fixture = Fixture::new(); let fixture = Fixture::new();
fixture.readme().hello_world_src_lib().file( fixture.readme().hello_world_src_lib().file(

Loading…
Cancel
Save