diff --git a/playground/optimize-deps/cjs-dynamic.js b/playground/optimize-deps/cjs-dynamic.js index 616dffae4d6c0c..69c11051692272 100644 --- a/playground/optimize-deps/cjs-dynamic.js +++ b/playground/optimize-deps/cjs-dynamic.js @@ -22,7 +22,11 @@ } const cjsFromCJS = await import('@vitejs/test-dep-cjs-compiled-from-cjs') - if (typeof cjsFromCJS.default === 'function') { + if ( + typeof cjsFromCJS.default === 'function' && + typeof cjsFromCJS !== 'function' && + cjsFromCJS.bar === 'bar' + ) { text('.cjs-dynamic-dep-cjs-compiled-from-cjs', 'ok') } diff --git a/playground/optimize-deps/cjs.js b/playground/optimize-deps/cjs.js index f0201008647889..cd26c373a4765a 100644 --- a/playground/optimize-deps/cjs.js +++ b/playground/optimize-deps/cjs.js @@ -7,6 +7,7 @@ import { Socket } from 'phoenix' import clip from 'clipboard' import cjsFromESM from '@vitejs/test-dep-cjs-compiled-from-esm' import cjsFromCJS from '@vitejs/test-dep-cjs-compiled-from-cjs' +import * as cjsFromCJSNamespace from '@vitejs/test-dep-cjs-compiled-from-cjs' // Test exporting a name that was already imported export { useState } from 'react' @@ -25,7 +26,11 @@ if (typeof cjsFromESM === 'function') { text('.cjs-dep-cjs-compiled-from-esm', 'ok') } -if (typeof cjsFromCJS === 'function') { +if ( + typeof cjsFromCJS === 'function' && + typeof cjsFromCJSNamespace !== 'function' && + cjsFromCJSNamespace.bar === 'bar' +) { text('.cjs-dep-cjs-compiled-from-cjs', 'ok') } diff --git a/playground/optimize-deps/dep-cjs-compiled-from-cjs/index.js b/playground/optimize-deps/dep-cjs-compiled-from-cjs/index.js index 38d4c85c7c33ce..bb78ebd1f162bd 100644 --- a/playground/optimize-deps/dep-cjs-compiled-from-cjs/index.js +++ b/playground/optimize-deps/dep-cjs-compiled-from-cjs/index.js @@ -2,4 +2,5 @@ function foo() { return 'foo' } +foo.bar = 'bar' module.exports = foo