Movatterモバイル変換


[0]ホーム

URL:


Parcel

CoffeeScript

CoffeeScript is a language that transpiles to JavaScript, which allows you to use a shorter syntax and other features likethe 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 theJavaScript docs.

Example usage

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

URL dependencies

#

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

CoffeeScript does not currently supportimport.meta. Instead, you can use the CommonJS__filename variable with thefile: prefix to convert it to a URL. For example, here's how you could create a worker in CoffeeScript:

newWorkernewURL('worker.js','file:'+ __filename),
type:'module'

The same goes for other types of dependencies like images:

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

On this page


[8]ページ先頭

©2009-2025 Movatter.jp