@zero-version/tsc-tidy.cli

9.9.14 • Public • Published

Update the output file structure after a TypeScript compile.

Usage

Usage: tsc-tidy [options]

Update the output file structure after a TypeScript compile.

Options:
  -V, --version           output the version number
  -d, --projectDir <dir>  The project directory (default: `process.cwd()`)
  -o, --outDir <dir>      The output directory (default: "lib")
  -t, --tmpDir <dir>      A temp directory (default: ".tmp")
  -s, --srcDir <dir>      The source directory (default: "src")
  -h, --help              display help for command

Example

tsc-tidy may be useful as part of the build process for TypeScript monorepos as an alternative to using the include, exclude and files settings in a tsconfig.json file.

Given the following monorepo structure where project-b has a dependency on project-a:

packages/
├── project-a/
│   ├── src/
│   │   ├── ClassA.ts
│   │   ├── IInterfaceA.ts
│   │   └── index.ts
│   ├── package.json
│   └── tsconfig.json
└── project-b/
    ├── src/
    │   ├── ClassB.ts
    │   └── index.ts
    ├── package.json
    └── tsconfig.json

And project-b has the following tsconfig.json:

{
  "compilerOptions": {
    "baseUrl": ".",
    "declaration": true,
    "esModuleInterop": true,
    "outDir": "./lib",
    "paths": {
      "project-a": ["../project-a/src/index.ts"],
      "project-a/*": ["../project-a/src/*"]
    },
    "strict": true
  }
}

When project-b is compiled with the TypeScript compiler, the lib directory looks like this:

packages/
└── project-b/
    └── lib/
        ├── project-a/
        │   └── src/
        │       ├── ClassA.d.ts
        │       ├── ClassA.js
        │       ├── IInterfaceA.d.ts
        │       ├── IInterfaceA.js
        │       ├── index.d.ts
        │       └── index.js
        └── project-b/
            └── src/
                ├── ClassB.d.ts
                ├── ClassB.js
                ├── index.d.ts
                └── index.js

After running tsc-tidy, the lib directory now looks like this:

packages/
└── project-b/
    └── lib/
        ├── ClassB.d.ts
        ├── ClassB.js
        ├── index.d.ts
        └── index.js

This may be a better structure for bundling types and javascript for project-b.

Support

Are you using a package I've developed and finding it useful? Or have you looked at one of my repositories and learnt something new? If so, please consider buying me a coffee. Thanks!

Package Sidebar

Install

npm i @zero-version/tsc-tidy.cli

Weekly Downloads

0

Version

9.9.14

License

UNLICENSED

Unpacked Size

8.73 kB

Total Files

3

Last publish

Collaborators

  • andrewcrobertson