Skip to content

Commit

Permalink
refactor: rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Dec 8, 2022
1 parent 9f7561b commit c231902
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions packages/vite-node/src/client.ts
Expand Up @@ -231,14 +231,14 @@ export class ViteNodeRunner {
}

/** @internal */
async directRequest(id: string, fsPath: string, _callstack: string[]) {
const moduleId = normalizeModuleId(fsPath)
async directRequest(id: string, url: string, _callstack: string[]) {
const moduleId = normalizeModuleId(url)
const callstack = [..._callstack, moduleId]

const mod = this.moduleCache.get(fsPath)
const mod = this.moduleCache.get(url)

const request = async (dep: string) => {
const depFsPath = await this.resolveUrl(dep, fsPath)
const depFsPath = await this.resolveUrl(dep, url)
return this.dependencyRequest(dep, depFsPath, callstack)
}

Expand All @@ -247,7 +247,7 @@ export class ViteNodeRunner {
return requestStubs[id]

// eslint-disable-next-line prefer-const
let { code: transformed, externalize } = await this.options.fetchModule(fsPath)
let { code: transformed, externalize } = await this.options.fetchModule(url)

if (externalize) {
debugNative(externalize)
Expand All @@ -259,10 +259,10 @@ export class ViteNodeRunner {
if (transformed == null)
throw new Error(`[vite-node] Failed to load "${id}" imported from ${callstack[callstack.length - 2]}`)

const file = cleanUrl(moduleId)
const modulePath = cleanUrl(moduleId)
// disambiguate the `<UNIT>:/` on windows: see nodejs/node#31710
const url = pathToFileURL(file).href
const meta = { url }
const href = pathToFileURL(modulePath).href
const meta = { url: href }
const exports = Object.create(null)
Object.defineProperty(exports, Symbol.toStringTag, {
value: 'Module',
Expand Down Expand Up @@ -291,7 +291,7 @@ export class ViteNodeRunner {
})

Object.assign(mod, { code: transformed, exports })
const __filename = fileURLToPath(url)
const __filename = fileURLToPath(href)
const moduleProxy = {
set exports(value) {
exportAll(cjsExports, value)
Expand All @@ -308,7 +308,7 @@ export class ViteNodeRunner {
Object.defineProperty(meta, 'hot', {
enumerable: true,
get: () => {
hotContext ||= this.options.createHotContext?.(this, `/@fs/${fsPath}`)
hotContext ||= this.options.createHotContext?.(this, `/@fs/${url}`)
return hotContext
},
})
Expand All @@ -327,7 +327,7 @@ export class ViteNodeRunner {
__vite_ssr_import_meta__: meta,

// cjs compact
require: createRequire(url),
require: createRequire(href),
exports: cjsExports,
module: moduleProxy,
__filename,
Expand Down

0 comments on commit c231902

Please sign in to comment.