-
Notifications
You must be signed in to change notification settings - Fork 10
Importing a package
Aritra Karak edited this page Nov 8, 2023
·
2 revisions
In this guide, we will import the yaml
package from the hyperimport registry.
-
Create a new project with
bun init
. -
Install
hyperimport
in your project.bun i hyperimport
-
Create a new file called
bunfig.toml
and add the preload script.preload = ["./node_modules/hyperimport/preload.ts"]
-
Add the yaml package to the config below that.
[hyperimport] packages = ["yaml"]
-
Create a new file called
data.yml
with the following data.name: Fast X releaseYear: 2023
-
Inside index.ts import this file.
import data from "./data.yml"; console.log(data);
-
Finally, run
bun .
to execute it. -
For the first run, hyperimport will automatically fetch and install the package hence it might take some time and when done, it will display the contents successfully.
-
Now next time when
bun .
is ran, hyperimport will used the cached package and instantly print the contents of data.yml.
To reinstall packages, simply run bunx hyperimport i
.