mirror of https://github.com/lukechilds/rollup.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.4 KiB
40 lines
1.4 KiB
10 years ago
|
var path = require( 'path' );
|
||
|
var assert = require( 'assert' );
|
||
|
var getLocation = require( '../../utils/getLocation' );
|
||
|
var SourceMapConsumer = require( 'source-map' ).SourceMapConsumer;
|
||
|
|
||
|
module.exports = {
|
||
|
description: 'basic sourcemap support',
|
||
|
test: function ( code, map ) {
|
||
|
assert.equal( map.version, 3 );
|
||
|
assert.equal( map.file, 'bundle.js' );
|
||
|
|
||
|
var smc = new SourceMapConsumer( map );
|
||
|
var generatedLoc, originalLoc;
|
||
|
|
||
|
// main.js
|
||
|
generatedLoc = getLocation( code, code.indexOf( "console.log( 'hello from main.js' )" ) );
|
||
|
originalLoc = smc.originalPositionFor( generatedLoc );
|
||
|
|
||
|
assert.equal( originalLoc.line, 4 );
|
||
|
assert.equal( originalLoc.column, 0 );
|
||
|
assert.equal( path.resolve( originalLoc.source ), path.resolve( __dirname, 'main.js' ) );
|
||
|
|
||
|
// foo.js
|
||
|
generatedLoc = getLocation( code, code.indexOf( "console.log( 'hello from foo.js' )" ) );
|
||
|
originalLoc = smc.originalPositionFor( generatedLoc );
|
||
|
|
||
|
assert.equal( originalLoc.line, 2 );
|
||
|
assert.equal( originalLoc.column, 1 );
|
||
|
assert.equal( path.resolve( originalLoc.source ), path.resolve( __dirname, 'foo.js' ) );
|
||
|
|
||
|
// bar.js
|
||
|
generatedLoc = getLocation( code, code.indexOf( "console.log( 'hello from bar.js' )" ) );
|
||
|
originalLoc = smc.originalPositionFor( generatedLoc );
|
||
|
|
||
|
assert.equal( originalLoc.line, 2 );
|
||
|
assert.equal( originalLoc.column, 1 );
|
||
|
assert.equal( path.resolve( originalLoc.source ), path.resolve( __dirname, 'bar.js' ) );
|
||
|
}
|
||
|
};
|