# API Changes
## `swc_ecma_utils`
### Renames
- `find_ids` => `find_pat_ids`
- `prepend` => `prepend_stmt`
- `as_bool` => `cast_to_bool`
- `as_number` => `as_pure_number`
- `as_string` => `cast_to_string`
- (`as_pure_bool`, `cast_to_number` is not renamed)
- `UsageFinder` => `IdentUsageFinder`.
- `IdentFinder` => `IdentRefFinder`.
## Changes
- Re-export of `HANDLER` from `swc_common::errors` is removed. Use `swc_common::error::HANDLER` instead.
- Re-export of `Id` from `swc_ecma_ast` is removed. Use `swc_ecma_ast::Id` instead.
- `ExprCtx` is used for apis related to `Expr`.
- `preserve_effects` is now a method of `ExprCtx`. It was a top-level function.
- `extract_side_effects_to` is now a method of `ExprCtx`. It was a top-level function.
- `IdentUsageFinder` (previously `UsageFinder`) now takes `Id` instead of `Ident`.
- `IdentRefFinder` (previously `IdentFinder`) now takes `Id` instead of `Ident`.
- `ExprExt::is_ident_ref_to` is removed.
- `Expr::is_global_ref_to` is added.
- `:🆔:id` is removed. Use `Ident::to_id()` instead.
- We don't need a list of bindings to check if an identifier is unresolved.
- Checking if an identifier is unresolved is now one CPU instruction.
- Previously it was one hashmap operation.
- This PR also improves performance, by removing the hashmaps mentioned above.
- We now check if there's pending inlining before remapping variables.
- We now use ad-hoc type for remapping.
- We now inline before remapping to prevent interference with inlining.
- We now remap parameters using a new syntax context. This is required because we may copy functions, and it can result in duplicated variables with respect to the span hygiene.
- We now visit the sequence expression generated by inlining. This is to improve performance in some cases.
- We now remove variables from variable statements if it's identical to a parameter declared in the function.
- IIFE evaluation is now aware of `this` being different for member expressions.
- We now have more logic for detecting simple functions.
swc_ecma_minifier:
- `conditionals`: Preserve a conditional expression if test is not resolved.
- `unsafe_arrows`: Optimize an anonymous function expression as an arrow expression.
- `unsafe_methods`: Optimize a method property where the only statement is return to an arrow expression.
swc_ecma_minifier:
- `pure`: Add an optional list of bindings.
- `pure`: Drop identifier only if we have the complete list of bindings.
- `pure`: Allow using `GLOBALS`.
- `pure`: Drop some pure member expressions.
- Move identifier dropping logic from the stateful optimizer to the pure optimizer.
- `pure`: Drop more references to global declarations.
swc_ecma_transforms_optimization:
- `expr_simplifier`: Track more changes.
swc_ecma_minifier:
- Analyze after applying the pure optimizer.
- Preserve access to a variable not in scope.
- `compress`: Remove string literal if it was not a directive.
- `pure/collapse_vars`: Merge vars declared in the first statement into one with initializers if `collapse_vars` and `join_vars` are enabled.
- `unused`: Use `usage_count` instead of `ref_count`.
- `unused`: Fix dropping rule for member expressions.
- `unused`: Fix dropping rule for declarations.
- `hoist_props`: Preserve exported items.
swc_ecma_transforms_base:
- `resolver`: Ignore named export with source.
- `hygiene`: Ignore named export with source. (Closes#2924, Closes#3114)
swc_ecma_minifier:
- Handle `export default` declarations as declaration instead of expressions. (Closes#2717)
- Don't override already-processed identifiers. (Closes#2988)
swc_bundler:
- Adjust the syntax context for named re-exports.
swc_ecma_minifier:
- Add `module` to `TerserCompressorOptions`.
- Don't create top level variables while inlining if `module` is false.
- Drop more unused parameters.
swc_ecma_parser:
- Preserve more data for invalid escapes in template literals.
swc_ecma_transforms_compat:
- Fix handling of template literals. (Closes#2674)