$ npm install @tetherto/wdk-worklet-bundlerCLI tool for generating optimized WDK worklet bundles. This tool packages specific blockchain modules (Wallets, Protocols) into a single artifact designed to run in a separate Bare runtime thread, isolated from your main React Native application loop.
This architecture ensures:
bare-node-runtime) for standard crypto libraries.# Global installation
npm install -g @tetherto/wdk-worklet-bundler
# Or as a project dependency (recommended)
npm install --save-dev @tetherto/wdk-worklet-bundler
# Or run directly without installation
npx @tetherto/wdk-worklet-bundler
Initialize a configuration in your React Native project:
wdk-worklet-bundler init
Configure your networks in wdk.config.js:
module.exports = {
networks: {
ethereum: {
package: '@tetherto/wdk-wallet-evm-erc-4337'
},
bitcoin: {
package: '@tetherto/wdk-wallet-btc'
}
}
};
Generate the bundle:
# Automatically installs missing WDK modules to your dependencies
wdk-worklet-bundler generate --install
Use it in your App:
import { WdkAppProvider } from '@tetherto/pear-wrk-wdk';
// Import the generated bundle asset (handled by metro/webpack as a static asset)
const workletBundle = require('./.wdk-bundle/wdk-worklet.bundle.js');
function App() {
return (
<WdkAppProvider bundle={{ bundle: workletBundle }}>
{/* Your App Content */}
</WdkAppProvider>
);
}
The bundler orchestrates the creation of a standalone JavaScript environment ("Worklet") that communicates with your main application.
bare-pack.We recommend installing all WDK modules and the core library as dependencies. The bundler compiles them into the separate worklet artifact, but having them in dependencies ensures proper resolution and type availability.
generateBuilds the worklet bundle.
wdk-worklet-bundler generate [options]
Options:
-c, --config <path>: Path to config file.--install: Automatically install missing modules listed in your config (saves to devDependencies).--keep-artifacts: Keep the intermediate .wdk/ folder (useful for debugging generated source code). By default, this is cleaned up.--source-only: Generate the entry files but skip the final bare-pack bundling step.--skip-generation: Skip artifact generation and use existing files.--dry-run: Print what would happen without writing files.--no-types: Skip generating TypeScript definitions (index.d.ts).-v, --verbose: Show verbose output.initCreates a fresh wdk.config.js file.
wdk-worklet-bundler init [options]
Options:
-y, --yes: Use defaults without prompting.validateChecks if your configuration is valid and if all required dependencies are installed.
wdk-worklet-bundler validate [options]
Options:
-c, --config <path>: Path to config file.list-modulesList available WDK modules.
wdk-worklet-bundler list-modules [options]
Options:
--json: Output as JSON.cleanRemove generated .wdk folder.
wdk-worklet-bundler clean [options]
Options:
-y, --yes: Skip confirmation.wdk.config.js)module.exports = {
// Map logical network names to WDK wallet packages
networks: {
ethereum: {
package: '@tetherto/wdk-wallet-evm-erc-4337'
},
local_dev: {
package: './local-packages/my-custom-wallet' // Local paths supported
}
},
// Map logical protocol names to WDK protocol packages
protocols: {
aaveEvm: {
package: '@tetherto/wdk-protocol-aave-lending-evm'
}
},
// Native addons to preload (e.g. for specific crypto requirements)
preloadModules: [
'spark-frost-bare-addon'
],
// Customize output locations
output: {
bundle: './.wdk-bundle/wdk-worklet.bundle.js',
types: './.wdk/index.d.ts'
},
// Build options
options: {
minify: false, // Optional: Minify the bundle
sourceMaps: false, // Optional: Generate source maps
targets: ['ios-arm64', 'android-arm64'] // bare-pack targets
}
};
"Module not found" during generation:
Run wdk-worklet-bundler generate --install. This ensures all packages defined in your config (plus the core @tetherto/pear-wrk-wdk) are present in your node_modules.
"Missing dependency" inside the worklet:
If you see runtime errors about missing modules inside the worklet, ensure pear-wrk-wdk is properly installed. The bundler treats it as an external dependency that must be present.
Apache-2.0