1.0.5 • Published 3 months ago

@jgoz/esbuild-overlay v1.0.5

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

@jgoz/esbuild-overlay

A dismissable error overlay for reporting esbuild errors to a web browser.

Features

  • Supports esbuild's message format
  • Dismissable

Install

This package isn't really intended to be used on its own because it's bundled with @jgoz/esbuild-plugin-livereload and will be used without any configuration.

$ npm i @jgoz/esbuild-overlay

Usage with an EventSource

async function init() {
  const { overlay } = await import('@jgoz/esbuild-overlay');

  const evt = new EventSource('/my-event-source');
  let removeOverlay;

  evt.addEventListener('build-result', e => {
    const result = JSON.parse(e?.data ?? '{}');
    if (removeOverlay && !result.errors.length) {
      removeOverlay();
      removeOverlay = undefined;
    }
    if (result.errors?.length) {
      removeOverlay = overlay({ errors: result.errors });
    }
  });
}

API

function overlay(props: OverlayProps): () => void

Displays an overlay with the supplied error messages and returns a function that removes the overlay.

NameTypeDefaultDescription
errors (*)Message[]-Error messages to display.
openFileURLstring-If provided, this URL will be opened when the user clicks on the overlay.This can be used to open the source file of the error or warning.
1.0.5

3 months ago

1.0.4

10 months ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

2 years ago

1.0.0

2 years ago