Skip to content

library generator

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
OptionTypeDefaultDescription
directorystring(required)The directory of the new library. Takes the first positional argument.
namestringThe name of the library. Must match ^[a-zA-Z][^:]*$.
lintereslint | noneeslintThe tool to use for running lint checks.
unitTestRunnervitest | none(prompted)Test runner to use for unit tests.
bundlerswc | tsc | vite | esbuild | nonetscThe bundler to use. none means the library is not buildable.
publishablebooleanfalseGenerate a publishable library.
importPathstringThe library name used to import it (e.g. @myorg/my-lib). Required for publishable libraries.
jsbooleanfalseGenerate JavaScript files rather than TypeScript files.
strictbooleantrueEnable tsconfig strict mode.
tagsstringComma-separated tags added to the library (used for linting).
minimalbooleanfalseGenerate a library with minimal setup. No README.md generated.
simpleNamebooleanfalseDon’t include the directory in the generated file name.
configworkspace | project | npm-scriptsprojectWhere to configure the project’s executors.
skipFormatbooleanfalseSkip formatting files.
skipPackageJsonbooleanfalseDo not add dependencies to package.json.
skipTsConfigbooleanfalseDo not update tsconfig.json for development experience.
skipTypeCheckbooleanfalseSkip TypeScript type checking for SWC compiler.
setParserOptionsProjectbooleanfalseConfigure the ESLint parserOptions.project option. Off by default for lint performance.

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.

bunx nx show project my-worker-lib

The library appears in the graph at the directory you generated it in.