How to use the fork-ts-checker-webpack-plugin.getCompilerHooks function in fork-ts-checker-webpack-plugin

To help you get started, we’ve selected a few fork-ts-checker-webpack-plugin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github johnnyreilly / fork-ts-checker-notifier-webpack-plugin / index.ts View on Github external
apply(compiler: any) {
    if ('hooks' in compiler) {
      // webpack 4+
      try {
        forkTsCheckerWebpackPlugin
          .getCompilerHooks(compiler)
          .receive.tap('fork-ts-checker-notifier-webpack-plugin', this.compilationDone);
      } catch (error) {
        console.error(`
          Something went wrong in accessing the hooks.
          Most likely the order of plugins is wrong.\n
          Check the documentation for "fork-ts-checker-notifier-webpack-plugin"\n
        `);
        throw Error(`Error: ${error}`);
      }
    } else {
      // webpack 2 / 3
      compiler.plugin('fork-ts-checker-receive', this.compilationDone);
    }
  }
}
github zeit / next.js / packages / next / build / output / index.ts View on Github external
compiler.hooks.invalid.tap(`NextJsInvalid-${key}`, () => {
      tsMessagesPromise = undefined
      onEvent({ loading: true })
    })

    if (hasTypeChecking) {
      const typescriptFormatter = createCodeframeFormatter({})

      compiler.hooks.beforeCompile.tap(`NextJs-${key}-StartTypeCheck`, () => {
        tsMessagesPromise = new Promise(resolve => {
          tsMessagesResolver = msgs => resolve(msgs)
        })
      })

      forkTsCheckerWebpackPlugin
        .getCompilerHooks(compiler)
        .receive.tap(
          `NextJs-${key}-afterTypeScriptCheck`,
          (diagnostics: NormalizedMessage[], lints: NormalizedMessage[]) => {
            const allMsgs = [...diagnostics, ...lints]
            const format = (message: NormalizedMessage) =>
              typescriptFormatter(message, true)

            const errors = allMsgs
              .filter(msg => msg.severity === 'error')
              .map(d => ({
                file: (d.file || '').replace(/\\/g, '/'),
                message: format(d),
              }))
            const warnings = allMsgs
              .filter(msg => msg.severity === 'warning')