feat: allow modules to be marked as errors #152
Merged
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.
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 ourv2
branch currently falls back to an empty module which is a runtime error. This approach is much nicer for us.Status and versioning classification: