From 69f1622c170b09822106bf962d5967a9acfa82f8 Mon Sep 17 00:00:00 2001 From: AriPerkkio Date: Tue, 30 May 2023 18:13:46 +0300 Subject: [PATCH] feat: support VITE_NODE_DEPS_MODULE_DIRECTORIES from .npmrc --- .npmrc | 1 + package.json | 10 +++++----- packages/vite-node/src/server.ts | 4 +++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.npmrc b/.npmrc index 858516285c60..0d2900e898ad 100644 --- a/.npmrc +++ b/.npmrc @@ -2,3 +2,4 @@ ignore-workspace-root-check=true strict-peer-dependencies=false shell-emulator=true registry=https://registry.npmjs.org/ +VITE_NODE_DEPS_MODULE_DIRECTORIES=/node_modules/,/packages/ diff --git a/package.json b/package.json index e970b851861f..11ba7e04232f 100644 --- a/package.json +++ b/package.json @@ -19,11 +19,11 @@ "lint": "eslint --cache .", "lint:fix": "nr lint --fix", "release": "bumpp package.json packages/*/package.json --commit --push --tag && pnpm -r publish --access public", - "test": "VITE_NODE_DEPS_MODULE_DIRECTORIES=/node_modules/,/packages/ vitest --api -r test/core", - "test:run": "VITE_NODE_DEPS_MODULE_DIRECTORIES=/node_modules/,/packages/ vitest run -r test/core", - "test:all": "VITE_NODE_DEPS_MODULE_DIRECTORIES=/node_modules/,/packages/ CI=true pnpm -r --stream run test --allowOnly", - "test:ci": "VITE_NODE_DEPS_MODULE_DIRECTORIES=/node_modules/,/packages/ CI=true pnpm -r --stream --filter !test-fails --filter !test-browser --filter !test-esm --filter !test-browser run test --allowOnly", - "test:ci:single-thread": "VITE_NODE_DEPS_MODULE_DIRECTORIES=/node_modules/,/packages/ CI=true pnpm -r --stream --filter !test-fails --filter !test-coverage --filter !test-watch --filter !test-bail --filter !test-esm --filter !test-browser run test --allowOnly --no-threads", + "test": "vitest --api -r test/core", + "test:run": "vitest run -r test/core", + "test:all": "CI=true pnpm -r --stream run test --allowOnly", + "test:ci": "CI=true pnpm -r --stream --filter !test-fails --filter !test-browser --filter !test-esm --filter !test-browser run test --allowOnly", + "test:ci:single-thread": "CI=true pnpm -r --stream --filter !test-fails --filter !test-coverage --filter !test-watch --filter !test-bail --filter !test-esm --filter !test-browser run test --allowOnly --no-threads", "typecheck": "tsc --noEmit", "typecheck:why": "tsc --noEmit --explainFiles > explainTypes.txt", "ui:build": "vite build packages/ui", diff --git a/packages/vite-node/src/server.ts b/packages/vite-node/src/server.ts index f468f51da063..e1eb6f5a4563 100644 --- a/packages/vite-node/src/server.ts +++ b/packages/vite-node/src/server.ts @@ -67,7 +67,9 @@ export class ViteNodeServer { this.debugger = new Debugger(server.config.root, options.debug!) options.deps.moduleDirectories ??= [] - const customModuleDirectories = process.env.VITE_NODE_DEPS_MODULE_DIRECTORIES?.split(',') + + const envValue = process.env.VITE_NODE_DEPS_MODULE_DIRECTORIES || process.env.npm_config_VITE_NODE_DEPS_MODULE_DIRECTORIES + const customModuleDirectories = envValue?.split(',') if (customModuleDirectories) options.deps.moduleDirectories.push(...customModuleDirectories) }