Skip to content

Commit b80124d

Browse files
committed
feat: replace resolve usage with native Node resolve impl
1 parent 9c40849 commit b80124d

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

packages/nextjs/src/config/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { parseSemver } from '@sentry/core';
22
import * as fs from 'fs';
3-
import { sync as resolveSync } from 'resolve';
3+
import { createRequire } from 'module';
44

55
/**
66
* Returns the version of Next.js installed in the project, or undefined if it cannot be determined.
@@ -23,7 +23,7 @@ export function getNextjsVersion(): string | undefined {
2323

2424
function resolveNextjsPackageJson(): string | undefined {
2525
try {
26-
return resolveSync('next/package.json', { basedir: process.cwd() });
26+
return createRequire(`${process.cwd()}/`).resolve('next/package.json');
2727
} catch {
2828
return undefined;
2929
}

packages/nextjs/src/config/webpack.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
import { debug, escapeStringForRegex, loadModule, parseSemver } from '@sentry/core';
55
import * as fs from 'fs';
6+
import { createRequire } from 'module';
67
import * as path from 'path';
7-
import { sync as resolveSync } from 'resolve';
88
import type { VercelCronsConfig } from '../common/types';
99
import { getBuildPluginOptions, normalizePathForGlob } from './getBuildPluginOptions';
1010
import type { RouteManifest } from './manifest/types';
@@ -790,7 +790,7 @@ function addValueInjectionLoader({
790790

791791
function resolveNextPackageDirFromDirectory(basedir: string): string | undefined {
792792
try {
793-
return path.dirname(resolveSync('next/package.json', { basedir }));
793+
return path.dirname(createRequire(`${basedir}/`).resolve('next/package.json'));
794794
} catch {
795795
// Should not happen in theory
796796
return undefined;

0 commit comments

Comments
 (0)