Documentation
    Preparing search index...

    Exposes the API to start the development server in HMR, watch or static mode.

    In HMR mode, the DevServer will exec the "bin/server.ts" file and let hot-hook manage the changes using hot module reloading.

    In watch mode, the DevServer will start an internal watcher and restarts the after every file change. The files must be part of the TypeScript project (via tsconfig.json), or registered as metaFiles.

    const devServer = new DevServer(cwd, { hmr: true, hooks: [] })
    await devServer.start(ts)
    Index

    Constructors

    Properties

    scriptFile: string = 'bin/server.ts'

    Script file to start the development server

    cwd: URL

    The current working directory URL

    Development server configuration options including hooks and environment variables

    Accessors

    • get ui(): {}

      CLI UI instance to log colorful messages and progress information

      Returns {}

    • set ui(ui: {}): void

      CLI UI instance to log colorful messages and progress information

      Parameters

      • ui: {}

      Returns void

    • get mode(): "hmr" | "watch" | "static"

      The mode in which the DevServer is running.

      Returns "hmr" | "watch" | "static"

    Methods

    • Add listener to get notified when dev server is closed

      Parameters

      • callback: (exitCode: number) => any

        Function to call when dev server closes

      Returns this

      This DevServer instance for method chaining

    • Add listener to get notified when dev server encounters an error

      Parameters

      • callback: (error: any) => any

        Function to call when dev server encounters an error

      Returns this

      This DevServer instance for method chaining

    • Close watchers and the running child process

      Returns Promise<void>

    • Start the development server in static or HMR mode

      Parameters

      • ts: typeof ts

        TypeScript module reference

      Returns Promise<void>

    • Start the development server in watch mode and restart on file changes

      Parameters

      • ts: typeof ts

        TypeScript module reference

      • Optionaloptions: { poll: boolean }

        Watch options including polling mode

      Returns Promise<void>