From 4022b8dfffc1fb11a06a4663f4c205308cc3b9ee Mon Sep 17 00:00:00 2001 From: Alessandro Di Dio Date: Thu, 25 May 2023 11:00:43 +0200 Subject: [PATCH] feat(dev): update deps.external behavior --- docs/config/index.md | 2 +- packages/vite-node/src/externalize.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/config/index.md b/docs/config/index.md index 033fa1e9751e..4c182bc173b8 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -136,7 +136,7 @@ You will not be able to edit your `node_modules` code for debugging, since the c #### deps.external - **Type:** `(string | RegExp)[]` -- **Default:** `['**/node_modules/**', '**/dist/**']` +- **Default:** `[]` 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. diff --git a/packages/vite-node/src/externalize.ts b/packages/vite-node/src/externalize.ts index fe5fc3202907..93ccbef49695 100644 --- a/packages/vite-node/src/externalize.ts +++ b/packages/vite-node/src/externalize.ts @@ -140,7 +140,7 @@ function matchExternalizePattern(id: string, patterns?: (string | RegExp)[] | tr return true for (const ex of patterns) { if (typeof ex === 'string') { - if (id.includes(`/node_modules/${ex}/`)) + if (id.includes(`/${ex.replace(/(^\/?|\/?$)/g, '')}/`)) return true } else {