getCommentOptions renamed to getCommentOptionsStrict

and wrapped back in getCommentOptions to avoid possible breaking changes
This commit is contained in:
Ronan Amsterdam 2018-05-29 16:25:10 +08:00
parent 1969485f05
commit d91e7ecafc
2 changed files with 10 additions and 2 deletions

View File

@ -1994,7 +1994,7 @@ class Parser extends Tapable {
);
}
getCommentOptions(range) {
getCommentOptionsStrict(range) {
const comments = this.getComments(range);
if (comments.length === 0) return null;
const options = comments.map(comment => {
@ -2015,6 +2015,14 @@ class Parser extends Tapable {
return options.reduce((o, i) => Object.assign(o, i), {});
}
getCommentOptions(range) {
try {
return this.getCommentOptionsStrict(range);
} catch (e) {
return {};
}
}
getNameForExpression(expression) {
let expr = expression;
const exprName = [];

View File

@ -34,7 +34,7 @@ class ImportParserPlugin {
const groupOptions = {};
try {
importOptions = parser.getCommentOptions(expr.range);
importOptions = parser.getCommentOptionsStrict(expr.range);
} catch (e) {
parser.state.module.warnings.push(
new ImportOptionsCompileWarning(