esbuild-coffeescript

Bundle CoffeeScript with Esbuild


Keywords
esbuild, esbuild-coffeescript, esbuild-plugin, coffeescript, litcoffee
License
MIT
Install
npm install esbuild-coffeescript@1.0.0

Documentation

esbuild-coffeescript

esbuild-coffeescript

This plugin lets you import CoffeeScript files when bundling with Esbuild

Installation

$ npm install --save-dev esbuild-coffeescript

Getting Started

main.coffee

answer = 42
console.log("the answer is #{answer}")

build.js

const coffeeScriptPlugin = require('esbuild-coffeescript');

require('esbuild').build({
  entryPoints: ['main.coffee'],
  bundle: true,
  outfile: 'out.js',
  plugins: [coffeeScriptPlugin()],
});

Configuration

An object containing configuration options may be passed into the plugin constructor coffeeScriptPlugin

coffeeScriptPlugin({
  bare: true,
});

The following options are available:

  • options.inlineMap, boolean: if true, output the source map as a base64-encoded string in a comment at the bottom.
  • options.filename, string: the filename to use for the source map. It can include a path (relative or absolute).
  • options.bare, boolean: if true, output without the top-level function safety wrapper.
  • options.header, boolean: if true, output the Generated by CoffeeScript header.
  • options.transpile, object: if set, this must be an object with the options to pass to Babel. See Transpilation.
  • options.ast, boolean: if true, return an abstract syntax tree of the input CoffeeScript source code.

But CoffeeScript is dead?

Yes and no. Even if the last stable release of CoffeeScript were on January 2020, it still has over a million weekly downloads from NPM. CoffeeScript is also great for quick ideations and experiments.