@syndicate-lang/esbuild-plugin
v0.1.0
Published
Syndicate/JS JavaScript and TypeScript esbuild plugin
Downloads
5
Readme
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/core
module. 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"
. Formodule
ofes6
orrequire
, names the module to import/require, respectively; formodule
ofglobal
, an expression to yield a module instance.For example, in a browser, using a CDN to retrieve a
dist/syndicate.js
script from the@syndicate-lang/core
package produces aSyndicate
global variable, so you could setmodule
toglobal
andruntime
toSyndicate
orwindow.Syndicate
etc.include
,exclude
: both optional arrays of strings. By default,include
is["**/*.{js,ts}"]
andexclude
is["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.