From fe3dc6aecf53715667de1189f0c019f7ee275caf Mon Sep 17 00:00:00 2001 From: boblauer Date: Tue, 15 Oct 2013 23:42:29 -0500 Subject: [PATCH 1/5] Updated browserify version Also added support for defining transforms and externals on BrowserifyAsset --- lib/modules/browserify.coffee | 22 +++++++++++++++------- package.json | 3 ++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/modules/browserify.coffee b/lib/modules/browserify.coffee index c8497e1..a254f0d 100644 --- a/lib/modules/browserify.coffee +++ b/lib/modules/browserify.coffee @@ -13,17 +13,25 @@ class exports.BrowserifyAsset extends Asset @require = options.require @debug = options.debug or false @compress = options.compress + @external = options.external + @transform = options.transform @compress ?= false @extensionHandlers = options.extensionHandlers or [] agent = browserify watch: false, debug: @debug for handler in @extensionHandlers agent.register(handler.ext, handler.handler) - agent.addEntry @filename + agent.require @filename agent.require @require if @require - if @compress is true - uncompressed = agent.bundle() - @contents = uglify.minify(uncompressed, {fromString: true}).code - @emit 'created' - else - @emit 'created', contents: agent.bundle() + agent.external ext for ext in @external if @external + agent.transform t for t in @transform if @transform + + agent.transform 'coffeeify' if /.coffee$/.test @filename + + agent.bundle (error, src) => + # return @emit 'error', error if error? + if @compress is true + @contents = uglify.minify(src, {fromString: true}).code + @emit 'created' + else + @emit 'created', contents: src diff --git a/package.json b/package.json index 72629eb..fd7deb3 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "author": "Brad Carleton ", "repository": "https://github.com/techpines/asset-rack", "dependencies": { - "browserify": "1.17.3", + "browserify": "~2.34.0", "snockets": "~1.3.8", "uglify-js": "~2.4.0", "async": "~0.2.9", @@ -17,6 +17,7 @@ "stylus": "~0.38.0", "underscore": "~1.5.2", "coffee-script": "~1.6.3", + "coffeeify": "~0.5.0", "markdown": "~0.5.0", "node-sassy": "~0.0.1" }, From e75f1701a9905a603aa29b8c9a1bf8365db09fc1 Mon Sep 17 00:00:00 2001 From: boblauer Date: Thu, 17 Oct 2013 09:01:09 -0500 Subject: [PATCH 2/5] Switched from bundle.require to bundle.add for entry point file --- lib/modules/browserify.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/modules/browserify.coffee b/lib/modules/browserify.coffee index a254f0d..fcbc5b7 100644 --- a/lib/modules/browserify.coffee +++ b/lib/modules/browserify.coffee @@ -20,7 +20,7 @@ class exports.BrowserifyAsset extends Asset agent = browserify watch: false, debug: @debug for handler in @extensionHandlers agent.register(handler.ext, handler.handler) - agent.require @filename + agent.add @filename agent.require @require if @require agent.external ext for ext in @external if @external From 8f4454a9612d3413ab8d710785fe68a7e2b30dfd Mon Sep 17 00:00:00 2001 From: boblauer Date: Thu, 17 Oct 2013 09:07:58 -0500 Subject: [PATCH 3/5] Uncommented error handling --- lib/modules/browserify.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/modules/browserify.coffee b/lib/modules/browserify.coffee index fcbc5b7..98ffcd6 100644 --- a/lib/modules/browserify.coffee +++ b/lib/modules/browserify.coffee @@ -29,7 +29,7 @@ class exports.BrowserifyAsset extends Asset agent.transform 'coffeeify' if /.coffee$/.test @filename agent.bundle (error, src) => - # return @emit 'error', error if error? + return @emit 'error', error if error? if @compress is true @contents = uglify.minify(src, {fromString: true}).code @emit 'created' From ff08677a839ba199693de5cb43f097f09132d8b8 Mon Sep 17 00:00:00 2001 From: boblauer Date: Thu, 17 Oct 2013 09:21:39 -0500 Subject: [PATCH 4/5] A more flexible way to define requires --- lib/modules/browserify.coffee | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/modules/browserify.coffee b/lib/modules/browserify.coffee index 98ffcd6..71ba030 100644 --- a/lib/modules/browserify.coffee +++ b/lib/modules/browserify.coffee @@ -21,7 +21,13 @@ class exports.BrowserifyAsset extends Asset for handler in @extensionHandlers agent.register(handler.ext, handler.handler) agent.add @filename - agent.require @require if @require + + if @require + for r in @require + if r.file + agent.require r.file, r.options + else + agent.require r agent.external ext for ext in @external if @external agent.transform t for t in @transform if @transform From 62383ce8dcca45b9a4c0c33cf98643804f24b257 Mon Sep 17 00:00:00 2001 From: boblauer Date: Wed, 6 Nov 2013 21:03:39 -0600 Subject: [PATCH 5/5] Browserify filename optional --- lib/modules/browserify.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/modules/browserify.coffee b/lib/modules/browserify.coffee index 71ba030..51bfe99 100644 --- a/lib/modules/browserify.coffee +++ b/lib/modules/browserify.coffee @@ -20,7 +20,7 @@ class exports.BrowserifyAsset extends Asset agent = browserify watch: false, debug: @debug for handler in @extensionHandlers agent.register(handler.ext, handler.handler) - agent.add @filename + agent.add @filename if @filename if @require for r in @require