favware / esbuild-plugin-file-path-extensions

An esbuild plugin to automatically insert file extensions in your built JavaScript files based on the specified target
MIT License
18 stars 1 forks source link

bug: Adds extension to imports from external package sub path #101

Closed lenhosseini closed 4 months ago

lenhosseini commented 4 months ago

Is there an existing issue for this?

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

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

favna commented 4 months ago

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.