Skip to content

Commit

Permalink
fix: windows path issues (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Aug 9, 2021
1 parent 163149c commit 4f118b6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ export default function nuxt2CompatModule () {
const nitroContext = getNitroContext(nuxt.options, nitroOptions)
const nitroDevContext = getNitroContext(nuxt.options, { ...nitroOptions, preset: 'dev' })

// Normalize Nuxt directories
for (const context of [nitroContext, nitroDevContext]) {
context._nuxt.rootDir = resolve(context._nuxt.rootDir)
context._nuxt.srcDir = resolve(context._nuxt.srcDir)
context._nuxt.buildDir = resolve(context._nuxt.buildDir)
context._nuxt.generateDir = resolve(context._nuxt.generateDir)
}

// Connect hooks
nuxt.addHooks(nitroContext.nuxtHooks)
nuxt.hook('close', () => nitroContext._internal.hooks.callHook('close'))
Expand Down
8 changes: 7 additions & 1 deletion src/rollup/plugins/externals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ export function externals (opts: NodeExternalsOptions): Plugin {
return null
}

const originalId = id

// Normalize path on windows
if (process.platform === 'win32') {
if (id.startsWith('/')) {
// Add back C: prefix on Windows
id = resolve(id)
}
id = id.replace(/\\/g, '/')
}

Expand All @@ -46,7 +52,7 @@ export function externals (opts: NodeExternalsOptions): Plugin {

// Track externals
if (opts.trace !== false) {
const resolved = await this.resolve(id, importer, { ...options, skipSelf: true }).then(r => r.id)
const resolved = await this.resolve(originalId, importer, { ...options, skipSelf: true }).then(r => r.id)
trackedExternals.add(resolved)
}

Expand Down

0 comments on commit 4f118b6

Please sign in to comment.