Skip to content

Commit

Permalink
Merge pull request #56 from jenius/0.13.0
Browse files Browse the repository at this point in the history
Source Map Support
  • Loading branch information
Jeff Escalante committed Dec 17, 2014
2 parents f834d1a + 720816c commit f061353
Show file tree
Hide file tree
Showing 49 changed files with 302 additions and 189 deletions.
4 changes: 4 additions & 0 deletions docs/coco.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Coco is a fork of CoffeeScript that tries to eliminate some pain points. It has
## Supported Methods
- render

## Source Maps

Coco does not support source maps, unfortunately. If they do add support we would be happy to add it to accord.

## Additional Options
### Bare
- key: `bare`
Expand Down
4 changes: 4 additions & 0 deletions docs/coffeescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ The CoffeeScript adapter API is almost exactly the same as the CoffeeScript JS A
## Supported Methods
- render

## Source Maps

Source maps are supported by the coffeescript adapter. Just pass in `sourceMap: true` as an option and you will get back both `sourcemap` and `v3sourcemap` (this is what coffeescript passes back by default), on the response object.

## Additional Options
### Bare
- key: `bare`
Expand Down
4 changes: 4 additions & 0 deletions docs/csso.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ CSSO is a great tool for optimizing CSS. It's public API is very simple, sometim
## Supported Methods
- render

## Source Maps

CSSO does not have support for source maps, unfortunately. There is an open issue for it [here](https://github.com/css/csso/issues/173). If they do add support we'd be happy to integrate it with accord.

## Additional Options
### No Restructure
- key: `no_restructure`
Expand Down
4 changes: 4 additions & 0 deletions docs/dogescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ dogescript.render('wow', { beauty: true, trueDoge: true })

## Supported Methods
- render

## Source Maps

Dogescript does not support sourcemaps. Honestly, I doubt it ever will. If you are writing dogescript, you probably don't need sourcemaps anyway because you are too boss for that kind of stuff.
4 changes: 4 additions & 0 deletions docs/handlebars.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ hbs.render("hello there {{ name }}", {
- compile
- compileClient
- clientHelpers

## Source Maps

Handlebars [does support source maps](https://github.com/wycats/handlebars.js/pull/902), but the functionality is brand new (at the time of writing), and is still undocumented. We will add this feature to accord once it's documented in handlebars if there's any demand for it.
4 changes: 4 additions & 0 deletions docs/jade.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ The jade adapter is used in just about the exact same as the jade public api, ma
- compile
- compileClient
- clientHelpers

## Source Maps

Jade does not support source maps and has no plans of doing so in the near future. See [this issue](https://github.com/jadejs/jade/issues/941) for discussion.
4 changes: 4 additions & 0 deletions docs/less.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ less.render('some less code', {

## Supported Methods
- render

## Source Maps

The less adapter does have support for sourcemaps. You can pass in `sourceMap: true` as an option and receive a map back on the response object as `sourcemap`.
4 changes: 4 additions & 0 deletions docs/livescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ LiveScript is a fork of Coco, which is a fork of CoffeeScript. More info on chan
## Supported Methods
- render

## Source Maps

Livescript does not yet have support for source maps. You can see an open issue for this feature [here](https://github.com/gkz/LiveScript/issues/452).

## Additional Options
Its compiler is unsurprisingly very similar to both CoffeeScript and Coco, and has only 2 unique options, explained below.

Expand Down
4 changes: 4 additions & 0 deletions docs/minify-css.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ CSS is minified with the fantastic [clean-css](https://github.com/GoalSmashers/c

## Supported Methods
- render

## Source Maps

Clean CSS does not yet have support for source maps, but it is [in the works](https://github.com/jakubpawlowicz/clean-css/issues/125) at the time of writing. We will re-examine if/when this feature is fully implemented.
4 changes: 4 additions & 0 deletions docs/minify-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ Uses [uglifyjs2](https://github.com/mishoo/UglifyJS2) to minify javascript code.

## Supported Methods
- render

## Source Maps

Although UglifyJS has sourcemap support, unfortunately it forces you to write them to a specific file rather than simply returning the map so you can do with it what you want. Since accord does not write files and simply executes transforms then returns the text, we do not support this in any special way. You can pass `sourceMap` as an option with the path to a file and presumably it will be written. This is not tested or officially supported and will not be until UglifyJS allows us to return the sourcemap as a string or object.
4 changes: 4 additions & 0 deletions docs/myth.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ Essentially a polyfill for the css future spec. Check the [features](https://git

## Supported Methods
- render

## Source Maps

Myth does support sourcemaps, but automatically inlines them. If call the adapter with `sourcemap: true` as an option, it will return a compiled result with an inline sourcemap.
4 changes: 4 additions & 0 deletions docs/scss.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This adapter uses [node-sass](https://github.com/andrew/node-sass), an incredibl
## Supported Methods
- render

## Source Maps

Libsass does not yet support source maps, although at the time of writing there is [an open pull request](https://github.com/sass/libsass/pull/591) to work on this.

## Additional Options
It has a pretty standard API, and uses the [options documented here](https://github.com/andrew/node-sass#options). Do not pass through `data` or `file`, as this will be overridden by accord's wrapper - everything else is fair game.

Expand Down
4 changes: 4 additions & 0 deletions docs/stylus.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ The Stylus compiler interface is one of the most abnormal and has gone through h
## Supported Methods
- render

## Source Maps

Source maps are supported by the stylus adapter. Just pass in a `sourcemap` option [as described in the docs](http://learnboost.github.io/stylus/docs/sourcemaps.html), and it will come back as `sourcemap` on the response object.

## Additional Options
### [Define](http://learnboost.github.io/stylus/docs/js.html#definename-node)

Expand Down
6 changes: 2 additions & 4 deletions lib/adapter_base.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ class Adapter
* @return {Promise}
###
render: (str, opts = {}) ->
if not @_render
return W.reject new Error('render not supported')
if not @_render then return W.reject new Error('render not supported')
@_render(str, opts)

###*
Expand All @@ -107,8 +106,7 @@ class Adapter
* @return {Promise}
###
compile: (str, opts = {}) ->
if not @_compile
return W.reject new Error('compile not supported')
if not @_compile then return W.reject new Error('compile not supported')
@_compile(str, opts)

###*
Expand Down
2 changes: 1 addition & 1 deletion lib/adapters/LiveScript.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ class LiveScript extends Adapter
compile = (fn) ->
try res = fn()
catch err then return W.reject(err)
W.resolve(res)
W.resolve(result: res)

module.exports = LiveScript
2 changes: 1 addition & 1 deletion lib/adapters/coco.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ class Coco extends Adapter
compile = (fn) ->
try res = fn()
catch err then return W.reject(err)
W.resolve(res)
W.resolve(result: res)

module.exports = Coco
5 changes: 4 additions & 1 deletion lib/adapters/coffee-script.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class CoffeeScript extends Adapter
compile = (fn) ->
try res = fn()
catch err then return W.reject(err)
W.resolve(res)
if res.sourceMap
W.resolve(result: res.js, sourcemap: res.sourceMap, v3sourcemap: res.v3SourceMap)
else
W.resolve(result: res)

module.exports = CoffeeScript
2 changes: 1 addition & 1 deletion lib/adapters/csso.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ class CSSO extends Adapter
compile = (fn) ->
try res = fn()
catch err then return W.reject(err)
W.resolve(res)
W.resolve(result: res)

module.exports = CSSO
2 changes: 1 addition & 1 deletion lib/adapters/dogescript.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class DogeScript extends Adapter
isolated: true

_render: (str, options) ->
W.resolve @engine(str, options.beauty, options.trueDoge)
W.resolve(result: @engine(str, options.beauty, options.trueDoge))

module.exports = DogeScript
2 changes: 1 addition & 1 deletion lib/adapters/ejs.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ class EJS extends Adapter
compile = (fn) ->
try res = fn()
catch err then return W.reject(err)
W.resolve(res)
W.resolve(result: res)

module.exports = EJS
2 changes: 1 addition & 1 deletion lib/adapters/haml.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ class HAML extends Adapter
compile = (fn) ->
try res = fn()
catch err then return W.reject(err)
W.resolve(res)
W.resolve(result: res)

module.exports = HAML
2 changes: 1 addition & 1 deletion lib/adapters/handlebars.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ class Handlebars extends Adapter
compile = (fn) ->
try res = fn()
catch err then return W.reject(err)
W.resolve(res)
W.resolve(result: res)

module.exports = Handlebars
2 changes: 1 addition & 1 deletion lib/adapters/jade.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ class Jade extends Adapter
compile = (fn) ->
try res = fn()
catch err then return W.reject(err)
W.resolve(res)
W.resolve(result: res)

module.exports = Jade
4 changes: 3 additions & 1 deletion lib/adapters/less.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class Less extends Adapter

@engine.render str, options, (err, res) ->
if err then return deferred.reject(err)
deferred.resolve(res.css)
obj = { result: res.css }
if options.sourceMap then obj.sourcemap = res.map
deferred.resolve(obj)

return deferred.promise

Expand Down
2 changes: 1 addition & 1 deletion lib/adapters/marc.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ class Marc extends Adapter

# all the remaining options are options for marked
base.config options
W.resolve base(str, true)
W.resolve(result: base(str, true))

module.exports = Marc
1 change: 1 addition & 0 deletions lib/adapters/markdown.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ class Markdown extends Adapter

_render: (str, options) ->
nodefn.call(@engine.bind(@engine), str, options)
.then (res) -> result: res

module.exports = Markdown
2 changes: 1 addition & 1 deletion lib/adapters/minify-css.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ class MinifyCSS extends Adapter
compile = (fn) ->
try res = fn()
catch err then return W.reject(err)
W.resolve(res)
W.resolve(result: res)

module.exports = MinifyCSS
2 changes: 1 addition & 1 deletion lib/adapters/minify-html.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ class MinifyHTML extends Adapter
compile = (fn) ->
try res = fn()
catch err then return W.reject(err)
W.resolve(res)
W.resolve(result: res)

module.exports = MinifyHTML
8 changes: 6 additions & 2 deletions lib/adapters/minify-js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ class MinifyJS extends Adapter
isolated: true

_render: (str, options) ->
compile => @engine.minify(str, _.extend(options, fromString: true)).code
compile =>
res = @engine.minify(str, _.extend(options, fromString: true))
obj = { result: res.code }
if options.sourceMap then obj.sourcemap = res.map
obj

# private

compile = (fn) ->
compile = (fn, map) ->
try res = fn()
catch err then return W.reject(err)
W.resolve(res)
Expand Down
4 changes: 2 additions & 2 deletions lib/adapters/mustache.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Mustache extends Adapter

_compileClient: (str, options) ->
options.asString = true
@_compile(str, options).then((o) -> "new Hogan.Template(#{o.toString()});")
@_compile(str, options).then((o) -> result: "new Hogan.Template(#{o.result.toString()});")

clientHelpers: ->
version = require(path.join(@engine.__accord_path, 'package')).version
Expand All @@ -33,6 +33,6 @@ class Mustache extends Adapter
compile = (fn) ->
try res = fn()
catch err then return W.reject(err)
W.resolve(res)
W.resolve(result: res)

module.exports = Mustache
6 changes: 4 additions & 2 deletions lib/adapters/myth.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ class Myth extends Adapter
output: 'css'

_render: (str, options) ->
compile => @engine(str)
options.source = options.filename
delete options.filename
compile => @engine(str, options)

# private

compile = (fn) ->
try res = fn()
catch err then return W.reject(err)
W.resolve(res)
W.resolve(result: res)

module.exports = Myth
4 changes: 2 additions & 2 deletions lib/adapters/scss.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class SCSS extends Adapter
deferred = W.defer()

options.data = str
options.success = deferred.resolve
options.error = deferred.reject
options.success = (res) -> deferred.resolve(result: res)
options.error = (res) -> deferred.reject(result: res)

@engine.render(options)

Expand Down
4 changes: 4 additions & 0 deletions lib/adapters/stylus.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,9 @@ class Stylus extends Adapter
base.use(i) for i in plugins

nodefn.call(base.render.bind(base))
.then (res) ->
obj = { result: res }
if base.sourcemap then obj.sourcemap = base.sourcemap
return obj

module.exports = Stylus
2 changes: 1 addition & 1 deletion lib/adapters/swig.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ class Swig extends Adapter
compile = (fn) ->
try res = fn()
catch err then return W.reject(err)
W.resolve(res)
W.resolve(result: res)

module.exports = Swig
2 changes: 1 addition & 1 deletion lib/adapters/toffee.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ class Toffee extends Adapter
compile = (fn) ->
try res = fn()
catch err then return W.reject(err)
W.resolve(res)
W.resolve(result: res)

module.exports = Toffee
Loading

0 comments on commit f061353

Please sign in to comment.