1.1.0 • Published 2 years ago
@matii96/nx-tsc v1.1.0
Nx-tsc
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
Property | What it does | Required |
---|---|---|
main | The name of the main entry-point file | ✓ |
tsConfig | The name of the Typescript configuration file | ✓ |
assets | List of static application assets | ✓ |
watch | Run build when files change | |
debounceTime | Debounce timeout after last file change for watch mode |
License
Nx-tsc is MIT licensed.