contributor-context
Contributor context for coding agents working in this repository. Human contributors should start with `README.md` and…
<!-- GENERATED from docs/playbooks/integration/webpack-rspack.md by scripts/build-agent-skill.mjs. Do not edit. -->
$ npx -y skills add crossbind/crossbind --agent claude-codeHow it fires
How this agent gets triggered: by you, by Claude, or both.
Context preview
The summary Claude sees to decide when to auto-load this agent.
<!-- GENERATED from docs/playbooks/integration/webpack-rspack.md by scripts/build-agent-skill.mjs. Do not edit. -->
<!-- GENERATED from docs/playbooks/integration/webpack-rspack.md by scripts/build-agent-skill.mjs. Do not edit. -->
> Persona 2 sub-playbook. The user's project uses Webpack or Rspack (`webpack` / `@rspack/core` in deps; `webpack.config.*` or `rspack.config.*` at root).
> The same `@crossbind/plugin-webpack` package supports **both** Webpack and Rspack — Rspack reuses the Webpack plugin API surface.
Wire `@crossbind/plugin-webpack` into the bundler config so dev-server serves wasm with COOP/COEP, the loader handles `.h` and `.rs` files (plus `cargo:` crate imports, `conan:` header imports and bare Rust package imports), and prod build emits `crossbind.js` + `crossbind.wasm` artifacts.
| File | Role | |------|------| | `package.json` | + `@crossbind/plugin-webpack`, `@crossbind/plugin-webpack-loader` (devDependencies), optional `@crossbind/port-<name>` | | `webpack.config.*` / `rspack.config.*` | Construct plugin, register loader rule, plug `devServer` config | | `crossbind.config.js` *(new at root)* | Project-level crossbind config | | `src/native/` *(only if user wraps own C++)* | `.h` + `.cpp` source files | | Production headers config | Hosting layer (only for multithread) |
pnpm add -D @crossbind/plugin-webpack@beta @crossbind/plugin-webpack-loader@beta pnpm add @crossbind/port-<name>@beta # optional, for prebuilt libraries # Dev (Rspack) pnpm dev # or `pnpm rspack serve` # Dev (Webpack) pnpm dev # or `pnpm webpack serve` # Production pnpm build
Mirror `examples/web-react-rspack/rspack.config.mjs` (canonical for Rspack; Webpack identical except imports):
import { defineConfig } from '@rspack/cli';
import CrossbindWebpackPlugin from '@crossbind/plugin-webpack';
const crossbindWebpackPlugin = new CrossbindWebpackPlugin();
export default defineConfig({
entry: { main: './src/main.jsx' },
module: {
rules: [
crossbindWebpackPlugin.getRule(), // .h loader, hands work to plugin-webpack-loader
// ... other rules
],
},
plugins: [
crossbindWebpackPlugin, // register the plugin
],
devServer: crossbindWebpackPlugin.getDevServerConfig(), // COOP/COEP + middleware
});What the plugin gives you:
For Webpack (CommonJS-style):
const CrossbindWebpackPlugin = require('@crossbind/plugin-webpack').default;
const crossbindWebpackPlugin = new CrossbindWebpackPlugin();
module.exports = {
// …same shape as the Rspack example
};If the project already has a `devServer` block, **merge** with `getDevServerConfig()`:
const cppDev = crossbindWebpackPlugin.getDevServerConfig();
export default defineConfig({
// …
devServer: {
...cppDev,
port: 4000,
proxy: [...],
headers: { ...cppDev.headers, 'X-Custom': 'value' },
},
});Key headers are `Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: require-corp`. Don't drop them.
Same as the Vite playbook — devServer is handled by the plugin, production deploy is the user's hosting layer's responsibility. See `docs/playbooks/integration/vite.md` "Multithread → production headers" table for per-host recipes.
Plugin source: `plugins/webpack/index.js`. Loader source: `plugins/webpack-loader/`.
Import C++ and Rust like JavaScript modules (WebAssembly & React Native)
Contributor context for coding agents working in this repository. Human contributors should start with `README.md` and…
<!-- GENERATED from docs/api/app.md by scripts/build-agent-skill.mjs. Do not edit. -->
<!-- GENERATED from docs/api/build-state.md by scripts/build-agent-skill.mjs. Do not edit. -->
<!-- GENERATED from docs/api/conan.md by scripts/build-agent-skill.mjs. Do not edit. -->
<!-- GENERATED from docs/api/cpp-binding-rules.md by scripts/build-agent-skill.mjs. Do not edit. -->