Closed j4w8n closed 2 months ago
Think I figured out this issue. I believe it's because I'm using a third-party plugin for use in "dev" mode, to do one thing, and also in "build" mode to do another.
So, for runtime (dev) I have the plugin setup in a file called bun.plugin.ts; and this is referenced for preload in bunfig.toml. But, since I also need that plugin at buildtime, I have a typescript file called bun.build.ts that uses Bun.build()
because this is currently the only way to use plugins at buildtime. Then, I have package.json script that executes the typescript file, to do the build.
This setup causes the plugin to run twice - first because the bunfig.toml preload runs it, since I'm executing a typescript file to trigger the build; then a second time when included with the Bun.build config. The TypeError is triggered on the preload run, since config doesn't actually exist in this case.
What version of Bun is running?
1.1.26+0a37423ba
What platform is your computer?
Linux 5.15.153.1-microsoft-standard-WSL2 x86_64 x86_64
What steps can reproduce the bug?
I'm building a third-party plugin and testing it in another package, using
bun link
. I build the project usingbun run build
, with a package.json script of"build": "bun run ./bun.build.ts"
.The relevant plugin code is:
What is the expected behavior?
The value of
build.config.outdir
should be logged.What do you see instead?
Additional information
If I instead make config optional, with
console.log('build', build.config?.outdir)
, everything works fine. But since theconfig
is required in the type, I'm not expecting to have to do this to get it to work.