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
Special loader for vite(st) environments #150
Comments
/cc @antfu If you have any ideas. |
I image that we could have a magic comment in the stub file, and then with a Vite plugin to transform it back to a redirect. For example: // @jiti-stub /path/to/source.ts
module.exports = jiti()('/path/to/source.ts') export const jitiStubPlugin() {
return {
name: 'jiti:stub',
transform(code, id) {
if (!code.includes('@jiti-stub')) return
const match = /REGEX/.match(code)
return `export * from "${match[1]}"`
}
}
} |
Do you think would it be possible to magically making jiti+vite working together out of the box without custom user/framework plugins? |
I can't think of one at this moment (without changes in Vite core, which is unlikely to happen) |
Can we detect vite environment in a reliable way or having an export condition by default in vite? This way i was thinking jiti instead can change it's internal behavior for vite(st) compatibility. |
FWIW — Im able to get the tests to run fine in vitest using this little unplugin resolver i wrote (main issue was the It works fine — the remaining issue is (in the context of a monorepo at least) making changes in stubbed |
While this is not a direct purpose of jiti, when it is used in testing environments (unbuild dist in stub mode) we might need to detect vite environment and bypass transforms.
The text was updated successfully, but these errors were encountered: