Skip to content

Commit

Permalink
fix: add type: "module" hint to cache directory (#4063)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
sodatea and antfu committed Jul 2, 2021
1 parent 4adc970 commit 58a29b2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/vite/src/node/optimizer/index.ts
Expand Up @@ -144,6 +144,12 @@ export async function optimizeDeps(
} else {
fs.mkdirSync(cacheDir, { recursive: true })
}
// a hint for Node.js
// all files in the cache directory should be recognized as ES modules
writeFile(
path.resolve(cacheDir, 'package.json'),
JSON.stringify({ type: 'module' })
)

let deps: Record<string, string>, missing: Record<string, string>
if (!newDeps) {
Expand Down

0 comments on commit 58a29b2

Please sign in to comment.