Skip to content

Commit

Permalink
fix(factory): fix require.resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
chemzqm committed Feb 28, 2025
1 parent 4118fb2 commit 7e30334
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/util/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { createLogger } from '../logger'
import { fs, path, vm } from '../util/node'
import { hasOwnProperty, toObject } from './object'
const requireFunc = require

export interface ExtensionExport {
activate: (context: unknown) => any
Expand All @@ -24,7 +23,7 @@ export interface ILogger {

export interface IModule {
new(name: string, parent?: boolean): any
_resolveFilename: (file: string, context: any) => string
_resolveFilename: (file: string, context: any, isMain: boolean, options: any) => string
_extensions: {}
_cache: { [file: string]: any }
_compile: (content: string, filename: string) => any
Expand Down Expand Up @@ -74,7 +73,7 @@ function makeRequireFunction(this: any, cocExports: any): any {
}
return this.require(p)
}
req.resolve = requireFunc.resolve.bind(requireFunc)
req.resolve = (request, options) => Module._resolveFilename(request, this, false, options)
// request => Module._resolveFilename(request, this)
req.main = mainModule
// Enable support to add extra extension types
Expand Down

0 comments on commit 7e30334

Please sign in to comment.