Warning CommonJS require not working. Cannot access local files
CoffeeScript is a language that compiles into JavaScript. It adds syntactic sugar inspired by Ruby, Python, and Haskell in an effort to enhance JavaScript's brevity and readability. While also being almost as good as TypeScript.
No bracket jungle. No semicolons. No commas. No parentheses. No colons. No curly braces. No strings. No prototypes. No new keywords. No functions. No fat arrows. No var. No this. No that. No underbars. No confusion. No bullshit. (Copilot volt nem én)
# CoffeeScript
square = (x) -> x * x
// JavaScript
var square = function(x) {
return x * x;
};
Install Node packages:
npm i
CoffeeScript is required to use coffee commands.
npm install -g coffeescript
Ctrl+Shift+B to start watching for changes. The compiled javascript will be in the dist folder.
Use with the Live Server extension
.
├── .vscode
│ └── tasks.json
├── dist
│ ├── modules
│ │ └── module.js
│ └── main.js
├── src
│ ├── modules
│ │ └── module.coffee
│ └── main.coffee
├── .babelrc
├── jsconfig.json
├── rollup.config.js
- This file is used by VSCode to run tasks. In this case, it is used to run the
watchscript inpackage.json.
- This folder contains the compiled javascript files.
- Only the
main.jsfile is used in theindex.htmlfile.
- This folder contains the coffeescript files.
Warning when importing a module, add
.jsto the end of the path. NOT.coffee.
- This file is used by Babel to compile the javascript files.
- It sets
modulestofalseso that ES modules are preserved (theimportstatements are not compiled torequirestatements).
- Enable type checking for javascript (and coffeescript) files.
- Use rollup-plugin-coffee-script to integrate coffeescript with rollup.
