Skip to content
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

feat(terser): emit worker error message (+stack) to parent instance #1394

Closed
wants to merge 1 commit into from

Conversation

tada5hi
Copy link
Member

@tada5hi tada5hi commented Jan 6, 2023

Rollup Plugin Name: terser

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.

List any relevant issue numbers:

Description

@tada5hi
Copy link
Member Author

tada5hi commented Jan 6, 2023

@shellscape would be great if you could have a look ✌️

PS: Would be great if you could also add me to the plugin maintainers: https://github.com/orgs/rollup/teams/plugin-maintainers 😅

@shellscape
Copy link
Collaborator

I'm codeowner on the whole repo so I get email notifications of everything.

@tada5hi
Copy link
Member Author

tada5hi commented Jan 6, 2023

I will remember that ^^. Did you see the change in the last comment?
Sorry for mentioning you again in addition 🙈

@tada5hi
Copy link
Member Author

tada5hi commented Jan 8, 2023

@shellscape is something missing?

@@ -23,6 +23,12 @@ export interface WorkerOutput {
sourceMap?: Record<string, any>;
}

export interface WorkerError {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is pretty loose. being more constrained would probably be a good idea. Adding an error property to WorkerOutput is more semantic. error can be an object with message and stack, and then all you need do is check if data.error is truthy on line 111. that will remove some complexity I don't think is needed.

Copy link
Member Author

@tada5hi tada5hi Jan 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shellscape but that would imply that all other properties of the WorkerOutput must be nullable, in case an error occoured and the error property is set and than it would be harder to distinguish between a success and error state and infer property values or am i wrong here ?

But I also see the complexity in the current implementation for the actual simple feature

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I follow:

error is nullish: no error
error is truthy: error

Copy link
Member Author

@tada5hi tada5hi Jan 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, but the code property e.g. could then no longer be a mandatory property. All attributes of the WorkerOutput type would then have to be nullable to cover all states (success +errror)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. why is that a concern?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like to map different states using different types and then merge them with a union type if necessary 😇 .
Even with callbacks, there are also two parameters (error, result), instead of the error being an optional property of the result parameter. The same applies to promises. But I have no problem doing it the way you suggested, if you prefer ✌️ ☺️ .

packages/terser/test/test.js Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants