feat: bypass transformation in browser and vitest
Combining with https://github.com/unjs/unbuild/pull/300, it would allow unbuild --stub's output compatible with the browser and Vitest, by opting-out jiti transform on them and forward to Vite's transformation.
Playground: https://stackblitz.com/~/github.com/antfu/testing-jiti-on-vite
(drafting until we support jiti.import to avoid breaking changes for current jiti users)
@pi0 Implemented the async jiti.import (https://github.com/unjs/jiti/pull/158/commits/eddf1f582ec1b7acfe234b6280b1c540f5172477) and let unbuild's mjs stub using it (https://github.com/unjs/unbuild/pull/300/commits/f3d5a566c844bfc4a9d504d5f4857a7cc2d7bfd3) for vite/vitest env. WDYT?
Seems good start only would you mind separating PR for jiti.import?
I've added new jiti/native (https://github.com/unjs/jiti/pull/289) to experiment with it. I think if vitest can have a specific export condition it would be much safer to rely on that.
For bun we have a runtime test check that only uses bun native import. vitest can also have runtime hook perhaps.
Closing PR for triage and preparing final release but let's discuss how we can make it working out of the box finally for vitest!