refactor: replace createRequire with import.meta.resolve in config-loader and gitLoader

This commit is contained in:
saberzero1
2026-07-27 20:47:51 +02:00
parent 508f73a33f
commit 41864a0eba
2 changed files with 4 additions and 6 deletions
+2 -3
View File
@@ -4,7 +4,7 @@ import { execSync } from "child_process"
import git from "isomorphic-git"
import http from "isomorphic-git/http/node"
import { styleText } from "util"
import { createRequire } from "module"
import { fileURLToPath } from "node:url"
import { pathToFileURL } from "url"
import { PluginSource } from "./types"
@@ -990,8 +990,7 @@ export async function regeneratePluginIndex(
for (const npmPkg of options.npmPackages ?? []) {
let distIndex: string | undefined
try {
const esmRequire = createRequire(import.meta.url)
const pkgJsonPath = esmRequire.resolve(`${npmPkg}/package.json`)
const pkgJsonPath = fileURLToPath(import.meta.resolve(`${npmPkg}/package.json`))
distIndex = path.join(path.dirname(pkgJsonPath), "dist", "index.d.ts")
} catch {
if (options.verbose) {