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

fix: check path starts with deps instead of equality for subpath import support #112

Closed KaisSalha closed 3 months ago

KaisSalha commented 3 months ago

This PR adds support for handling subpath imports.

Before fix: https://github.com/KaisSalha/esbuild-plugin-file-path-extensions-bug

After fix: https://github.com/KaisSalha/esbuild-plugin-file-path-extensions-bug/tree/with-fix

favna commented 3 months ago

What do you think about using dep.split('/').at(0) instead? I have a feeling it might be more reliable considering the wide spread of package names. For example I fear that this would match both package and package-somethingelse

favna commented 3 months ago

Did you run the updated code on your branch with-fix? Because this line seems to suggest that there this doesn't full work.

https://github.com/KaisSalha/esbuild-plugin-file-path-extensions-bug/blob/74a28096f8b996d06b1e1864e1429cfe61d78783/dist/index.js#L15267

KaisSalha commented 3 months ago

@favna updated