1.1.0 • Published 1 year ago

@matii96/nx-tsc v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Nx-tsc

MIT Licensed ci

Typescript executor for Nx workspace.

Why?

Nx only allows to use webpack as ts builder. While it has benefits like slightly reduced bundle size, it makes using build-reliant libraries like MikroORM a pain to use as it prevents distribution directory exploration.

How?

Nx-tsc eliminates this problem by introducing a full-fledged tsc build keeping hot-reload (serve) option.

Installation

$ npm i --save-dev @matii96/nx-tsc

Example

App's project.json:

{
  "root": "apps/my-app",
  "sourceRoot": "apps/my-app/src",
  "projectType": "application",
  "targets": {
    "build": {
      "executor": "@matii96/nx-tsc:build",
      "options": {
        "main": "apps/my-app/src/main.js",
        "tsConfig": "apps/my-app/tsconfig.app.json",
        "assets": ["apps/my-app/src/assets"]
      },
      "configurations": {
        "production": {
          "optimization": true,
          "extractLicenses": true,
          "inspect": false,
          "fileReplacements": [
            {
              "replace": "apps/my-app/src/environments/environment.ts",
              "with": "apps/my-app/src/environments/environment.prod.ts"
            }
          ]
        }
      }
    },
    "..."
  },
  "tags": []
}

App's tsconfig.app.json:

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "../../dist/out-tsc/my-app",
    "..."
  },
  "..."
}

Nothing changes in serve and build commands:

$ nx serve my-app
$ nx build my-app

Options

PropertyWhat it doesRequired
mainThe name of the main entry-point file
tsConfigThe name of the Typescript configuration file
assetsList of static application assets
watchRun build when files change
debounceTimeDebounce timeout after last file change for watch mode

License

Nx-tsc is MIT licensed.