Skip to content

Commit

Permalink
chore: revert breaking change
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Works committed Nov 22, 2022
1 parent e7e2aec commit c922ee1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lib/dependencies/CommonJsImportsParserPlugin.js
Expand Up @@ -236,7 +236,8 @@ class CommonJsImportsParserPlugin {
parser.parseCommentOptions(expr.range);

if (commentErrors) {
for (const { cause: e, comment } of commentErrors) {
for (const e of commentErrors) {
const { comment } = e;
parser.state.module.addWarning(
new CommentCompilationWarning(
`Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
Expand Down
3 changes: 2 additions & 1 deletion lib/dependencies/ImportParserPlugin.js
Expand Up @@ -55,7 +55,8 @@ class ImportParserPlugin {
parser.parseCommentOptions(expr.range);

if (commentErrors) {
for (const { cause: e, comment } of commentErrors) {
for (const e of commentErrors) {
const { comment } = e;
parser.state.module.addWarning(
new CommentCompilationWarning(
`Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
Expand Down
3 changes: 2 additions & 1 deletion lib/dependencies/WorkerPlugin.js
Expand Up @@ -203,7 +203,8 @@ class WorkerPlugin {
parser.parseCommentOptions(expr.range);

if (commentErrors) {
for (const { cause: e, comment } of commentErrors) {
for (const e of commentErrors) {
const { comment } = e;
parser.state.module.addWarning(
new CommentCompilationWarning(
`Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
Expand Down
6 changes: 5 additions & 1 deletion lib/javascript/JavascriptParser.js
Expand Up @@ -3635,6 +3635,7 @@ class JavascriptParser extends Parser {
return EMPTY_COMMENT_OPTIONS;
}
let options = {};
/** @type {unknown[]} */
let errors = [];
for (const comment of comments) {
const { value } = comment;
Expand All @@ -3651,7 +3652,10 @@ class JavascriptParser extends Parser {
options[key] = val;
}
} catch (e) {
errors.push({ comment, cause: e });
const newErr = new Error(String(e.message));
newErr.stack = String(e.stack);
newErr.comment = comment;
errors.push(newErr);
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions types.d.ts
Expand Up @@ -5476,9 +5476,7 @@ declare class JavascriptParser extends Parser {
evaluatedVariable(tagInfo?: any): VariableInfo;
parseCommentOptions(
range?: any
):
| { options: null; errors: null }
| { options: object; errors: { comment: any; cause: unknown }[] };
): { options: null; errors: null } | { options: object; errors: unknown[] };
extractMemberExpressionChain(expression: MemberExpression): {
members: string[];
object:
Expand Down

0 comments on commit c922ee1

Please sign in to comment.