-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Minifier should panic with a descriptive error message on JSX/TypeScript #9204
Comments
This is expected, but I think minifeir should panic instead |
I managed to fix this by adding a
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
fn visit_jsx_element_name(&mut self, n: &JSXElementName) {
let ctx = Ctx {
in_pat_of_var_decl: false,
in_pat_of_param: false,
in_catch_param: false,
var_decl_kind_of_pat: None,
in_pat_of_var_decl_with_init: false,
..self.ctx
};
n.visit_children_with(&mut *self.with_ctx(ctx));
if let JSXElementName::Ident(i) = n {
self.with_ctx(ctx).report_usage(i);
}
} Would do you think about fixing it instead of panic? |
JSX is not a standard, so I think it should panic instead of handling them. |
**Description:** These macros are optimization hint on release builds. **Related issue:** - Closes #9204
I found that we should support this due to |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Describe the bug
We are using the SWC minifier with Rust API. But the output is incorrect with JSX is preserved.
If a variable is only being used as a
JSXElementName
, it will be mistakenly removed by SWC minifier.Input code
Config
Playground link (or link to the minimal reproduction)
https://play.swc.rs/?version=1.6.7&code=H4sIAAAAAAAAA0vOzysuUXDLz1ewVUguSk0sSQWyNTStuVIrCvKLShTSSvOSSzLz8xQcCwo0NBWquRSAoCi1pLQoT0EDzAEBm7LM1HI7OBcsBDJTHyFmo49QAzS%2BlgsAf4CxUHoAAAA%3D&config=H4sIAAAAAAAAA32UO3LjMAyG%2B5zCozrFjostcoDt9gwcWgRlZilCQ4CONRnffaFnPDboTsIHEMQPEN9vh0PzSW3zcfiWT%2FkZbCbI%2B79YaExsr2JpeByA2hwGbt43yjQhzgVmy20BDdvcAU9BQMdfx%2BMa0EREAjF7GwlWWx9S8ON9yhb7IQPRnU2scmTpITGtCd%2FvUcYvxX5CjGDTC2IsmZAYOsiKV4sx2oHAXKyOe9ErEGoZJlgYnBkyDipPLnDAJFI8UwfWmRbdg1gLCxlaDhfQ4iSZxCWS8irUwal03dzkBwwXG4tlJRCuc0Pkts%2FsjIHY%2BKKJsLCKAgvUpQ3eZOCSlXyfGNIW9SjNPwApP1qiZHtNn9nByyhV2RaoHh2Sl2nl8TlYJlurMUEngpoQvNbJSRjIHLSbZnClhUnXtk4rMlBwYMB7GRMllr4Ct2ct5%2FTC0StAmmvVChZg9gdY4dNjeIH%2FSJG8DFfFo7d8rlMa%2BxPGFwl64DO6Fw7SCcY6zrIgrkOdl%2BRAJgOc6lJoBs8LQMaf0cR5Uz7QQfYKy4mmi3j6WRGrw21fwL1NXdw7syzht9Wh6dGVGa7bfervspR%2FNz9O2%2F7dL94E%2BrtFzklv%2FwFbOOlnKQYAAA%3D%3D
SWC Info output
No response
Expected behavior
The
const Foo
is preserved in the output:Actual behavior
The
const Foo
is removed. Result inFoo is not defined
error at runtime.Version
1.6.7
Additional context
No response
The text was updated successfully, but these errors were encountered: