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: allow modules to be marked as errors #152

Merged
merged 2 commits into from
Aug 24, 2023

Conversation

markdalgleish
Copy link
Contributor

This adds an error module type so that Node built-ins can be marked as errors if they're present in the final output.

I've described this in a comment in the code, but this is done by scanning the generated code so that unused modules can be part of the module graph. This way it's only an error if they're not tree shaken.

This is useful in the context of Remix because we have Node built-ins in the module graph that may never be used on the client. This is due to the way route files contain both server and client code. In this case the fallback option is super useful because I can break the Remix browser build if an unpolyfilled module is detected in the output, whereas our v2 branch currently falls back to an empty module which is a runtime error. This approach is much nicer for us.

Status and versioning classification:

  • Code changes have been tested and working fine, or there are no code changes
  • This PR changes the library's interface (methods or parameters added)

Copy link
Owner

@imranbarbhuiya imranbarbhuiya left a comment

Choose a reason for hiding this comment

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

Changes LGTM but why write option need to be false?

@markdalgleish
Copy link
Contributor Author

@imranbarbhuiya Because you can't read the contents of outputFiles in the onEnd callback unless write is set to false.

@imranbarbhuiya imranbarbhuiya merged commit c02060d into imranbarbhuiya:main Aug 24, 2023
@markdalgleish markdalgleish deleted the error-polyfills branch August 24, 2023 14:10
@imranbarbhuiya
Copy link
Owner

imranbarbhuiya commented Aug 24, 2023

released in v1.5.0

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.

2 participants