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

Vitest + Solid testing results in dynamic import warnings #4414

Closed
1 task done
niccholaspage opened this issue Aug 22, 2022 · 1 comment
Closed
1 task done

Vitest + Solid testing results in dynamic import warnings #4414

niccholaspage opened this issue Aug 22, 2022 · 1 comment
Assignees

Comments

@niccholaspage
Copy link

What version of astro are you using?

1.0.6

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

yarn

What operating system are you using?

Windows

Describe the Bug

I have setup a brand new Astro + SolidJS project and wanted to use vitest to test out the components. I got it working but can't get rid of these dynamic import warnings that pop up whenever I run vitest:

11:01:24 PM [vite] warning: 
/home/projects/github-b2yuz1/node_modules/vitest/dist/chunk-runtime-error.1104e45a.mjs
256|    await Promise.all(files.map(async (fsPath) => {
257|      getWorkerState().moduleCache.delete(fsPath);
258|      await import(fsPath);
11:01:24 PM [vite] warning: 
/home/projects/github-b2yuz1/node_modules/vitest/dist/chunk-runtime-error.1104e45a.mjs
279|      const hash2 = browserHashMap.get(filepath);
280|      if (match)
281|        return await import(`/@fs/${filepath.slice(match[1].length)}?v=${hash2}`);
   |                            ^
282|      else
283|        return await import(`${filepath}?v=${hash2}`);
The above dynamic import cannot be analyzed by vite.
See https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations for supported dynamic import formats. If this is intended to be left as-is, you can use the /* @vite-ignore */ comment inside the import() call to suppress this warning.

  Plugin: vite:import-analysis
  File: /home/projects/github-b2yuz1/node_modules/vitest/dist/chunk-runtime-error.1104e45a.mjs
11:01:24 PM [vite] warning: 
/home/projects/github-b2yuz1/node_modules/vitest/dist/chunk-runtime-error.1104e45a.mjs
281|        return await import(`/@fs/${filepath.slice(match[1].length)}?v=${hash2}`);
282|      else
283|        return await import(`${filepath}?v=${hash2}`);
   |                            ^
284|    }
285|    for (const filepath of paths) {
The above dynamic import cannot be analyzed by vite.
See https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations for supported dynamic import formats. If this is intended to be left as-is, you can use the /* @vite-ignore */ comment inside the import() call to suppress this warning.

  Plugin: vite:import-analysis
  File: /home/projects/github-b2yuz1/node_modules/vitest/dist/chunk-runtime-error.1104e45a.mjs
11:01:24 PM [vite] warning: 
/home/projects/github-b2yuz1/node_modules/vitest/dist/chunk-runtime-error.1104e45a.mjs
302|          await importFromBrowser(filepath);
303|        else
304|          await import(filepath);
   |                       ^
305|        const defaultTasks = await defaultSuite.collect(file);
306|        setHooks(file, getHooks(defaultTasks));
The above dynamic import cannot be analyzed by vite.
See https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations for supported dynamic import formats. If this is intended to be left as-is, you can use the /* @vite-ignore */ comment inside the import() call to suppress this warning.

  Plugin: vite:import-analysis
  File: /home/projects/github-b2yuz1/node_modules/vitest/dist/chunk-runtime-error.1104e45a.mjs
 ✓ test/Counter.test.tsx (1)

Here is a StackBlitz with the issue reproduced: https://stackblitz.com/edit/github-b2yuz1

I am planning on doing some deeper digging into this to try to find the root cause of the issue, but figured someone else might have a better idea while I do that.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-b2yuz1

Participation

  • I am willing to submit a pull request for this issue.
@bluwy
Copy link
Member

bluwy commented Aug 25, 2022

This should be fixed upstream in Vite at vitejs/vite#9738, which is now released at Vite 3.1.0-beta.0. You can try it out by using yarn resolutions (if you're using yarn) to override the Vite version used by Astro.

@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Aug 25, 2022
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