tutorialkit icon indicating copy to clipboard operation
tutorialkit copied to clipboard

Replace direct `babel` usage with `magicast`

Open AriPerkkio opened this issue 1 year ago • 1 comments

Is your feature request related to a problem?

Currently CLI modifies user's astro.config.ts via AST transforms using Babel. This works really well but it quite heavy to maintain.

https://github.com/stackblitz/tutorialkit/blob/9333065ae9200fc0a22a54c4684bca5546be89cc/packages/cli/src/utils/astro-config.ts#L78-L148

Describe the solution you'd like.

Check if direct Babel usage could be replaced with magicast. It provides much nicer API to work with AST transforms. This package is also used by Vitest, where we modify user's vitest.config.ts. It's very similar to what TutorialKit does.

https://github.com/vitest-dev/vitest/blob/7012f8c12a3d0004e7e7651bbeee905ac9102098/packages/vitest/src/utils/coverage.ts#L349-L402

We should also add similar unit tests: https://github.com/vitest-dev/vitest/blob/main/test/coverage-test/test/threshold-auto-update.unit.test.ts

Describe alternatives you've considered.

Keep maintaining the direct Babel integration. It's reliable and does exactly what we need it to, but it's not as easy to maintain.

Additional context

No response

AriPerkkio avatar Jul 10 '24 06:07 AriPerkkio

Get R Done

MoneyMouthBottom avatar Sep 02 '24 13:09 MoneyMouthBottom