1.0.0 • Published 8 months ago

@reactive-forge/codegen v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

@reactive-forge/codegen

Code generation part of the Reactive Forge.

This package provides function that can be used to generate metadata for react components and cli tool that wraps around this function and also provides command for generating config file.

Generating config

To generate config, run

npx forge init

and follow instructions from console. It will create forge.config.ts file in your current working directory.

Generating component metadata

First, you need to create config file. It can be either forge.config.ts, forge.config.js, forgerc.ts or forgerc.js. Default exported object must be assignable to ForgeConfig from @reactive-forge/codegen package.

Once you create it, you can run

npx forge codegen

or simply

npx forge

to generate argument information for your components. Note, that generated files will use types from @reactive-forge/shared package, and you will need to add it as your dependency when shipping your library to end-users.

Config

Available options:

FieldTypeDefaultDescription
debugbooleanfalseenables debug output to the console
silentbooleanfalsedisables console output except for errors
outDirstring"reactive-forge"directory to put output files in
rootDirstring"."path to the root of the project
baseDirstring"src"path to the roof of the componentsfile paths in the generated output will be relative to this path
componentRootsstring[][baseDir]root directories to start the search for components
pathPrefixstring"@/"prefix of the file paths in the generated output
tsConfigFilePathstringpath.resolve(rootDir, "./tsconfig.json")location of tsconfig.json of the project
typescriptLibPathstringpath.resolve(rootDir, "./node_modules/typescript/lib")path to the typescript lib folderimportant when using workspaces
reactTypesFilePathstringpath to the index.d.ts of type for reactimportant when using workspaces