1.15.1 • Published 7 months ago

mwtsc v1.15.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

midway tsc

it's a tsc wrapper, like tsc-watch.

Usage

# run package file
$ npx mwtsc --watch --run @midwayjs/mock/app.js

# run file
$ npx mwtsc --watch --run ./bootstrap.js

# run with tsc options
$ npx mwtsc --watch --project tsconfig.production.json --run ./bootstrap.js

# run with kill timeout
$ npx mwtsc --watch --run ./bootstrap.js --kill-timeout 5000

# the child process keep avaliable during the development
$ npx mwtsc --watch --run ./bootstrap.js --keepalive

# run with inspect and debug in chrome or other supported tools
$ npx mwtsc --watch --inspect --run ./bootstrap.js
$ npx mwtsc --watch --inspect-brk --run ./bootstrap.js

Different with tsc and tsc-watch

  • 1、support --run option, run file after compile success
  • 2、support copy non-ts file to dist directory when build source code
  • 3、support ts alias path by tsc-alias

About --kill-timeout

Process kill timeout in milliseconds. When restarting the application, if the process doesn't exit within this time, it will be forcefully killed.

Default: 2000

When using Ctrl+C to stop the process, it will follow the kill-timeout to kill the process.

About --inspect and --inspect-brk

If you're using VSCode or JetBrains IntelliJ IDEA (or other IDEs), you won't need to manually start the child process with debugging flags like --inspect or --inspect-brk. The IDE will automatically attach the debugger to the child process.

However, if you wish to debug the child process within Chrome, you can utilize --inspect or --inspect-brk to initiate the child process with the debugger enabled.

$ npx mwtsc --watch --inspect --run ./bootstrap.js
$ npx mwtsc --watch --inspect-brk --run ./bootstrap.js

Unfortunately, Chrome DevTools cannot directly access local files with certain special protocols due to security policies. To overcome this, we set up a proxy server to serve the source files. You will need to configure the proxy server's location in your tsconfig.json to properly handle source maps.

{
  "compilerOptions": {
    "sourceRoot": "http://localhost:7788/"
  }
}

API

You can use mwtsc API in your code to extend your own logic.

mwtsc API:

  • run - run tsc compile
  • chokidar - watch file change

run API:

  • exit - exit process
  • restart - restart process
  • onExit - on exit event
// custom.js
const { run, chokidar } = require('mwtsc');
const { restart, exit, onExit } = run();

const watcher = chokidar.watch('node_modules/**/*.ts', {
  ignoreInitial: true,
  ignored: ['**/*.d.ts'],
});

watcher.on('all', (event, path) => {
  console.log(event, path);
  restart([
    '/home/admin/workspace/midwayjs/midway/packages/mock/src/app.ts',
  ]);
});

onExit(async () => {
  await watcher.close();
});

Rewrite dev command in package.json .

{
  "scripts": {
    "dev": "NODE_ENV=local node ./custom.js --watch --run ./bootstrap.js"
  }
}
1.14.0

7 months ago

1.15.0

7 months ago

1.13.0

8 months ago

1.15.1

7 months ago

1.12.0-beta.5

9 months ago

1.12.0-beta.6

9 months ago

1.12.0-beta.7

9 months ago

1.12.0

9 months ago

1.12.0-beta.1

9 months ago

1.12.0-beta.2

9 months ago

1.12.0-beta.3

9 months ago

1.12.0-beta.4

9 months ago

1.11.3

9 months ago

1.10.3

1 year ago

1.10.2

1 year ago

1.11.0

1 year ago

1.11.2

12 months ago

1.11.1

12 months ago

1.11.0-beta.2

1 year ago

1.11.0-beta.3

1 year ago

1.11.0-beta.1

1 year ago

1.10.1

1 year ago

1.10.0

1 year ago

1.9.1

1 year ago

1.9.0

1 year ago

1.8.1

1 year ago

1.8.0

1 year ago

1.8.0-beta.3

1 year ago

1.8.0-beta.1

1 year ago

1.8.0-beta.2

1 year ago

1.7.2

1 year ago

1.7.1-beta.1

1 year ago

1.7.1-beta.2

1 year ago

1.7.1

1 year ago

1.7.0

1 year ago

1.7.0-beta.3

1 year ago

1.7.0-beta.1

1 year ago

1.7.0-beta.2

1 year ago

1.6.3

1 year ago

1.6.2

1 year ago

1.6.1

1 year ago

1.6.0

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.5.0-beta.2

1 year ago

1.5.0-beta.1

1 year ago

1.4.0

1 year ago

1.4.0-beta.3

1 year ago

1.4.0-beta.2

1 year ago

1.4.0-beta.1

1 year ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.1-beta.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago