jiti icon indicating copy to clipboard operation
jiti copied to clipboard

feat: bypass transformation in browser and vitest

Open antfu opened this issue 2 years ago • 3 comments

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

antfu avatar Aug 16 '23 15:08 antfu

(drafting until we support jiti.import to avoid breaking changes for current jiti users)

pi0 avatar Aug 16 '23 15:08 pi0

@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?

antfu avatar Oct 02 '23 08:10 antfu

Seems good start only would you mind separating PR for jiti.import?

pi0 avatar Oct 02 '23 09:10 pi0

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!

pi0 avatar Sep 12 '24 22:09 pi0