Skip to content

Commit c0bf2d2

Browse files
authored
fix: use cwd in async: false mode for consistency (#533)
Closes: #509
1 parent 8cd7304 commit c0bf2d2

File tree

4 files changed

+5
-13
lines changed

4 files changed

+5
-13
lines changed

src/hooks/tapAfterCompileToGetIssues.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@ function tapAfterCompileToGetIssues(
4040
issues = hooks.issues.call(issues, compilation);
4141

4242
issues.forEach((issue) => {
43-
const error = new IssueWebpackError(
44-
configuration.formatter(issue),
45-
compiler.options.context || process.cwd(),
46-
issue
47-
);
43+
const error = new IssueWebpackError(configuration.formatter(issue), issue);
4844

4945
if (issue.severity === 'warning') {
5046
compilation.warnings.push(error);

src/hooks/tapDoneToAsyncGetIssues.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@ function tapDoneToAsyncGetIssues(
6969

7070
if (state.webpackDevServerDoneTap) {
7171
issues.forEach((issue) => {
72-
const error = new IssueWebpackError(
73-
configuration.formatter(issue),
74-
compiler.options.context || process.cwd(),
75-
issue
76-
);
72+
const error = new IssueWebpackError(configuration.formatter(issue), issue);
7773

7874
if (issue.severity === 'warning') {
7975
stats.compilation.warnings.push(error);

src/issue/IssueWebpackError.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ class IssueWebpackError extends Error {
77
readonly hideStack = true;
88
readonly file: string | undefined;
99

10-
constructor(message: string, context: string, readonly issue: Issue) {
10+
constructor(message: string, readonly issue: Issue) {
1111
super(message);
1212

1313
// to display issue location using `loc` property, webpack requires `error.module` which
1414
// should be a NormalModule instance.
1515
// to avoid such a dependency, we do a workaround - error.file will contain formatted location instead
1616
if (issue.file) {
17-
this.file = forwardSlash(relative(context, issue.file));
17+
this.file = forwardSlash(relative(process.cwd(), issue.file));
1818

1919
if (issue.location) {
2020
this.file += `:${formatIssueLocation(issue.location)}`;

test/e2e/TypeScriptContextOption.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ describe('TypeScript Context Option', () => {
6969
await sandbox.patch(
7070
'webpack.config.js',
7171
"entry: './src/index.ts',",
72-
"entry: path.resolve(__dirname, './src/index.ts'),"
72+
["entry: './src/index.ts',", 'context: path.resolve(__dirname),'].join('\n')
7373
);
7474
await sandbox.patch(
7575
'webpack.config.js',

0 commit comments

Comments
 (0)