@syndicate-lang/esbuild-plugin v0.1.1
esbuild plugin for Syndicate/JS
import esbuild from 'esbuild';
import { syndicatePlugin } from '@syndicate-lang/esbuild-plugin';
...
esbuild.build({
...
plugins: [..., syndicatePlugin(), ...],
...
});
...The syndicatePlugin function takes an optional options object. It may include properties:
module, optional, drawn from"es6"(the default),"require","global", or"none": controls how to get hold of an instance of the@syndicate-lang/coremodule. Ifes6, usesimport; ifrequire, usesrequire; ifglobal, uses a global variable (useful for browser contexts); ifnone, does no imports, so some other provision will have to be made to ensure__SYNDICATE__is bound to a module instance for the output code.runtime, optionalstring: defaults to"@syndicate-lang/core". Formoduleofes6orrequire, names the module to import/require, respectively; formoduleofglobal, an expression to yield a module instance.For example, in a browser, using a CDN to retrieve a
dist/syndicate.jsscript from the@syndicate-lang/corepackage produces aSyndicateglobal variable, so you could setmoduletoglobalandruntimetoSyndicateorwindow.Syndicateetc.include,exclude: both optional arrays of strings. By default,includeis["**/*.{js,ts}"]andexcludeis["node_modules/**"]. Each time esbuild considers a module path, the Syndicate plugin first checks to see if it matches some glob ininclude(using outmatch). If not, the plugin delegates to esbuild's default handler. Otherwise, it checks to see if it matches some glob inexclude. If so, again it delegates to esbuild. Otherwise, it runs the Syndicate compiler on the module source code and hands that off to esbuild.