[ https://issues.apache.org/jira/browse/COUCHDB-1875?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Anthony Kaufman updated COUCHDB-1875: ------------------------------------- Description: Reusable CommonJS functions written in CoffeeScript raise exceptions when referenced from map functions. Consider the following Javascript code: {code:js} { lib: { simple: "exports.callback = function() { return 'Simple' }" }, test: { map: "function(doc) { emit(require('views/lib/simple').callback(), doc) }" } } {code} As expected, "Simple" is emitted for the key of every document. Now the equivalent CoffeeScript code: {code:coffee} { lib: { simple: "exports.callback = () -> 'Simple'" }, test: { map: "(doc) -> emit(require('views/lib/simple').callback(), doc)" } } {code} The view returns no results and an error for every document is printed to the log file. For example: [info] [<0.7270.11>] OS Process #Port<0.96999> Log :: function raised exception (new TypeError("require(\"views/lib/simple\").callback is not a function", "undefined", 3)) with doc._id 8117 was: Reusable CommonJS functions written in CoffeeScript raise exceptions when referenced from map functions. Consider the following Javascript code: {code:title=design.js|borderStyle=solid} { lib: { simple: "exports.callback = function() { return 'Simple' }" }, test: { map: "function(doc) { emit(require('views/lib/simple').callback(), doc) }" } } {code} As expected, "Simple" is emitted for the key of every document. Now the equivalent CoffeeScript code: {code:title=design.coffee|borderStyle=solid} { lib: { simple: "exports.callback = () -> 'Simple'" }, test: { map: "(doc) -> emit(require('views/lib/simple').callback(), doc)" } } {code} The view returns no results and an error for every document is printed to the log file. For example: [info] [<0.7270.11>] OS Process #Port<0.96999> Log :: function raised exception (new TypeError("require(\"views/lib/simple\").callback is not a function", "undefined", 3)) with doc._id 8117 > CoffeeScript CommonJS Functions Don't Work > ------------------------------------------ > > Key: COUCHDB-1875 > URL: https://issues.apache.org/jira/browse/COUCHDB-1875 > Project: CouchDB > Issue Type: Bug > Components: JavaScript View Server > Reporter: Anthony Kaufman > > Reusable CommonJS functions written in CoffeeScript raise exceptions when > referenced from map functions. > Consider the following Javascript code: > {code:js} > { > lib: { > simple: "exports.callback = function() { return 'Simple' }" > }, > test: { > map: "function(doc) { emit(require('views/lib/simple').callback(), doc) }" > } > } > {code} > As expected, "Simple" is emitted for the key of every document. > Now the equivalent CoffeeScript code: > {code:coffee} > { > lib: { > simple: "exports.callback = () -> 'Simple'" > }, > test: { > map: "(doc) -> emit(require('views/lib/simple').callback(), doc)" > } > } > {code} > The view returns no results and an error for every document is printed to the > log file. For example: > [info] [<0.7270.11>] OS Process #Port<0.96999> Log :: function raised > exception (new TypeError("require(\"views/lib/simple\").callback is not a > function", "undefined", 3)) with doc._id 8117 -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira