Skip to content

Commit

Permalink
fix: don't store temporary vite config file in node_modules if deno (
Browse files Browse the repository at this point in the history
  • Loading branch information
kazushisan authored Nov 29, 2024
1 parent e4a0ff1 commit a20267b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1858,7 +1858,13 @@ async function loadConfigFromBundledFile(
// with --experimental-loader themselves, we have to do a hack here:
// write it to disk, load it with native Node ESM, then delete the file.
if (isESM) {
const nodeModulesDir = findNearestNodeModules(path.dirname(fileName))
// Storing the bundled file in node_modules/ is avoided for Deno
// because Deno only supports Node.js style modules under node_modules/
// and configs with `npm:` import statements will fail when executed.
const nodeModulesDir =
typeof process.versions.deno === 'string'
? undefined
: findNearestNodeModules(path.dirname(fileName))
if (nodeModulesDir) {
await fsp.mkdir(path.resolve(nodeModulesDir, '.vite-temp/'), {
recursive: true,
Expand Down

0 comments on commit a20267b

Please sign in to comment.