Skip to content

Commit c8f9826

Browse files
committed
Inline function to avoid mutating params
1 parent 6138634 commit c8f9826

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

packages/esbuild-plugin-node/src/plugin.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,6 @@ export function openTelemetryPlugin(
115115
};
116116
}
117117

118-
// @see https://github.com/nodejs/node/issues/47000
119-
function dotFriendlyResolve(path: string, directory: string): string {
120-
if (path === '.') {
121-
path = './';
122-
} else if (path === '..') {
123-
path = '../';
124-
}
125-
return require.resolve(path, { paths: [directory] });
126-
}
127-
128118
/**
129119
* For a given full path to a module,
130120
* return the package name it belongs to and the local path to the module
@@ -135,7 +125,11 @@ function extractPackageAndModulePath(
135125
path: string,
136126
resolveDir: string
137127
): { path: string; extractedModule: ExtractedModule } {
138-
const fullPath = dotFriendlyResolve(path, resolveDir);
128+
// @see https://github.com/nodejs/node/issues/47000
129+
const fullPath = require.resolve(
130+
path === '.' ? './' : path === '..' ? '../' : path,
131+
{ paths: [resolveDir] }
132+
);
139133

140134
const nodeModulesIndex = fullPath.lastIndexOf(NODE_MODULES);
141135
if (nodeModulesIndex < 0) {

0 commit comments

Comments
 (0)