Folder extensions can't import packages from their own node_modules in the compiled binary ("Cannot find package")
What happened?
The rendered-markdown example extension fails to load in the compiled hunk binary:
Extension rendered-markdown failed to load • Cannot find package 'marked' imported from /Users/<me>/.config/hunk/extensions/rendered-markdown/index.tsmarked is installed in the extension's own node_modules, which the folder extension docs say is supported.
Environment: macOS 26 (Darwin 25.6.0, arm64), Ghostty 1.3.2, zsh. hunkdiff is installed globally with Bun 1.4.2 (it runs the hunkdiff-darwin-arm64 binary). config.toml has no [extensions] settings.
Workaround: Importing by relative path loads fine, and F8 renders the Markdown:
import { Lexer, type Token, type Tokens } from "./node_modules/marked/lib/marked.esm.js";Suspected cause (unconfirmed): registerHostRuntimeModules (packages/hunk/src/extensions/hostRuntimeModules.ts) serves extension files through a Bun.plugin onLoad hook that returns transpiled contents. My guess is that inside a bun build --compile binary, bare specifiers in that returned code aren't resolved from the importing file's directory, while relative ones are. The folder-local node_modules coverage from #606 may only run from source.
Steps to reproduce
git clone --depth 1 https://github.com/modem-dev/hunk
mkdir -p ~/.config/hunk/extensions
cp -R hunk/examples/extensions/rendered-markdown ~/.config/hunk/extensions/
(cd ~/.config/hunk/extensions/rendered-markdown && bun install) # installs [email protected]
cd "$(mktemp -d)"
printf '# Hi\n\nold\n' > before.md
printf '# Hi\n\n**new** text\n' > after.md
hunk diff --files before.md after.mdThe load error appears in the status bar, and F8 does nothing.
Expected behavior
The extension loads, and F8 (View → File presentation: Rendered Markdown) shows the rendered Markdown view.
Version
0.23.0
Source: modem-dev/hunk