Skip to content

Commit

Permalink
docs: update deps.interopDefault section
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jan 21, 2023
1 parent 44e5e22 commit a5ec633
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/config/index.md
Expand Up @@ -128,7 +128,7 @@ If disabled, your `alias` and `<plugin>.resolveId` won't affect imports inside e
#### deps.interopDefault

- **Type:** `boolean`
- **Default:** `false` if `environment` is `node`, `true` otherwise
- **Default:** `true`

Interpret CJS module's default as named exports. Some dependencies only bundle CJS modules and don't use named exports that Node.js can statically analyze when a package is imported using `import` syntax instead of `require`. When importing such dependencies in Node environment using named exports, you will see this error:

Expand All @@ -139,14 +139,14 @@ SyntaxError: Named export 'read' not found. The requested module 'fs-jetpack' is
CommonJS modules can always be imported via the default export.
```

Vitest doesn't do static analysis, and cannot fail before your running code, so you will most likely see this error when running tests:
Vitest doesn't do static analysis, and cannot fail before your running code, so you will most likely see this error when running tests, if this feature is disabled:

```
TypeError: createAsyncThunk is not a function
TypeError: default is not a function
```

If you are using bundlers or transpilers that bypass this Node.js limitation, you can enable this option manually. By default, Vitest assumes you are using Node ESM syntax, when `environment` is `node`, and doesn't interpret named exports.
By default, Vitest assumes you are using a bundler to bypass this and will not fail, but you can disable this behaviour manually, if you code is not processed.

### benchmark

Expand Down

0 comments on commit a5ec633

Please sign in to comment.