Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw better error messages for parse errors in non-JS files (#2466)
- Loading branch information
1 parent
c962007
commit bfb6b03
Showing
9 changed files
with
72 additions
and
10 deletions.
There are no files selected for viewing
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
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
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,22 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
description: | ||
'throws with an extended error message when failing to parse a file with ".json" extension', | ||
error: { | ||
code: 'PARSE_ERROR', | ||
message: 'Unexpected token (Note that you need rollup-plugin-json to import JSON files)', | ||
pos: 10, | ||
loc: { | ||
file: path.resolve(__dirname, 'file.json'), | ||
line: 2, | ||
column: 8 | ||
}, | ||
frame: ` | ||
1: { | ||
2: "JSON": "is not really JavaScript" | ||
^ | ||
3: } | ||
` | ||
} | ||
}; |
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 @@ | ||
{ | ||
"JSON": "is not really JavaScript" | ||
} |
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 json from './file.json'; | ||
|
||
console.log(json); |
23 changes: 23 additions & 0 deletions
23
test/function/samples/error-parse-unknown-extension/_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,23 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
description: | ||
'throws with an extended error message when failing to parse a file without .(m)js extension', | ||
error: { | ||
code: 'PARSE_ERROR', | ||
message: | ||
'Unexpected token (Note that you need plugins to import files that are not JavaScript)', | ||
pos: 0, | ||
loc: { | ||
file: path.resolve(__dirname, 'file.css'), | ||
line: 1, | ||
column: 0 | ||
}, | ||
frame: ` | ||
1: .special-class { | ||
^ | ||
2: color: black; | ||
3: } | ||
` | ||
} | ||
}; |
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 @@ | ||
.special-class { | ||
color: black; | ||
} |
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 css from './file.css'; | ||
|
||
console.log(css); |
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