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

Vite 6: The "path" argument must be of type string. Received an instance of RegExp #18875

Closed
7 tasks done
marekdedic opened this issue Dec 3, 2024 · 3 comments
Closed
7 tasks done

Comments

@marekdedic
Copy link

marekdedic commented Dec 3, 2024

Describe the bug

Hi,
I'm trying to update my plugin to Vite v6 (marekdedic/rollup-plugin-htaccess#170), however, I'm encoutering issues with my tests on Vite 6.

Reproduction

https://github.com/marekdedic/vite-6-path-issue-repro

Steps to reproduce

  1. npm ci
  2. npm test

System Info

System:
    OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i7-1265U
    Memory: 6.57 GB / 15.23 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 22.11.0 - /usr/bin/node
    Yarn: 1.22.21 - /usr/bin/yarn
    npm: 10.9.1 - /usr/bin/npm
  npmPackages:
    vite: ^6.0.2 => 6.0.2

Used Package Manager

npm

Logs

No response

Validations

@sapphi-red
Copy link
Member

sapphi-red commented Dec 4, 2024

It seems this is a bug in jest. This line is returning false when id is /node_modules/.
https://github.com/rollup/plugins/blob/92daef00b0da30de172868d4e0792c8686da0045/packages/pluginutils/src/createFilter.ts#L30

test("Minimal", async () => {
  const defaultExclude = /node_modules/;
  expect(defaultExclude instanceof RegExp).toBe(true); // ok
  expect(structuredClone(defaultExclude) instanceof RegExp).toBe(true); // error
});

This is the minimal reproduction case. Maybe jestjs/jest#2549?

I'm open to changing this line to new RegExp(value) to avoid structuredClone.

return structuredClone(value) as DeepWritable<T>

I guess this would avoid the error happening.

BTW it seems the test above works with Vitest.

@marekdedic
Copy link
Author

Thanks, I tried to open a specific issue in jest as the one you linked seems to be about a much more general behaviour. Let's see if that yields anything

@sapphi-red
Copy link
Member

sapphi-red commented Jan 14, 2025

I'll close this issue for now as this isn't a bug in Vite. But I'm still open to changing the line mentioned above, so if someone is interested, feel free to open a PR that changes the line.

@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Jan 14, 2025
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

2 participants