fix(plugin-sdk): scaffold one SDK specifier, not two - #391
Open
lovepixel-git wants to merge 1 commit into
Open
Conversation
`instatic-plugin init <name> --kind content-editor` generates a two-file plugin that imports the SDK two different ways: instatic-plugin.config.ts → '@core/plugin-sdk' server/index.ts → '@instatic/plugin-sdk' Verified by scaffolding it. `@core/plugin-sdk` resolves through this repo's tsconfig `paths`; `@instatic/plugin-sdk` resolves nowhere, because there is no such published package and no alias for it. So one of the two files a fresh content-editor plugin ships with cannot resolve its import. The server entry now matches its sibling. That makes the scaffold self-consistent and working in-tree today, which is what CoreBunch#384 reports tripping over. Also documents the underlying constraint in the hot-sync section: neither specifier is a published package, so an out-of-tree plugin repo has to point at the SDK source directly until it ships to a registry. That was the other half of the report, and it is the part a doc can fix without pre-deciding whether the package gets published. Refs CoreBunch#384
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.
Refs #384. The report is about
@instatic/plugin-sdknot resolving. Chasing it down turned up something a bit worse: the scaffold emits two different specifiers, and one of them resolves nowhere.Reproduced
produces exactly two source files:
@core/plugin-sdkresolves through this repo'stsconfig.jsonpaths.@instatic/plugin-sdkresolves nowhere:node_modules/@instaticdoes not exist,package.jsonis namedinstaticwith noexportsmap, and there is no@instatic/*path alias. So one of the two files in a fresh content-editor plugin cannot resolve its import even inside the monorepo.init.tsemits@core/plugin-sdkin three templates and@instatic/plugin-sdkin exactly one, so this reads as an oversight rather than intent.Change
Two things, both small.
The scaffold now emits one specifier.
serverEntryTemplatematches its sibling, so a scaffolded content-editor plugin resolves in-tree today.The docs get the constraint stated in the "Local dev with hot sync" section, which is already the place that handles out-of-tree setup for
INSTATIC_UPLOADS_DIR. Neither specifier is a published package, so a plugin repo outside an Instatic checkout has to point at the SDK source; the reporter's env-var indirection module is a reasonable shape for that.One thing that is yours to decide
I did not touch the three
@instatic/plugin-sdkexamples in the docs (lines ~970, ~1030, ~1064) or the SDK builder docstrings, because they are only wrong until you publish the package, and right the moment you do. Rewriting them to@core/plugin-sdkwould make them accurate today and wrong later.The same tension applies to the scaffold fix, and it is why I framed it as consistency rather than as choosing a specifier: two files should not disagree, and matching the one that resolves is the option that works now. If you would rather publish
@instatic/plugin-sdkand move the other three templates onto it, that inverts this diff and I am glad to send that instead — it is the nicer end state for anyone distributing a plugin, since it also makesbun testwork on plugin sources without a full CMS checkout.Verification
bun run lintcleanbunx tsc -bexit 0src/__tests__/pluginspass