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

TypeError: Cannot read properties of undefined (reading 'length'), error when using with vitest #30

Closed
chandu opened this issue Apr 24, 2024 · 4 comments

Comments

@chandu
Copy link

chandu commented Apr 24, 2024

Hi,
Thanks for this plugin.
I have been using this in one of my projects without any issuess untill recent past with vitest/vite.

However I have upgraded the plguin version from 7.0.1 to 7.1.1 and since then when I run the vitest run or vitest, I am getting the error TypeError: Cannot read properties of undefined (reading 'length'), (thrown in the resolveId call) and the process is exiting.

The same code is working fine with v 7.0.1 of this plugin.
I think the introduction of the 'order': 'pre' of the resolveId function could be triggering this. https://github.com/Septh/rollup-plugin-node-externals/blob/main/source/index.ts#L231

Stackblitz with v7.0.1 works fine: https://stackblitz.com/edit/vitest-dev-vitest-ydhtdg?file=package.json

Stackblitz with v7.1.1 fails: https://stackblitz.com/edit/vitest-dev-vitest-jlcazj?file=package.json

@Septh
Copy link
Owner

Septh commented Apr 25, 2024

That's odd. I'm going to investigate this.
Thanks for reporting!

@Septh Septh closed this as completed in 5a5a9b1 Apr 25, 2024
@Septh
Copy link
Owner

Septh commented Apr 25, 2024

So it seems that vitest calls the resolvedId hook before the buildStart hook, resulting in the include and exclude arrays being used before they are initialized.

I'm not sure whether this is vitest or vite misbehaving but this is clearly a bug on one of these tools. I'll need to further investigate before I file an issue to the relevant repo.

Meanwhile, I just published version 7.1.2 that has a workaround for this.

Thanks again.

@Septh
Copy link
Owner

Septh commented Apr 25, 2024

@chandu
Copy link
Author

chandu commented Apr 25, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants