Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to work with the latest version of Browserify #101

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lib/modules/browserify.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ class exports.BrowserifyAsset extends Asset
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.bundle (err, src) =>
if @compress is true
@contents = uglify.minify(src, {fromString: true}).code
@emit 'created'
else
@emit 'created', contents: src
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Brad Carleton <[email protected]>",
"repository": "https://github.com/techpines/asset-rack",
"dependencies": {
"browserify": "1.17.3",
"browserify": "2.34.1",
"snockets": "~1.3.8",
"uglify-js": "~2.4.0",
"async": "~0.2.9",
Expand Down
12 changes: 5 additions & 7 deletions test/browserify.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ describe 'a browserify asset', ->
fixturesDir = "#{__dirname}/fixtures/browserify"

it 'should work', (done) ->
compiled = fs.readFileSync "#{fixturesDir}/app.js", 'utf8'
app = express().http()
app.use new rack.BrowserifyAsset {
filename: "#{fixturesDir}/app.coffee"
filename: "#{fixturesDir}/app.js"
url: '/app.js'
}
app.listen 7076, ->
Expand All @@ -22,10 +21,9 @@ describe 'a browserify asset', ->
done()

it 'should work compressed', (done) ->
compiled = fs.readFileSync "#{fixturesDir}/app.min.js", 'utf8'
app = express().http()
app.use asset = new rack.BrowserifyAsset
filename: "#{fixturesDir}/app.coffee"
filename: "#{fixturesDir}/app.js"
url: '/app.js'
compress: true
app.listen 7076, ->
Expand All @@ -35,10 +33,10 @@ describe 'a browserify asset', ->

#it 'should work with extension handlers', (done) ->
# done()

#it 'should work with debug option', (done) ->
# done()


afterEach (done) -> process.nextTick ->
app.server.close done
2 changes: 1 addition & 1 deletion test/dynamic.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ describe 'a dynamic asset builder', ->
app.use new rack.DynamicAssets
type: rack.BrowserifyAsset
dirname: join fixturesDir, 'browserify'
filter: 'coffee'
filter: 'js'
app.listen 7076, ->
easyrequest 'http://localhost:7076/app.js', (error, response, body) ->
response.headers['content-type'].should.equal 'text/javascript'
Expand Down
5 changes: 0 additions & 5 deletions test/fixtures/browserify/app.coffee

This file was deleted.

Loading