Skip to content

Commit

Permalink
fix(vite-node): external /dist/ by default
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Feb 18, 2022
1 parent d8267ac commit bb77e4f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/config/index.md
Expand Up @@ -57,7 +57,7 @@ Handling for dependencies inlining or externalizing
#### deps.external

- **Type:** `(string | RegExp)[]`
- **Default:** `['**\/node_modules\/**']`
- **Default:** `['**\/node_modules\/**','**\/dist\/**']`

Externalize means that Vite will bypass the package to native Node. Externalized dependencies will not be applied Vite's transformers and resolvers, so they do not support HMR on reload. Typically, packages under `node_modules` are externalized.

Expand Down Expand Up @@ -372,4 +372,4 @@ Format options for snapshot testing.
- **Type:** `string`
- **Default:** `test`

Overrides Vite mode.
Overrides Vite mode.
4 changes: 2 additions & 2 deletions packages/vite-node/src/externalize.ts
Expand Up @@ -67,15 +67,15 @@ async function _shouldExternalize(
return id

const isNodeModule = id.includes('/node_modules/')

id = isNodeModule ? guessCJSversion(id) || id : id

if (matchExternalizePattern(id, defaultInline))
return false
if (matchExternalizePattern(id, depsExternal))
return id

if (isNodeModule && await isValidNodeImport(id))
const isDist = id.includes('/dist/')
if ((isNodeModule || isDist) && await isValidNodeImport(id))
return id

return false
Expand Down
7 changes: 7 additions & 0 deletions packages/vitest/LICENSE.md
Expand Up @@ -465,6 +465,13 @@ Repository: git://github.com/kpdecker/jsdiff.git
---------------------------------------

## eastasianwidth
License: MIT
By: Masaki Komagata
Repository: git://github.com/komagata/eastasianwidth.git

---------------------------------------

## emoji-regex
License: MIT
By: Mathias Bynens
Expand Down

0 comments on commit bb77e4f

Please sign in to comment.