@crestanzio/typemon

0.0.3 • Public • Published

typemon

typemon is a tool that help the typescript development process, does that typescript don't does at this time, synchronize all files and folders from source to destination and automatic restart the node application. Is like nodemon, but for typescript.

This is the best way to work with typescript, many tools compile typescript on the fly, but is not provide type checking, so you gonna lose all the benefits that typescript actually provides!

With this setup you have always an updated build without the need to stop the development process. And also all the benefits from typescript compiler.

Watch

typemon is designed to watch all events so get the last updated version on the destination directory.

specifically:

  • change
  • add
  • delete
  • rename
  • addDir
  • deleteDir
  • renameDir

Installation

install typemon global:

npm install -g typemon # or using yarn: yarn global add typemon

install typemon as dev dependency:

npm install --save-dev typemon # or using yarn: yarn add typemon -D

Usage

On the fly

npx -c 'tsc --watch & typemon' # run without install the package

locally

Just declare the typescript watch in parallel with typemon as start script.

"scripts": {
	"start": "tsc --watch & typemon"
}

Config

typemon looks for configuration in package.json, typemon config can declared by object typemonConfig.

Options

"typemonConfig": {
	"main": "string"
	"tsConfig": "string"
	"delay": "number"
}

typemon requires an entry point to execute, you can declare an entry point on package.json main or typemonConfig main. If both are present default is package.json main .

delay is configured in seconds, default 1,5.

Also, requires an tsconfig.json || tsconfig.anything.json. default is tsconfig.json at the top level of project.

Is looking for the options rootDir and outDir. if an option is not found, current working directory gonna used as default.

Example

package.json

{
"main": "build/index.js"
"typemonConfig": {
    "tsConfig": "tsconfig.json",
    "delay": 5
  }
}

tsconfig.json

{
  "compilerOptions": {
    "rootDir": "src",
    "outDir": "build"
  }
}

Recommend setup for scripts

  "scripts":  {
    "start":  "tsc --watch & typemon",
    "prebuild":  "rm -rf ./build",
    "build":  "tsc",
    "postbuild":  "rsync -a --exclude='*.ts' ./src/ ./build/"
  },

This way on a build process you have a new clear build directory with all the necessary files included.

Package Sidebar

Install

npm i @crestanzio/typemon

Weekly Downloads

0

Version

0.0.3

License

none

Unpacked Size

9.08 kB

Total Files

9

Last publish

Collaborators

  • crestanzio