create-tw-extension
create-tw-extension
scaffolds a ready-to-build TurboWarp / Scratch extension
project. You pick a bundler; it wires up the matching scratch4js plugin
(tw-plugin-webpack or tw-plugin-rollup),
writes a working starter extension, and installs the dependencies — so
npm run build produces the single self-contained file TurboWarp expects.
Quick start
Run it with your package manager's create command — no global install needed:
With no arguments it launches an interactive wizard (built with Ink). Answer four questions and it scaffolds, installs, and prints the next steps:
Non-interactive
Pass a project name and flags to skip the prompts — handy for scripts and CI:
The
--separatesnpm create's own arguments from the ones forwarded to the scaffolder.pnpm/yarn/bunforward trailing args directly, so the--isn't needed there.
Options
Choosing a bundler
All six options produce the same single-file extension; pick whichever toolchain you prefer. Under the hood each maps to one of the two scratch4js plugins:
See the webpack / Rspack and Rollup / Rolldown / Vite plugin docs for the full set of options the generated config exposes.
Package-manager detection
When you run through npm create / pnpm create / yarn create /
bun create, the launching tool sets npm_config_user_agent. The scaffolder
reads it and pre-selects that package manager in the wizard (and uses it as
the default in non-interactive mode), so the tool you already typed is the one
that runs the install. Override it any time with --package-manager.
Types
Choosing Yes (or passing --types) adds
@turbowarp/types as a dev dependency
and a jsconfig.json that pulls in its declarations, so your editor
autocompletes the global Scratch API (Scratch.BlockType,
Scratch.ArgumentType, and friends). It's installed straight from git:
What gets generated
The entry module export defaults the extension class and imports a sibling
helper — the plugin inlines everything into one file and wires up
Scratch.extensions.register() for you (no register() call in your source).
Next steps
Then load dist/<id>.js into TurboWarp via Add Extension → Custom Extension
(the Files tab, or paste the contents into the Text tab). Use
npm run dev to rebuild on every change while you work.