CoffeeScript

CoffeeScript is a language that transpiles to JavaScript, which allows you to use a shorter syntax and other features like the existential operator, shorter array-splicing syntax, block regular expressions and more.

Parcel supports CoffeeScript automatically using the @parcel/transformer-coffeescript plugin. When a .coffee file is detected, it will be installed into your project automatically.

CoffeeScript is compiled to JavaScript and processed as described in the JavaScript docs.

Example usage

#
index.html:
<script type="module" src="app.coffee"></script>
app.coffee:
console.log 'Hello world!'

URL dependencies

#

In JavaScript files, URL dependencies can be created using the URL constructor combined with import.meta.url. This can be used to reference URLs such as images, workers, service workers, and more.

CoffeeScript does not currently support import.meta. Instead, you can use the CommonJS __filename variable with the file: prefix to convert it to a URL. For example, here's how you could create a worker in CoffeeScript:

new Worker new URL('worker.js', 'file:' + __filename),
type: 'module'

The same goes for other types of dependencies like images:

img = document.createElement 'img'
img.src = new URL 'hero.jpg', 'file:' + __filename
document.body.appendChild img