-
-
Notifications
You must be signed in to change notification settings - Fork 579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: error and diagnostics #4866
Merged
Merged
Conversation
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
Current dependencies on/for this PR:
This stack of pull requests is managed by Graphite. |
github-actions
bot
added
the
team
The issue/pr is created by the member of Rspack.
label
Dec 4, 2023
h-a-n-a
force-pushed
the
12-04-refactor_error_and_diagnostics
branch
from
December 4, 2023 10:38
5d15894
to
6b52494
Compare
2 tasks
h-a-n-a
force-pushed
the
12-04-refactor_error_and_diagnostics
branch
2 times, most recently
from
December 4, 2023 13:20
11bdaf9
to
4c359da
Compare
h-a-n-a
force-pushed
the
12-04-refactor_error_and_diagnostics
branch
from
December 5, 2023 04:51
3406e7f
to
4c359da
Compare
2 tasks
h-a-n-a
force-pushed
the
12-04-refactor_error_and_diagnostics
branch
2 times, most recently
from
December 5, 2023 07:58
35be7b3
to
2247eee
Compare
h-a-n-a
force-pushed
the
12-04-refactor_error_and_diagnostics
branch
from
December 7, 2023 10:57
2247eee
to
b6ff92e
Compare
h-a-n-a
force-pushed
the
12-04-refactor_error_and_diagnostics
branch
from
December 8, 2023 03:55
b6ff92e
to
8deb971
Compare
h-a-n-a
requested review from
LingyuCoder,
ahabhgk,
IWANABETHATGUY and
ScriptedAlchemy
December 8, 2023 04:39
IWANABETHATGUY
approved these changes
Dec 8, 2023
ahabhgk
approved these changes
Dec 8, 2023
h-a-n-a
added a commit
that referenced
this pull request
Dec 8, 2023
…4892) <!-- Thank you for submitting a pull request! We appreciate the time and effort you have invested in making these changes. Please ensure that you provide enough information to allow others to review your pull request. Upon submission, your pull request will be automatically assigned with reviewers. If you want to learn more about contributing to this project, please visit: https://github.com/web-infra-dev/rspack/blob/main/CONTRIBUTING.md. --> ## Summary Based on the overall idea behind this in #4866. This PR leverages `miette` and `thiserror` for representing errors and diagnostics. This makes aligning with webpack errors easily. 1. `miette::Error` as `rspack_error::Error` 2. `miette::Error` as `Diagnostic` 3. `Result<T> = std::result::Result<T, miette::Error>` 4. Print diagnostics with `miette::GraphicalReportHandler` 5. Eagerly deduped ecma errors on site, and remove `PartialEq`, etc from `Diagnostics`. 6. Refactored one Webpack Error to diagnostic representation, use https://github.com/web-infra-dev/rspack/pull/4892/files#diff-b6b8b1bb36b909de2bbe46c5de8c4c34515cb1c9710e8d02faec369b352da525R167 as an example Minor changes: 1. Removed `clippy::unwrap_in_result` as previously discussed. <!-- Can you explain the reasoning behind implementing this change? What problem or issue does this pull request resolve? --> <!-- It would be helpful if you could provide any relevant context, such as GitHub issues or related discussions. --> ## Test Plan See snapshot changes. <!-- Can you please describe how you tested the changes you made to the code? --> ## Require Documentation? <!-- Does this PR require documentation? --> - [X] No - [ ] Yes, the corresponding rspack-website PR is \_\_
ahabhgk
pushed a commit
that referenced
this pull request
Jan 2, 2024
<!-- Thank you for submitting a pull request! We appreciate the time and effort you have invested in making these changes. Please ensure that you provide enough information to allow others to review your pull request. Upon submission, your pull request will be automatically assigned with reviewers. If you want to learn more about contributing to this project, please visit: https://github.com/web-infra-dev/rspack/blob/main/CONTRIBUTING.md. --> ## Summary This chain of PRs are intended to solve problems related to errors/diagnostics as follows. `InternalErrors` are abusively used across rspack crates. However these errors should provide more useful **context**. See: #4613, #4321. `Diagnostics` in rspack is represented by another custom type to be fed to `codespan-reporting` in reporting. This indicates that errors should be converted in the first place in order to be consumed by `Stats`. In the following PRs, the essential idea to solve the problems are as follows: 1. `miette` and `thiserror`: This pair of libraries can either make fancy diagnostics and create easy to read errors. `GraphicalReportHandler` of `miette` can be helpful to directly print error diagnostics. 2. `codespan-reporting` is removed as rspack will never rely on custom diagnostics anymore 3. Custom error code to maximize the compatibility with Webpack's error types 4. Improved webpack error overlay Some miscellaneous are included in the graphite stack. Take a look over the PR tree down below. **This** PR did some small initialization works. <!-- Can you explain the reasoning behind implementing this change? What problem or issue does this pull request resolve? --> <!-- It would be helpful if you could provide any relevant context, such as GitHub issues or related discussions. --> ## Test Plan <!-- Can you please describe how you tested the changes you made to the code? --> ## Require Documentation? <!-- Does this PR require documentation? --> - [ ] No - [x] Yes, the corresponding rspack-website PR is \_\_
ahabhgk
pushed a commit
that referenced
this pull request
Jan 2, 2024
…4892) <!-- Thank you for submitting a pull request! We appreciate the time and effort you have invested in making these changes. Please ensure that you provide enough information to allow others to review your pull request. Upon submission, your pull request will be automatically assigned with reviewers. If you want to learn more about contributing to this project, please visit: https://github.com/web-infra-dev/rspack/blob/main/CONTRIBUTING.md. --> ## Summary Based on the overall idea behind this in #4866. This PR leverages `miette` and `thiserror` for representing errors and diagnostics. This makes aligning with webpack errors easily. 1. `miette::Error` as `rspack_error::Error` 2. `miette::Error` as `Diagnostic` 3. `Result<T> = std::result::Result<T, miette::Error>` 4. Print diagnostics with `miette::GraphicalReportHandler` 5. Eagerly deduped ecma errors on site, and remove `PartialEq`, etc from `Diagnostics`. 6. Refactored one Webpack Error to diagnostic representation, use https://github.com/web-infra-dev/rspack/pull/4892/files#diff-b6b8b1bb36b909de2bbe46c5de8c4c34515cb1c9710e8d02faec369b352da525R167 as an example Minor changes: 1. Removed `clippy::unwrap_in_result` as previously discussed. <!-- Can you explain the reasoning behind implementing this change? What problem or issue does this pull request resolve? --> <!-- It would be helpful if you could provide any relevant context, such as GitHub issues or related discussions. --> ## Test Plan See snapshot changes. <!-- Can you please describe how you tested the changes you made to the code? --> ## Require Documentation? <!-- Does this PR require documentation? --> - [X] No - [ ] Yes, the corresponding rspack-website PR is \_\_
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This chain of PRs are intended to solve problems related to errors/diagnostics as follows.
InternalErrors
are abusively used across rspack crates. However these errorsshould provide more useful context. See: #4613, #4321.
Diagnostics
in rspack is represented by another custom typeto be fed to
codespan-reporting
in reporting. This indicates that errorsshould be converted in the first place in order to be consumed by
Stats
.In the following PRs, the essential idea to solve the problems are as follows:
miette
andthiserror
: This pair of libraries can either make fancy diagnostics and create easy to read errors.GraphicalReportHandler
ofmiette
can be helpful to directly print error diagnostics.codespan-reporting
is removed as rspack will never rely on custom diagnostics anymoreSome miscellaneous are included in the graphite stack. Take a look over the PR tree down below.
This PR did some small initialization works.
Test Plan
Require Documentation?