Create a Worker library
The library generator creates a Cloudflare Worker library — a shareable package with Workers runtime types, suitable for shared logic, bindings, or utilities consumed by Worker applications.
Alias: lib
bunx nx g @naxodev/nx-cloudflare:library my-worker-lib
Options
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
directory | string | (required) | The directory of the new library. Accepted as the first positional argument. |
name | string | - | The name of the library. |
linter | eslint | none | eslint | The tool to use for running lint checks. |
unitTestRunner | vitest | none | (prompted) | Test runner to use for unit tests. |
tags | string | - | Add tags to the library (used for linting). |
skipFormat | boolean | false | Skip formatting files. |
skipPackageJson | boolean | false | Do not add dependencies to package.json. |
skipTsConfig | boolean | false | Do not update tsconfig.json for development experience. |
js | boolean | false | Generate JavaScript files rather than TypeScript files. |
strict | boolean | true | Whether to enable tsconfig strict mode or not. |
publishable | boolean | false | Generate a publishable library. |
importPath | string | - | The library name used to import it, like @myorg/my-awesome-lib. Required for publishable library. |
setParserOptionsProject | boolean | false | Whether or not to configure the ESLint parserOptions.project option. We do not do this by default for lint performance reasons. |
config | workspace | project | npm-scripts | project | Determines whether the project's executors should be configured in workspace.json, project.json or as npm scripts. |
bundler | swc | tsc | vite | esbuild | none | tsc | The bundler to use. Choosing 'none' means this library is not buildable. |
skipTypeCheck | boolean | false | Whether to skip TypeScript type checking for SWC compiler. |
minimal | boolean | false | Generate a library with a minimal setup. No README.md generated. |
simpleName | boolean | false | Don't include the directory in the generated file name. |
Publishable libraries require importPath and cannot use bundler=none. Non-publishable libraries have bundler forced to none (not buildable) regardless of the value passed.
Worker libraries have no Wrangler config, so no inferred targets are generated (serve, deploy, typegen, etc. are not available). Workers runtime types come from @cloudflare/workers-types via tsconfig.lib.json, not a generated worker-configuration.d.ts.
Verify
Section titled “Verify”bunx nx show project my-worker-lib
The library appears in the graph at the directory you generated it in.
Next steps
Section titled “Next steps”- application generator — scaffold a Worker application
- init generator — workspace-level setup
- Plugin options — inferred target names