Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test to verify error object after transform not showing correct l…
…ocation
- Loading branch information
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
test/function/samples/error-after-transform-should-throw-correct-location/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var path = require( 'path' ); | ||
var assert = require( 'assert' ); | ||
var MagicString = require( 'magic-string' ); | ||
|
||
module.exports = { | ||
description: 'error after transform should throw with correct location of file', | ||
options: { | ||
plugins: [ | ||
{ | ||
transform: function ( source, id ) { | ||
var s = new MagicString( source ); | ||
s.prepend( "import _assign from 'object-assign';\n" ); | ||
|
||
return { | ||
code: s.toString(), | ||
map: s.generateMap({ hires: true }) | ||
}; | ||
} | ||
} | ||
] | ||
}, | ||
error: { | ||
code: 'MISSING_EXPORT', | ||
message: `'default' is not exported by empty.js`, | ||
pos: 44, | ||
loc: { | ||
file: path.resolve( __dirname, 'main.js' ), | ||
line: 1, | ||
column: 7 | ||
}, | ||
frame: ` | ||
1: import a from './empty.js'; | ||
^ | ||
2: | ||
3: Object.assign({}, a); | ||
`, | ||
url: `https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module` | ||
} | ||
}; |
Empty file.
3 changes: 3 additions & 0 deletions
3
test/function/samples/error-after-transform-should-throw-correct-location/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import a from './empty.js'; | ||
|
||
Object.assign({}, a); |