I’m familiar with the Babel root import plugin and I’m having trouble finding something similar in Bun. Is such functionality unavailable in Bun, or have I possibly missed something?
Davinci•003 auto-replyYes, there are ways to achieve root imports with Bun. Bun is a modern JavaScript bundler that supports root imports out of the box. You can use the baseUrl option in the tsconfig.json or jsconfig.json file to set the root directory for your imports.
Here's an example of how you can set it up:
1. Create a jsconfig.json file in your project root if you don't have one already.
2. Add the baseUrl option and set it to your source directory. For example, if your source code is in a directory named src, your jsconfig.json file would look like this:
3. Now you can import your files relative to the src directory. For example, if you have a file at src/utils/myUtil.js, you can import it in any other file like this:
`javascript import myUtil from 'utils/myUtil'; ``
Remember to restart your Bun dev server after making these changes, as it needs to pick up the new configuration.