# coffee-inline-map

> Compile CoffeeScript files with inline source maps

Latest version **0.9.0** (published 2015-11-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install coffee-inline-map
pnpm add coffee-inline-map
yarn add coffee-inline-map
bun add coffee-inline-map
```

Provides the command `coffee-inline-map`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.9.0 |
| Published | 2015-11-18 |
| First published | 2013-04-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.10.0 |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Alexander Gromnitsky |
| Maintainers | gromnitsky |
| Keywords | build, coffeescript, source map |

## Links

- npm: https://www.npmjs.com/package/coffee-inline-map
- Repository: https://github.com/gromnitsky/coffee-inline-map
- Issues: https://github.com/gromnitsky/coffee-inline-map/issues
- npm.io page: https://npm.io/package/coffee-inline-map

## Dependencies (3)

- [optparse](https://npm.io/package/optparse.md) ~1.0.5
- [coffee-script](https://npm.io/package/coffee-script.md) ~1.10.0
- [convert-source-map](https://npm.io/package/convert-source-map.md) ~1.1.2

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.9.0 (latest) — 2015-11-18
- 0.8.0 — 2015-06-07
- 0.7.0 — 2015-02-20
- 0.6.0 — 2015-01-30
- 0.5.0 — 2014-09-27
- 0.4.0 — 2014-04-27
- 0.3.0 — 2013-06-08
- 0.2.0 — 2013-06-07
- 0.1.0 — 2013-04-21
- 0.0.1 — 2013-04-18

## README

# coffee-inline-map

Compile CoffeeScript files with inline source maps.

## Features

* Error reporting similar to the original CoffeeScript compiler.
* `.litcoffee` support.

## Example

```
$ cat a.coffee
module.exports = (something) -> console.log something

$ coffee-inline-map a.coffee | fold -w72
// Generated by CoffeeScript 1.10.0
(function() {
  module.exports = function(something) {
    return console.log(something);
  };

}).call(this);

//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaW
xlIjoiYS5jb2ZmZWUiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJhLmNvZmZlZSJdLC
JuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7RUFBQSxNQUFNLENBQUMsT0FBUCxHQUFpQi
xTQUFDLFNBQUQ7V0FBZSxPQUFPLENBQUMsR0FBUixDQUFZLFNBQVo7RUFBZjtBQUFqQiIsIn
NvdXJjZXNDb250ZW50IjpbIm1vZHVsZS5leHBvcnRzID0gKHNvbWV0aGluZykgLT4gY29uc2
9sZS5sb2cgc29tZXRoaW5nXG4iXX0=

$ coffee-inline-map -h
Usage: coffee-inline-map [options] [file.coffee]

Available options:
  -h, --help            output usage information & exit
  -V, --version         output the version number & exit
  -o, --output [FILE]   write result to a FILE instead of stdout
  -l, --literate        treat stdin as literate style coffee-script
  -b, --bare            compile without a top-level function wrapper
      --no-map          don't include inline source map (why?)

```

## Installation

	# npm install -g coffee-inline-map

## Compilation

	$ make compile

## browserify & make-commonjs-depend

To verify the text below you'll need to clone this repo, run 'make
compile' & install
[make-commonjs-depend](https://github.com/gromnitsky/make-commonjs-depend).

Look into repo's `test/data` directory. Ignore `*.should` files. I'll wait.

Then

```
$ cd src
$ ls *coffee
a.coffee
b.litcoffee
main.coffee

```

Here `main.coffee` depends on `a.coffee` & `b.litcoffee`. For out site
we need just 1 `public/bundle.js` file which will include the result form the
compilations of our all CoffeeScript files.

We want to rebuild `public/bundle.js` only & only on .coffee files
change. That's obviously a job for make.

```
$ cat Makefile
COFFEE_COMPILER := ../../../bin/coffee-inline-map
BROWSERIFY := ../../../node_modules/.bin/browserify

out := ../public
js_temp := \
	$(patsubst %.coffee,%.js,$(wildcard *.coffee)) \
	$(patsubst %.litcoffee,%.js,$(wildcard *.litcoffee))
bundle := $(out)/bundle.js

.PHONY: depend compile compile-js clean

all: compile

%.js: %.coffee
	$(COFFEE_COMPILER) $< -o $@

%.js: %.litcoffee
	$(COFFEE_COMPILER) $< -o $@

depend: compile-js
	make-commonjs-depend *js -o js.mk

-include js.mk

compile-js: $(js_temp)
compile: compile-js $(bundle)

$(bundle): main.js
	@mkdir -p $(out)
	$(BROWSERIFY) -d $< -o $@

clean:
	rm -f js.mk $(js_temp) $(bundle)

```

To create a dependency tree, we run

```
$ make depend
../../../bin/coffee-inline-map a.coffee -o a.js
../../../bin/coffee-inline-map main.coffee -o main.js
../../../bin/coffee-inline-map b.litcoffee -o b.js
make-commonjs-depend *js -o js.mk

```

```
$ cat js.mk
a.js:
b.js:
main.js: \
  a.js \
  b.js

```

It's unfortunate that make-commonjs-depend supports only
javascript. That's why before running it, make needs to compile all
coffescript files.

Then compile the bundle

```
$ make compile
../../../bin/coffee-inline-map main.coffee -o main.js
../../../node_modules/.bin/browserify -d main.js -o ../public/bundle.js

```

As a little homework, try to guess why `main.js` was recompiled here,
when at first glance it should rather not.

Run again

```
$ make compile
make[1]: Nothing to be done for 'compile'.

```

Notice that the nothing was recompiled for the 2nd time. That's our goal!

```
$ touch a.coffee
$ make compile
../../../bin/coffee-inline-map a.coffee -o a.js
../../../bin/coffee-inline-map main.coffee -o main.js
../../../node_modules/.bin/browserify -d main.js -o ../public/bundle.js

```

Yay! Then open `public/index.html` in Chrome and switch to the console
view. (Make sure to turn on 'Enable source maps' in Developer Tool's
settings.)

## Jeez mate, why are you doing this rigmarole?

Every dependency & every file should be compiled/processed only once.

This seems meaningless for a bunch of small .coffee files but becomes
very useful for large projects with several complex browserify output
targets.

## Why not just use coffeeify plugin for browserify?

1. browserify can't (& shouldn't) check changes in our source files to
   decide whether it's time to recompile.
2. Error reporting.

## Why are you using outdated make instead of cake, jake, grunt, gulp or broccoli? It's not 1977 anymore!

facepalm.jpg

Dude. <br/>
Take a walk for 10 minutes & no one will get hurt.

## BUGS

* Reading from stdin doesn't work in Windows.

## NEWS

### 0.9.0

* CoffeeScript 1.10.0.

### ...

### 0.5.0

* CoffeeScript 1.8.0.

### 0.4.0

* CoffeeScript 1.7.1
* 'New' source map syntax.

### 0.3.0

* `-b` CLO.
* Include 'generated by ...' header.

### 0.2.0

* Update for CoffeeScript 1.6.3.
* Recognize `.coffee.md` extension.
* `-l` CLO.

### 0.1.0

* Add reading from stdin.
* Fix an unheplful crash for EPIPE error.

## License

MIT.

---
_Source: https://npm.io/package/coffee-inline-map · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
