mirror of https://github.com/lukechilds/rollup.git
Rich Harris
9 years ago
5 changed files with 68 additions and 2 deletions
@ -0,0 +1,37 @@ |
|||||
|
var fs = require( 'fs' ); |
||||
|
var path = require( 'path' ); |
||||
|
var assert = require( 'assert' ); |
||||
|
var getLocation = require( '../../utils/getLocation' ); |
||||
|
var SourceMapConsumer = require( 'source-map' ).SourceMapConsumer; |
||||
|
|
||||
|
var original = fs.readFileSync( path.resolve( __dirname, 'main.js' ), 'utf-8' ); |
||||
|
|
||||
|
module.exports = { |
||||
|
description: 'handles single-length sourcemap segments', |
||||
|
options: { |
||||
|
plugins: [ |
||||
|
{ |
||||
|
transform: function () { |
||||
|
return { |
||||
|
code: fs.readFileSync( path.resolve( __dirname, 'output.js' ), 'utf-8' ), |
||||
|
map: fs.readFileSync( path.resolve( __dirname, 'output.js.map' ), 'utf-8' ) |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
], |
||||
|
moduleName: 'x' |
||||
|
}, |
||||
|
test: function ( code, map ) { |
||||
|
var smc = new SourceMapConsumer( map ); |
||||
|
|
||||
|
[ 'Foo', 'log' ].forEach( function ( token ) { |
||||
|
var generatedLoc = getLocation( code, code.indexOf( token ) ); |
||||
|
var originalLoc = smc.originalPositionFor( generatedLoc ); |
||||
|
var expectedLoc = getLocation( original, original.indexOf( token ) ); |
||||
|
|
||||
|
assert.ok( /main/.test( originalLoc.source ) ); |
||||
|
assert.equal( originalLoc.line, expectedLoc.line ); |
||||
|
assert.equal( originalLoc.column, expectedLoc.column ); |
||||
|
}); |
||||
|
} |
||||
|
}; |
@ -0,0 +1,7 @@ |
|||||
|
class Foo { |
||||
|
bar () { |
||||
|
console.log( 42 ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export { Foo }; |
@ -0,0 +1,15 @@ |
|||||
|
var Foo = function () { |
||||
|
function Foo() { |
||||
|
babelHelpers.classCallCheck(this, Foo); |
||||
|
} |
||||
|
|
||||
|
babelHelpers.createClass(Foo, [{ |
||||
|
key: "bar", |
||||
|
value: function bar() { |
||||
|
console.log(42); |
||||
|
} |
||||
|
}]); |
||||
|
return Foo; |
||||
|
}(); |
||||
|
|
||||
|
export { Foo }; |
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"version":3, |
||||
|
"sources":["index.js"], |
||||
|
"names":[], |
||||
|
"mappings":"IAAM,G;;;;;;;wBACE;AACN,WAAQ,GAAR,CAAa,EAAb;AACA;;;;;AAGF,SAAS,GAAT", |
||||
|
"file":"index.js", |
||||
|
"sourcesContent":["class Foo {\n\tbar () {\n\t\tconsole.log( 42 );\n\t}\n}\n\nexport { Foo };\n"] |
||||
|
} |
Loading…
Reference in new issue