-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat: support rolldown-vite #7509
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for vitest-dev ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Awesome progress already! 🎉
These two are oxc transform issues and they are tracked in oxc-project/oxc#9168 and oxc-project/oxc#9129.
Probably this is because of unocss plugin not working unocss/unocss#4403. |
Great!
I've fixed that yesterday so maybe it'll work if you upgrade rolldown-vite.
I'll take a look this one.
|
I've fixed the things related to warnings. I also took a look the sourcemap one. I found that the sourcemaps output by OXC are slightly different from esbuild (oxc-project/oxc#9187). But I'm not sure if that's the reason. vitest/packages/vite-node/src/client.ts Line 507 in 6cc408d
and tried to reproduce it minimally by doing // run.mjs
import 'source-map-support/register.js'
globalThis.__vite_ssr_exports__ = {}
await import('./run2.mjs')
globalThis.__vite_ssr_exports__.setup()
// ---------------------------
// run2.mjs
'use strict';function setup() {
void new Promise((_, reject) => reject(new Error("intentional unhandled rejection")));
}
Object.defineProperty(__vite_ssr_exports__, "setup", { enumerable: true, configurable: true, get(){ return setup }});
//# sourceMappingSource=vite-node
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJtYXBwaW5ncyI6IkFBQU8sU0FBUyxRQUFRO0FBQ3RCLE1BQUssSUFBSSxRQUFRLENBQUMsR0FBRyxXQUFXLE9BQU8sSUFBSSxNQUFNLG1DQUFtQztBQUNyRiIsIm5hbWVzIjpbXSwiaWdub3JlTGlzdCI6W10sInNvdXJjZXMiOlsic2V0dXAtdW5oYW5kbGVkLXJlamVjdGlvbnMudHMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGZ1bmN0aW9uIHNldHVwKCkge1xuICB2b2lkIG5ldyBQcm9taXNlKChfLCByZWplY3QpID0+IHJlamVjdChuZXcgRXJyb3IoJ2ludGVudGlvbmFsIHVuaGFuZGxlZCByZWplY3Rpb24nKSkpXG59XG4iXSwiZmlsZSI6IkQ6L2RvY3VtZW50cy9HaXRIdWIvdml0ZXN0L3Rlc3QvY29uZmlnL2ZpeHR1cmVzL3VuaGFuZGxlZC1yZWplY3Rpb25zL3NldHVwLXVuaGFuZGxlZC1yZWplY3Rpb25zLnRzIn0= But the error message showed |
Ah, I should've mentioned earlier. Source map for global setup is not supported due to Vitest side #7101. The current assertion |
Ah, I see. |
@sheremet-va How did you run this PR locally? If I added rolldown-vite overrides, some dts build is failing, for example: $ pnpm -C packages/vite-node build
src/source-map.ts(36,37): error TS7006: Parameter 'source' implicitly has an 'any' type.
[!] (plugin dts) RollupError: [plugin dts] src/source-map.ts: Failed to compile. Check the logs above.
src/source-map.ts (The odd thing is that I don't see type error red squiggles on vscode and I have no idea what's the issue) |
I added Did you build vite package? |
Hmm, I was using |
There is another difference with source maps. I am not sure if it's correct or not, I think it is caused by a difference in boundaries. This code previously had a different column: test.each([1, 2])('custom %s', () => {
// ^ previously returned this column
// ^ now returns this column
}) Raw JavaScript returns the column that Rolldown returns. We had to do |
I used the same version yesterday. Still doesn't work (tried again today). I also tried |
I think the value needs to be a resolved path instead of a unresolved specifier here. |
Ah, no, it's not that |
A rolldown plugin seems to work correctly. |
I merged rolldown/vite#82 now, so the UI should be working now. |
Can confirm it does work now: ![]() |
|
Now we get the same error with pkg.pr.new 😄 Seems like it doesn't pick up rolldown types 🤔 |
It seems
That option is disable by default. rolldown-vite uses OXC regardless of that option. |
How do you type the parse function then 🤔 |
From what I can see in the code, the transform plugin doesn’t accept any options 🤔 JSDoc also says it’s true by default |
I'm not sure, just that the
Ah, the JSDoc is incorrect. To clarify, you can pass an option via |
Slight progress. I added I pushed my hack and build passed on CI 😀 |
@@ -12,5 +12,6 @@ test('unhandled rejections of main thread are reported even when no reporter is | |||
expect(exitCode).toBe(1) | |||
expect(stderr).toContain('Unhandled Rejection') | |||
expect(stderr).toContain('Error: intentional unhandled rejection') | |||
// FIXME: this should be the correct location, but rolldown (possibly) shows 2:41 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this one is also alright. It should be fixed once we figure out global setup source map #7101.
While esbuild preserved column exactly, oxc replaced two spaces with one tab, so the transformed output became one character off from the original one.
I found the culprit of dts build error. This is because While I have mostly same setup for rolldown-vite testing PR on my plugin hi-ogawa/vite-plugins#673 where I use Here is a minimal repro of the issue https://github.com/hi-ogawa/reproductions/tree/main/rolldown-vite-rollup-plugin-dts. |
So we don't see this issue in main because we have rollup in dependencies and it makes it visible? |
Yes, I think that's the reason. It's not possible to reproduce the exact same scenario with rollup because For our case, I think either we can install |
Seems like all tests are passing, except:
And that's it 😄 |
Description
Good thing is that Vitest works with vite-rolldown for the most part (99%)
Rollup.Program
(orRolldown.Program
?)using
syntax - we are transpiling the code down to node18, but it still doesn't work (although we use theesbuild
field 🤔 ) - the test is skipped for nowexperimental.enableNativePlugin
istrue
(the default)examples/lit
decorators don't seem to work correctly:'' + import.meta.url
when transformingnew URL
to opt-out of rolldown's transform (this is an easy regexp change). Vitest also changes this transform to make the URL closer to the one that will be resolved in the browser (in node.jsimport.meta.url
refers to a file, but we need a server URL there)optimizeDeps.rollupOptions.resolve.alias
work? Browser Mode aliasesvue
packages to CJS versions testing-library is CJS (and it should import the same version of test-utils), and also we want to have the ability to use string slots and string templatesesbuildOptions
(we always check for an empty stderr and this breaks some tests):The value of
esbuildOptions
is{ preserveSymlinks: false }
and the environment name isclient
🤔This comes probably from here:
https://github.com/rolldown/vite/blob/1eee1f56ee90a08d82f465900caea6f2a618d358/packages/vite/src/node/config.ts#L1139
source maps sometimes are not correct. Seetest/config/unhandled-rejections.test.ts
- the column should be 42 (this MIGHT BE an issue with custom Vitest plugins, but it was not a problem before):Note
Seems like we always had "Re-optimizing dependencies because vite config has changed" because of incorrect usage of
cacheDir