Skip to content

Commit

Permalink
fix(externals): compare package paths against normalized id (#2371)
Browse files Browse the repository at this point in the history
  • Loading branch information
markthree authored Apr 29, 2024
1 parent cb4406a commit b2f4523
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/rollup/plugins/externals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,14 @@ export function externals(opts: NodeExternalsOptions): Plugin {
// Absolute path, we are not sure about subpath to generate import statement
// Guess as main subpath export
const packageEntry = await _resolve(pkgName).catch(() => null);
if (packageEntry !== originalId) {
if (packageEntry !== id) {
// Reverse engineer subpath export
const guessedSubpath: string | null | undefined =
await lookupNodeModuleSubpath(originalId).catch(() => null);
await lookupNodeModuleSubpath(id).catch(() => null);
const resolvedGuess =
guessedSubpath &&
(await _resolve(join(pkgName, guessedSubpath)).catch(() => null));
if (resolvedGuess === originalId) {
if (resolvedGuess === id) {
trackedExternals.add(resolvedGuess);
return {
id: join(pkgName, guessedSubpath!),
Expand Down

0 comments on commit b2f4523

Please sign in to comment.