@@ -6,6 +6,13 @@ var hash = require('hash-sum')
66var deindent = require ( 'de-indent' )
77var splitRE = / \r ? \n / g
88var emptyRE = / ^ \s * $ /
9+ var commentSymbols = {
10+ 'coffee' : '#' ,
11+ 'coffee-jsx' : '#' ,
12+ 'coffee-redux' : '#' ,
13+ 'purs' : '--' ,
14+ 'ulmus' : '--'
15+ }
916
1017module . exports = function ( content , filename , needMap ) {
1118
@@ -110,7 +117,8 @@ module.exports = function (content, filename, needMap) {
110117 // do not add mappings for comment lines - babel's source map
111118 // somehow gets messed up because of it
112119 var isCommentLine = function ( line ) {
113- return type === 'script' && ! lang && line . indexOf ( '//' ) === 0
120+ return type === 'script' &&
121+ line . indexOf ( getCommentSymbol ( lang ) ) === 0
114122 }
115123
116124 result . split ( splitRE ) . forEach ( function ( line , index ) {
@@ -151,25 +159,19 @@ module.exports = function (content, filename, needMap) {
151159}
152160
153161function commentScript ( content , lang ) {
162+ var symbol = getCommentSymbol ( lang )
154163 return content
155164 . split ( splitRE )
156165 . map ( function ( line ) {
157- line = emptyRE . test ( line ) ? '' : ' ' + line
158- switch ( lang ) {
159- case 'coffee' :
160- case 'coffee-jsx' :
161- case 'coffee-redux' :
162- return '#' + line
163- case 'purs' :
164- case 'ulmus' :
165- return '--' + line
166- default :
167- return '//' + line
168- }
166+ return symbol + ( emptyRE . test ( line ) ? '' : ' ' + line )
169167 } )
170168 . join ( '\n' )
171169}
172170
171+ function getCommentSymbol ( lang ) {
172+ return commentSymbols [ lang ] || '//'
173+ }
174+
173175function getAttribute ( node , name ) {
174176 if ( node . attrs ) {
175177 var i = node . attrs . length
0 commit comments