Skip to content

Commit cc4cf03

Browse files
authored
docs: add ambiguous default import from CJS section in troubleshooting (#22232)
1 parent bb5203d commit cc4cf03

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

docs/guide/troubleshooting.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,18 @@ An example of cross drive links are:
287287

288288
Related issue: [#10802](https://github.com/vitejs/vite/issues/10802)
289289

290+
### Default import unexpectedly returns an object
291+
292+
The default import returns the `module.exports` object for CJS modules, while you may expect it to return the `module.exports.default` value.
293+
294+
This may cause errors like:
295+
296+
> Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
297+
298+
> foo is not a function
299+
300+
See Rolldown's docs about this problem for more details: [Ambiguous `default` import from CJS modules - Bundling CJS | Rolldown](https://rolldown.rs/in-depth/bundling-cjs#ambiguous-default-import-from-cjs-modules).
301+
290302
<script setup lang="ts">
291303
// redirect old links with hash to old version docs
292304
if (typeof window !== "undefined") {

0 commit comments

Comments
 (0)