Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: plugin warnings not showing warning.loc (#3824)
* fix: plugin warnings not showing warning.loc Plugin warnings without warning.id but with warning.loc were not emitting loc information loc information emitting is fundamental for user experience (to locate the source of the error/warning) * Update batchWarnings.ts * Add test Co-authored-by: Lukas Taegert-Atkinson <lukas.taegert-atkinson@tngtech.com> Co-authored-by: Lukas Taegert-Atkinson <lukastaegert@users.noreply.github.com>
- Loading branch information
1 parent
b794a13
commit 53e30e2
Showing
4 changed files
with
50 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const { assertIncludes } = require('../../../utils.js'); | ||
|
||
module.exports = { | ||
description: 'correctly adds locations to plugin warnings', | ||
command: 'rollup -c', | ||
stderr: stderr => { | ||
assertIncludes( | ||
stderr, | ||
'(!) Plugin test: Warning with file and id\n' + | ||
'file1: (1:2)\n' + | ||
'(!) Plugin test: Warning with file\n' + | ||
'file2: (2:3)\n' + | ||
'(!) Plugin test: Warning with id\n' + | ||
'file-id3: (3:4)\n' | ||
); | ||
} | ||
}; |
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 @@ | ||
console.log("everyday I'm throwing"); |
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,29 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
input: 'main.js', | ||
output: { | ||
format: 'cjs' | ||
}, | ||
plugins: [ | ||
{ | ||
name: 'test', | ||
buildStart() { | ||
this.warn({ | ||
message: 'Warning with file and id', | ||
file: path.join(__dirname, 'file-id1'), | ||
loc: { file: path.join(__dirname, 'file1'), line: 1, column: 2 } | ||
}); | ||
this.warn({ | ||
message: 'Warning with file', | ||
loc: { file: path.join(__dirname, 'file2'), line: 2, column: 3 } | ||
}); | ||
this.warn({ | ||
message: 'Warning with id', | ||
id: path.join(__dirname, 'file-id3'), | ||
loc: { line: 3, column: 4 } | ||
}); | ||
} | ||
} | ||
] | ||
}; |