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

chore: update Nestjs example to include minimizer options #158

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

lorenzodejong
Copy link
Contributor

This PR updates the Nest.js example to include minimizer options. The minimization was previously disabled, however it's possible to enable this with the right settings to allow for optimized production builds.

The main issue when using Nest.js is the ExecutionContext implementation, which retrieves class and handler values based on function names. This causes issues, for example when using this in combination with decorator metadata.

Copy link
Contributor

@chenjiahan chenjiahan left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! ❤️

@chenjiahan chenjiahan enabled auto-merge (squash) October 25, 2024 08:54
@chenjiahan chenjiahan merged commit 8abd8a6 into rspack-contrib:main Oct 25, 2024
1 check passed
Coly010 pushed a commit to nrwl/nx that referenced this pull request Oct 29, 2024
#28629)

## Current Behavior
When using Nest.js in combination with [decorator
metadata](https://docs.nestjs.com/fundamentals/execution-context#reflection-and-metadata),
the class names and handlers become mangled/compressed causing them to
lose the reference to the correct class/handler name.

## Expected Behavior
The decorator metadata works as intended.

## Approach
This PR implements a custom instance of the
`SwcJsMinimizerRspackPlugin`, where the setting is modified to keep
original class and function names from the `compress` and `mangle`
options.

## Related
I've opened a related PR on the rspack-examples repository:
rspack-contrib/rspack-examples#158
jaysoo pushed a commit to nrwl/nx that referenced this pull request Oct 31, 2024
#28629)

## Current Behavior
When using Nest.js in combination with [decorator
metadata](https://docs.nestjs.com/fundamentals/execution-context#reflection-and-metadata),
the class names and handlers become mangled/compressed causing them to
lose the reference to the correct class/handler name.

## Expected Behavior
The decorator metadata works as intended.

## Approach
This PR implements a custom instance of the
`SwcJsMinimizerRspackPlugin`, where the setting is modified to keep
original class and function names from the `compress` and `mangle`
options.

## Related
I've opened a related PR on the rspack-examples repository:
rspack-contrib/rspack-examples#158
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