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

Issues with js-minifier? #23

Open
phunguyen-finn opened this issue Jan 17, 2024 · 6 comments
Open

Issues with js-minifier? #23

phunguyen-finn opened this issue Jan 17, 2024 · 6 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@phunguyen-finn
Copy link

Since you're using class name as key, it can get pretty messed up going through a JS minifier, am I right? I got a case where in dev it goes ok, then I published it for production and it got an errors where two handler classes ended up having the same name.

@m4ss1m0g m4ss1m0g added bug Something isn't working enhancement New feature or request labels Jan 30, 2024
@m4ss1m0g
Copy link
Owner

I'm working on a possible solution (see the className branch).
Can you provide a minimal example or you can try the dev branch?

@thachp-mhc
Copy link

Is there an update on this issue? I potentially have a similar bug where I expected handler X to be called, but instead handler Y was executed. I can't reproduce it in development, but it does occur in production.

@m4ss1m0g
Copy link
Owner

I publish a beta version 1.3.0-beta.1 where you can specify a name for the className.

@thachp-mhc
Copy link

Thanks. It seems to be working. I'm not sure how to verify this, except that after minification, I can no longer reproduce the errors that I was having.

Is there an implicit way to implement this without having to explicitly define the unique ID in both the decorator and the request class?

@m4ss1m0g
Copy link
Owner

m4ss1m0g commented May 2, 2024

Is there an implicit way to implement this without having to explicitly define the unique ID in both the decorator and the request class?

I'm open to suggestions ;-)

@m4ss1m0g
Copy link
Owner

The v2 mediatr-ts have been released, there were breaking changes (interfaces and class has been renamed) see the README.

The code for add/get the request/notification was changed (code from beta1 was NOT ported), give it a try and send feedback about the issue.

If the problem persist you can try to remove className from minification.
For Webpack try this code.

module.exports = {
  mode: ...,
  resolve: ...,
  target: ...,
  optimization: {
    minimizer: [
      new TerserPlugin({
        terserOptions: {
          keep_classnames: true,
        },
      }),
    ],
  },
};

see this StackOverflow post

@m4ss1m0g m4ss1m0g self-assigned this Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants