How to use the @parcel/diagnostic.anyToDiagnostic function in @parcel/diagnostic

To help you get started, we’ve selected a few @parcel/diagnostic 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 parcel-bundler / parcel / packages / core / logger / src / Logger.js View on Github external
error(input: Diagnostifiable, realOrigin?: string): void {
    // $FlowFixMe origin is undefined on PluginInputDiagnostic
    let diagnostic = anyToDiagnostic(input);
    if (typeof realOrigin === 'string') {
      diagnostic = Array.isArray(diagnostic)
        ? diagnostic.map(d => {
            return {...d, origin: realOrigin};
          })
        : {
            ...diagnostic,
            origin: realOrigin,
          };
    }

    this.#logEmitter.emit({
      type: 'log',
      level: 'error',
      diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic],
    });
github parcel-bundler / parcel / packages / core / logger / src / Logger.js View on Github external
error(input: Diagnostifiable, realOrigin?: string): void {
    // $FlowFixMe origin is undefined on PluginInputDiagnostic
    let diagnostic = anyToDiagnostic(input);
    if (typeof realOrigin === 'string') {
      diagnostic = Array.isArray(diagnostic)
        ? diagnostic.map(d => {
            return {...d, origin: realOrigin};
          })
        : {
            ...diagnostic,
            origin: realOrigin,
          };
    }

    this.#logEmitter.emit({
      type: 'log',
      level: 'error',
      diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic],
    });
github parcel-bundler / parcel / packages / core / core / src / Parcel.js View on Github external
]),
        ),
        bundleGraph: new BundleGraph(bundleGraph, options),
        buildTime: Date.now() - startTime,
      };
      this.#reporterRunner.report(event);

      await this.#assetGraphBuilder.validate();

      return event;
    } catch (e) {
      if (e instanceof BuildAbortError) {
        throw e;
      }

      let diagnostic = anyToDiagnostic(e);
      let event = {
        type: 'buildFailure',
        diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic],
      };

      await this.#reporterRunner.report(event);

      return event;
    } finally {
      if (options.profile) {
        await this.#farm.endProfile();
      }
    }
  }
github parcel-bundler / parcel / packages / core / workers / src / child.js View on Github external
const errorResponseFromError = (e: Error): WorkerErrorResponse => ({
      idx,
      child,
      type: 'response',
      contentType: 'error',
      content: anyToDiagnostic(e),
    });
github parcel-bundler / parcel / packages / core / workers / src / WorkerFarm.js View on Github external
const errorResponseFromError = (e: Error): WorkerErrorResponse => ({
      idx,
      type: 'response',
      contentType: 'error',
      content: anyToDiagnostic(e),
    });

@parcel/diagnostic

MIT
Latest version published 2 months ago

Package Health Score

89 / 100
Full package analysis

Similar packages