oxc/crates
overlookmotel 73b78643f2 refactor(transformer): combine import and usage in JSX transform (#3540)
React JSX transform contains some confusing logic (ported directly from Babel) where in automatic mode, imports are inserted in one place, and then used in another.

Logic for which imports are needed is duplicated in both places, and it's hard to figure out whether they're in sync or not (I don't think they are in all cases).

This PR unifies the logic in one place. Imports are now added as and when they're used.

The `Bindings` enum is responsible for creating imports and also holds the state of which "mode" the plugin is working in:

1. Classic
2. Automatic script
3. Automatic module

Combining the two choices classic/automatic and script/module into a single enum:

1. clarifies the logic
2. reduces branching
3. reduces lookups on `ReactJsx::options` (which is behind an `Rc` and therefore costly to read from).
2024-06-06 03:19:41 +00:00
..
oxc chore: regenerate changelog 2024-06-06 01:29:38 +08:00
oxc_allocator chore: regenerate changelog 2024-06-06 01:29:38 +08:00
oxc_ast chore: regenerate changelog 2024-06-06 01:29:38 +08:00
oxc_ast_macros chore: regenerate changelog 2024-06-06 01:29:38 +08:00
oxc_codegen chore: regenerate changelog 2024-06-06 01:29:38 +08:00
oxc_diagnostics chore: regenerate changelog 2024-06-06 01:29:38 +08:00
oxc_index chore: regenerate changelog 2024-06-06 01:29:38 +08:00
oxc_js_regex
oxc_language_server fix: fix some nightly warnings 2024-05-19 00:54:52 +08:00
oxc_linter feat(linter): add fixer for no-single-promise-in-promise-methods (#3531) 2024-06-06 01:40:03 +08:00
oxc_macros refactor(macros): remove the redundant trie builder (#3415) 2024-05-26 08:00:05 +00:00
oxc_minifier chore: regenerate changelog 2024-06-06 01:29:38 +08:00
oxc_module_lexer chore: regenerate changelog 2024-06-06 01:29:38 +08:00
oxc_parser chore: regenerate changelog 2024-06-06 01:29:38 +08:00
oxc_prettier fix(parser): correctly parse cls.fn<C> = x (#3208) 2024-05-09 10:23:45 +08:00
oxc_semantic chore: regenerate changelog 2024-06-06 01:29:38 +08:00
oxc_sourcemap chore: regenerate changelog 2024-06-06 01:29:38 +08:00
oxc_span chore: regenerate changelog 2024-06-06 01:29:38 +08:00
oxc_syntax chore: regenerate changelog 2024-06-06 01:29:38 +08:00
oxc_transformer refactor(transformer): combine import and usage in JSX transform (#3540) 2024-06-06 03:19:41 +00:00
oxc_traverse chore: regenerate changelog 2024-06-06 01:29:38 +08:00
oxc_wasm chore: bump oxc-browserslist to 0.17.0 (#3495) 2024-06-01 15:06:34 +08:00