liveBook · Manning

Bundling

As explained in Refactoring to Rust

A bundler is a build tool that combines source modules and dependencies into one or more distributable assets.

A bundler assembles code and libraries into a module or executable script. For WebAssembly used as a library in a JavaScript component, the bundler target makes the code importable; separate browser scripts instead require pages to track which scripts they load and how they interact. section 9.4

Listing 9.12 Console: Bundling the library
wasm-pack build --target bundler
cd pkg
npm link
cd ../papers-list

Build the WebAssembly package for a bundler, then link it into the application project. section 9.4

Listing 9.13 package.json: Adding local dependency
"dependencies": {
    "papers": "file:../pkg",
    ...
  }

Declare the generated WebAssembly package as a local project dependency. section 9.4

How Refactoring to Rust covers it

How deep it goes
Defines bundling and contrasts script loading with module imports, then demonstrates a WebAssembly build and package setup.
Examples
Uses wasm-pack build commands, npm package linking, and a local dependency declaration.
What it assumes
Assumes npm is installed and uses a React app scaffold; it specifies no further background requirements.
What you can do after
Configure it with wasm-pack's bundler target and link the generated package into a JavaScript app.
How it connects
Connects JavaScript modules, browser script loading, WebAssembly, npm, Vite, and React.

Also explained in

Compare how 8 books explain bundling →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Refactoring to Rust. The section links point to the parts of the book it draws on.