Skip to content

Commit

Permalink
fix(cache): driver not found with file:// (#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux authored Oct 14, 2024
1 parent da685df commit 8d28e5d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 34 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"ofetch": "^1.4.1",
"pathe": "^1.1.2",
"pkg-types": "^1.2.1",
"std-env": "^3.7.0",
"ufo": "^1.5.4",
"uncrypto": "^0.1.3",
"unstorage": "^1.12.0",
Expand Down
46 changes: 13 additions & 33 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/features.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { execSync } from 'node:child_process'
import { pathToFileURL } from 'node:url'
import { isWindows } from 'std-env'
import type { Nuxt } from '@nuxt/schema'
import { join } from 'pathe'
import { logger, addImportsDir, addServerImportsDir, addServerScanDir, createResolver } from '@nuxt/kit'
Expand Down Expand Up @@ -153,7 +154,9 @@ export async function setupBrowser(nuxt: Nuxt) {
export async function setupCache(nuxt: Nuxt) {
// Add Server caching (Nitro)
let driver = await resolvePath('./runtime/cache/driver')
driver = pathToFileURL(driver).href
if (isWindows) {
driver = pathToFileURL(driver).href
}
nuxt.options.nitro = defu(nuxt.options.nitro, {
storage: {
cache: {
Expand Down
3 changes: 3 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ export default defineNuxtModule<ModuleOptions>({
if (!nuxt.options.nitro.unenv.external.includes('node:stream')) {
nuxt.options.nitro.unenv.external.push('node:stream')
}
if (!nuxt.options.nitro.unenv.external.includes('node:process')) {
nuxt.options.nitro.unenv.external.push('node:process')
}

// Add the env middleware
nuxt.options.nitro.handlers ||= []
Expand Down

0 comments on commit 8d28e5d

Please sign in to comment.