swc/crates/swc_ecma_transforms_optimization/tests
Levi bfea322351
feat(es/testing): Parse test code as a Program instead of a Module (#9623)
**Description:**

This PR addresses the issue described in https://github.com/swc-project/swc/issues/8713

**BREAKING CHANGE:**
Will break unit tests that use `fold_module`/`visit_module`/`visit_mut_module` if the visitor is intended to work for both modules and scripts instead of using `fold_program`/`visit_program`/`visit_mut_program`.

When creating visitors, you should use `fold_program`/`visit_program`/`visit_mut_program` if you simply want to visit the top-level node.

When creating tests, the input source code will be parsed using `parse_program` by default. If you need to parse it as a `Module`, you can use `module: Some(true)` in `FixtureTestConfig` (or with `test!(module, ..)`), which will parse it as a `Program::Module`, or `Some(false)` for `Program::Script`. `None` will use `parse_program` (`parse_program` will auto-detect the underlying type).
2024-10-08 13:58:58 +09:00
..
__swc_snapshots__ perf(es/visit): Introduce standard_only_* macros (#9207) 2024-07-11 16:16:05 +00:00
const-modules/issue-7747 fix(es/minifier): Handle ModuleDecl when transform const modules (#7959) 2023-09-16 09:17:26 +00:00
dce perf(es/minifier): Remove double-visit of DCE (#6069) 2022-10-06 16:08:03 +00:00
dce-jsx fix(es/minifier): Support minifying JSX (#9271) 2024-07-18 12:50:59 +09:00
expr-simplifier chore(repo): Configure prettier (#4523) 2022-05-04 14:25:28 +00:00
const_modules.rs feat(es/testing): Use __swc_snapshots__ for test! macro (#8191) 2023-10-30 10:38:59 +09:00
fixture.rs fix(es/minifier): Support minifying JSX (#9271) 2024-07-18 12:50:59 +09:00
remove_imports_with_side_effects.rs refactor(es/parser): Rename EsConfig and TsConfig (#9094) 2024-06-22 01:56:37 +09:00
simplify_dce.rs feat(es/common): Introduce pure Span and BytePos to handle #__PURE__ (#9539) 2024-09-09 10:05:41 +09:00
simplify_inlining.rs feat(es/testing): Parse test code as a Program instead of a Module (#9623) 2024-10-08 13:58:58 +09:00
simplify.rs feat(es/testing): Parse test code as a Program instead of a Module (#9623) 2024-10-08 13:58:58 +09:00