mirror of https://github.com/lukechilds/rollup.git
Rich Harris
8 years ago
10 changed files with 99 additions and 84 deletions
@ -0,0 +1,29 @@ |
|||||
|
const path = require( 'path' ); |
||||
|
|
||||
|
module.exports = { |
||||
|
description: 'plugin transform hooks can use `this.error({...}, char)` (#1140)', |
||||
|
options: { |
||||
|
plugins: [{ |
||||
|
name: 'test', |
||||
|
transform ( code, id ) { |
||||
|
this.error( 'nope', 22 ); |
||||
|
} |
||||
|
}] |
||||
|
}, |
||||
|
error: { |
||||
|
code: 'PLUGIN_ERROR', |
||||
|
plugin: 'test', |
||||
|
message: 'nope', |
||||
|
id: path.resolve( __dirname, 'main.js' ), |
||||
|
pos: 22, |
||||
|
loc: { |
||||
|
file: path.resolve( __dirname, 'main.js' ), |
||||
|
line: 1, |
||||
|
column: 22 |
||||
|
}, |
||||
|
frame: ` |
||||
|
1: assert.equal( 21 * 2, TK ); |
||||
|
^ |
||||
|
` |
||||
|
} |
||||
|
}; |
@ -0,0 +1 @@ |
|||||
|
assert.equal( 21 * 2, TK ); |
@ -1,22 +0,0 @@ |
|||||
var path = require( 'path' ); |
|
||||
var assert = require( 'assert' ); |
|
||||
|
|
||||
module.exports = { |
|
||||
description: 'reports which file caused a transform error', |
|
||||
options: { |
|
||||
plugins: [{ |
|
||||
name: 'bad-plugin', |
|
||||
transform: function ( code, id ) { |
|
||||
if ( /foo/.test( id ) ) { |
|
||||
throw new Error( 'nope' ); |
|
||||
} |
|
||||
} |
|
||||
}] |
|
||||
}, |
|
||||
error: { |
|
||||
code: 'BAD_TRANSFORMER', |
|
||||
message: `Error transforming foo.js with 'bad-plugin' plugin: nope`, |
|
||||
plugin: 'bad-plugin', |
|
||||
id: path.resolve( __dirname, 'foo.js' ) |
|
||||
} |
|
||||
}; |
|
@ -1,3 +0,0 @@ |
|||||
export default function () { |
|
||||
console.log( 'foo' ); |
|
||||
} |
|
@ -1,3 +0,0 @@ |
|||||
import foo from './foo.js'; |
|
||||
|
|
||||
foo(); |
|
Loading…
Reference in new issue