jscutlery/devkit

[swc-plugin-angular] Add vitest support

yjaaidi opened this issue · 2 comments

Using inline commonjs require() was an interesting quick win but switching to using ES imports will allow us to support vitest and any other modern tools.

What about making the module system configurable so we can support both and still have first class Jest support?

TL;DR: emitting ES imports allows users to choose the module type.

Actually, SWC is already doing that for us using the module.type option.
That is why the right way is to emit ES imports and let SWC transform that to commonjs require or let it as is depending on the module.type option.

BTW, when using @swc/jest, this option is a no-op because @swc/jest will override it depending on Jest's configuration: https://github.com/swc-project/pkgs/blob/f035da2969b45ab9b1810fc2b93be9798ccf8069/packages/jest/index.ts#L55