From e5cf1418bc466f8a2103ed13e06d16abdc542bca Mon Sep 17 00:00:00 2001 From: Vladimir Date: Mon, 13 Nov 2023 11:26:42 +0100 Subject: [PATCH] fix(vitest): throw an error if vitest is imported using require() (#4466) --- packages/vitest/index.cjs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/vitest/index.cjs b/packages/vitest/index.cjs index e69de29bb2d1..85fc303f76c6 100644 --- a/packages/vitest/index.cjs +++ b/packages/vitest/index.cjs @@ -0,0 +1,5 @@ +throw new Error( + 'Vitest cannot be imported in a CommonJS module using require(). Please use "import" instead.' + + '\n\nIf you are using "import" in your source code, then it\'s possible it was bundled into require() automatically by your bundler. ' + + 'In that case, do not bundle CommonJS output since it will never work with Vitest, or use dynamic import() which is available in all CommonJS modules.', +)