Conversation
…ult export A plugin module that exports its hooks as named plugin functions and also default exports an object meant for another plugin runtime never loaded. Detection treated any default export object carrying an `id` as a v1 plugin and then failed it for missing `server()`, and the legacy path rejected the same module because that default object is not a function. Detection now reports a default export without the requested kind back to the caller, and the legacy path loads the exports that are plugin functions while ignoring the rest.
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #50172
Type of change
What does this PR do?
A plugin file that exports its hooks by name and also default exports an object meant for another plugin runtime never loaded, because both load paths rejected it:
readV1Plugin(..., "detect")treated any default export object carrying anidas a v1 plugin, then threw for the missingserver(). Detection now returnsundefinedwhen the default export does not carry the requested kind, so the module falls through to the legacy path. Strict mode and the malformed-shape errors are unchanged.Plugin export is not a functionon the first export that is not a server plugin, which that default object always triggered. It now loads the plugin functions it finds, and only fails when the module exports none at all.The caller already catches and logs these failures, so the symptom was a plugin that silently did nothing.
How did you verify your code works?
bun test test/plugininpackages/opencode: 215 pass, 0 fail.bun run typecheck(tsgo --noEmit) passes.New coverage:
plugin.trigger > loads named exports next to a default export for another plugin shapebuilds a module withexport default { id, setup }plus a named hook export and asserts the hook runs. Reverting either source change makes it fail.readV1Pluginunit tests intest/plugin/shared.test.tspin the detect mode contract: a default export without the requested kind returnsundefinedin detect mode and still throws in strict mode, while malformed exports keep throwing in both modes.I also re-ran the existing object-shaped plugin tests in
test/plugin/loader-shared.test.ts, which rely on detection reading{ id, server }defaults.Screenshots / recordings
Not a UI change.
Checklist