Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throws error for imported assets #3

Open
vveisard opened this issue Oct 14, 2023 · 1 comment
Open

Throws error for imported assets #3

vveisard opened this issue Oct 14, 2023 · 1 comment

Comments

@vveisard
Copy link

vveisard commented Oct 14, 2023

This plugin throws an error when resolving imported assets as described by the Bun documentation here:

Files

  • ./index.ts
  • ./desert/background.png
// index.ts
import desertViewTowerUrl from './desert/background.jpg'

Output

error TS2307: Cannot find module './desert/background.jpg' or its corresponding type declarations.

Expected Behavior

I would expect this plugin to skip anything that Bun considers to be an asset.

@fivepixels
Copy link

I guess this problem has already been resolved, but just for you,

  1. This is not a problem with this plugin.

This plugin is just for people who want to use the features from dts bundle generator but in Bun. This project just kind of imports all features that we can normally use with that dts bundle generator and imports it as a Bun plugin. That is also the reason why the options in this project look pretty similar to the options in the dts bundle generator, except that we have to put the dts() call stuff inside of the plugins. If you still think there is a problem with this after reading the next thing, then you will have to make an issue on the official repository that this project uses.

  1. You have to write all codes manually again.

If you look at Next.js or any other famous TypeScript frameworks, you will be able to see their tremendous works of just importing all types that the developers might have to use and exporting all imported types again from one file, like this, or this. Also, they never import any files with JPG, PNG or any other images/videos/or assets types because it is impossible to make TypeScript types for them. So, what you probably have to do is to reimport all types, reexport them in a single file without files with those extensions, set that file as the entry point, and run the script for Bun. And do not forget to add this path ./dist/index.d.ts or whatever you set it as to the "types" field in your package.json so that the final file can also be exported out of the node_modules folder.

If you have any questions or something, please comment below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants