Skip to content

Commit

Permalink
feat: support VITE_NODE_DEPS_MODULE_DIRECTORIES from .npmrc (#3471)
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed May 30, 2023
1 parent d65f287 commit 393bf60
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions .npmrc
Expand Up @@ -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/
10 changes: 5 additions & 5 deletions package.json
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion packages/vite-node/src/server.ts
Expand Up @@ -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)
}
Expand Down

0 comments on commit 393bf60

Please sign in to comment.