Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable typescript compiling when using NodeNext and --experimental-strip-types #6960

Closed
4 tasks done
damianobarbati opened this issue Nov 25, 2024 · 2 comments
Closed
4 tasks done

Comments

@damianobarbati
Copy link

Clear and concise description of the problem

NodeJS recently introduced the new --experimental-strip-types and --experimental-transform-types flags, allowing to .ts files without the need to transpile anything (types are just replaced with 1 empty space).

Full repro here: https://github.com/damianobarbati/ts-repro/

Is it possible to give the developer the option to opt-out of the build-in typescript transpiling when running vitest?
I see unconsistent behaviours arising with imports (probably due to esnext/tsx way of handling cjs).

Suggested solution

Give a flag to opt-out of transpiling.

Alternative

No response

Additional context

No response

Validations

@hi-ogawa
Copy link
Contributor

This feature is probably close to #3995 in the spirit. If having an genuine and more strict node behavior is critical, we have to recommend node test runner for now.

I see unconsistent behaviours arising with imports (probably due to esnext/tsx way of handling cjs).

This is more of resolution difference than transpilation and that's probably a harder part for Vite/Vitest to not intervene.

You can technically disable esbuild transpilation by esbuild: false https://vite.dev/config/shared-options.html#esbuild, but that's not enough since internally Vite expects transpiled js, so it would simply breaks.

@sheremet-va
Copy link
Member

Vite is what makes Vitest - Vitest, so the user code will always be processed by Vite. If you wish to support TS in external packages, you can pass down --experimental-strip-types in execArgv: https://vitest.dev/config/#pooloptions-forks-execargv

@sheremet-va sheremet-va closed this as not planned Won't fix, can't repro, duplicate, stale Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants