devicesdk build
Bundle device scripts and regenerate inter-device RPC types
Usage
devicesdk build [flags]
Flags
-d, --device <id>— Build only one device.-o, --outdir <path>— Output directory (default:.devicesdk/build).--minify— Minify the output.--sourcemap— Generate source maps.-c, --config <path>— Path to thedevicesdk.tsconfig file.
Description
devicesdk build does two things:
- Generates
devicesdk-env.d.tsalongsidedevicesdk.ts. This file contains type-safe inter-device RPC types based on the device map indevicesdk.ts— soawait this.env.DEVICES["sensor-1"].method()autocompletes correctly. Re-runbuildafter any change to thedevicesblock. - Bundles each device’s
mainfile with esbuild (ESM, ES2022 target) into.devicesdk/build/<device-id>.js. Bundles must be under 1 MB.
devicesdk dev and devicesdk deploy both run build automatically; you only need to call it explicitly when you want to inspect the output or pre-warm the type generation in CI.
Common errors
Class "X" must be exported as a named export— your device file hasexport default class X. Change toexport class X.Main file not found— themainpath indevicesdk.tsis wrong. The path is relative todevicesdk.tsitself.Script exceeds maximum size of 1MB— the bundle is too large. Remove unnecessary deps and check that you’re not bundling Node-only packages.
Examples
# Build all devices
devicesdk build
# Build just one
devicesdk build --device thermostat --minify
# Build to a custom location
devicesdk build --outdir dist/ --sourcemap
Related
devicesdk deploy— push the build to production.devicesdk dev— run the simulator (callsbuildinternally).- Device entrypoints — what your
mainfile should look like.