Skip to content

Commit

Permalink
add browserify support and build target
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelficarra committed Nov 4, 2012
1 parent ed3202f commit dfe5782
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 19 deletions.
27 changes: 14 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,50 @@ ROOT = $(shell pwd)
COFFEE = bin/coffee --js --bare
PEGJS = node_modules/.bin/pegjs --track-line-and-column --cache
MOCHA = node_modules/.bin/mocha --compilers coffee:. -u tdd
MINIFIER = node_modules/.bin/uglifyjs --no-copyright --mangle-toplevel --reserved-names require,module,exports,global,window
BROWSERIFY = node_modules/.bin/browserify
MINIFIER = node_modules/.bin/uglifyjs --no-copyright --mangle-toplevel --reserved-names require,module,exports,global,window,CoffeeScript

all: $(LIB)
build: all
parser: lib/coffee-script/parser.js
browserify: CoffeeScriptRedux.js
minify: $(LIBMIN)
# TODO: build-browser
# TODO: test-browser
# TODO: doc
# TODO: bench


lib:
mkdir lib/

lib/coffee-script: lib
mkdir -p lib/coffee-script/

lib/coffee-script/bootstrap: lib/coffee-script
mkdir -p lib/coffee-script/bootstrap


lib/coffee-script/parser.js: src/grammar.pegjs bootstraps lib/coffee-script
printf %s "module.exports = " >"$(@:%=%.tmp)"
$(PEGJS) <"$<" >>"$(@:%=%.tmp)"
mv "$(@:%=%.tmp)" "$@"
$(PEGJS) <"$<" >>"$(@:%=%.tmp)" && mv "$(@:%=%.tmp)" "$@"
lib/coffee-script/bootstrap/parser.js: src/grammar.pegjs lib/coffee-script/bootstrap
printf %s "module.exports = " >"$@"
$(PEGJS) <"$<" >>"$@"

lib/coffee-script/%.min.js: lib/coffee-script/%.js lib/coffee-script
$(MINIFIER) <"$<" >"$@"

lib/coffee-script/bootstrap/%.js: src/%.coffee lib/coffee-script/bootstrap
$(COFFEE) <"$<" >"$@"

bootstraps: $(BOOTSTRAPS) lib/coffee-script/bootstrap
mv lib/coffee-script/bootstrap/* lib/coffee-script
rmdir lib/coffee-script/bootstrap


lib/coffee-script/%.js: src/%.coffee lib/coffee-script/bootstrap/%.js bootstraps lib/coffee-script
$(COFFEE) <"$<" >"$(@:%=%.tmp)" && mv "$(@:%=%.tmp)" "$@"


CoffeeScriptRedux.js: $(LIB)
$(BROWSERIFY) lib/coffee-script/module.js | $(MINIFIER) > CoffeeScriptRedux.js


lib/coffee-script/%.min.js: lib/coffee-script/%.js lib/coffee-script
$(MINIFIER) <"$<" >"$@"


.PHONY: test coverage install loc clean

test: $(LIB) $(TESTS)
Expand Down
2 changes: 1 addition & 1 deletion lib/coffee-script/command.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/coffee-script/compiler.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/coffee-script/module.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/command.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ if options.help
"""

else if options.version
pkg = require path.join __dirname, '..', '..', 'package.json'
pkg = require './../../package.json'
console.log "CoffeeScript version #{pkg.version}"

else if options.repl
Expand Down
2 changes: 1 addition & 1 deletion src/compiler.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ class exports.Compiler
# add a function wrapper
block = [stmt new JS.UnaryExpression 'void', new JS.CallExpression (memberAccess (new JS.FunctionExpression null, [], new JS.BlockStatement block), 'call'), [new JS.ThisExpression]]
# generate node
pkg = require (require 'path').join __dirname, '..', '..', 'package.json'
pkg = require './../../package.json'
program = new JS.Program block
program.leadingComments = [
type: 'Line'
Expand Down
2 changes: 1 addition & 1 deletion src/module.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ uglifyjs = try require 'uglify-js'


CoffeeScript = null
pkg = require path.join __dirname, '..', '..', 'package.json'
pkg = require './../../package.json'

escodegenFormatDefaults =
indent:
Expand Down

0 comments on commit dfe5782

Please sign in to comment.