https://github.com/codehz/bun-allow-macros
https://github.com/codehz/bun-allow-macros
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/codehz/bun-allow-macros
- Owner: codehz
- Created: 2024-08-14T04:02:15.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-14T07:01:58.000Z (over 1 year ago)
- Last Synced: 2025-02-18T07:56:21.292Z (about 1 year ago)
- Language: TypeScript
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# bun-allow-macros
Due to bun doesn't allow run macros from node_modules, I created a plugin to disable this check.
However, the bun handle plugin differently in runtime and build, I have to made two different api for runtime and build.
For build:
```js
import { AllowMacros } from "bun-allow-macros"
Bun.build({
// other props
plugins: [AllowMacros(path => import.meta.resolve(path), "you-library")]
})
```
For runtime:
```js
import { AllowMacrosRuntime } from "bun-allow-macros"
Bun.plugin(AllowMacrosRuntime(path => import.meta.resolve(path), "you-library"))
```
## Caveats
1. this library use some special logic for relative import, it may not work well.
2. for build plugin, the package name needs to be the name used for the actual import (this may be changed by the paths in tsconfig.json)