favware/esbuild-plugin-file-path-extensions

bug: Adds extension to imports from external package sub path

Closed this issue · 1 comments

Is there an existing issue for this?

  • I have searched the existing issues

Description of the bug

Im building a library, lets call it foo, that depends on another library bar. Bar exposes a subpath named "exportA" via its "exports"-key in the package.json. When I import stuff from the subpath "exportA" of bar in foo, e.g.

In foo src code

import { ... } from "bar/exportA"; 

this plugin updates the import in the output to the following

In foo dist

import { ... } from "bar/exportA.mjs";

Then, when using foo in a project, for example a simple vite react project I get the following vite error:

✘ [ERROR] Missing "./exportA.mjs" specifier in "bar" package [plugin vite:dep-scan]

Steps To Reproduce

  • create a package a that exposes multiple entry points with "exports" in package.json
  • import package a in another package b and bundle package b with tsup and esbuild-plugin-file-path-extensions
  • try to use package b in a vite project

Expected behavior

The plugin should only add extensions file imports and not to imports from external packages even if they use sub path exports.

Screenshots

No response

Additional context

No response

Duplicate of #6 which is still open because I as well as others cannot reproduce it. Please provide a small reproduction repository on that issue.