Skip to content

Commit

Permalink
fix: a plugin error can contains numeric code
Browse files Browse the repository at this point in the history
  • Loading branch information
TrickyPi committed Jun 21, 2023
1 parent 33f87b4 commit 44b7221
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/rollup/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface RollupLog {
meta?: any;
names?: string[];
plugin?: string;
pluginCode?: string;
pluginCode?: unknown;
pos?: number;
reexporter?: string;
stack?: string;
Expand Down
14 changes: 9 additions & 5 deletions src/utils/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -783,12 +783,16 @@ export function logParseError(error: Error, moduleId: string): RollupLog {
}

export function logPluginError(
error: RollupLog,
error: Omit<RollupLog, 'code'> & { code?: unknown },
plugin: string,
{ hook, id }: { hook?: string; id?: string } = {}
): RollupLog {
if (error.code && !error.code.startsWith('PLUGIN_') && !error.pluginCode) {
error.pluginCode = error.code;
) {
const code = error.code;
if (
!error.pluginCode &&
((typeof code === 'string' && !code.startsWith('PLUGIN_')) || code != null)
) {
error.pluginCode = code;
}
error.code = PLUGIN_ERROR;
error.plugin = plugin;
Expand All @@ -798,7 +802,7 @@ export function logPluginError(
if (id) {
error.id = id;
}
return error;
return error as RollupLog;
}

export function logShimmedExport(id: string, binding: string): RollupLog {
Expand Down

0 comments on commit 44b7221

Please sign in to comment.