Skip to content

Improve extensibility with plugin architecture. - #11

Merged
koculu merged 2 commits into
mainfrom
feature-plugin
Oct 5, 2026
Merged

koculu merged 2 commits into
mainfrom
feature-plugin

Conversation

@koculu

@koculu koculu commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Plugins for PureStack sites

Adds a plugin system and loads it from the CLI, so a site extends PureStack without a build script of its own.

What's new

  • definePlugin: a named bundle of skins, components, templates, markdown (remark/rehype plugins), pages (generated pages), hooks, and devMiddleware. Plugins are validated when a build starts, and errors name the plugin.
  • purestack.config.ts: lives next to siteConfig.json and is loaded by build, serve, and publish. serve reloads it when the config or a local file it imports changes. Packages resolve to the copies the CLI runs.
  • Generated pages: pages() returns { path, source } entries that build like files: routes, navigation, links, partials. source is a string, or a function PureStack calls only when it needs the content, so the plugin controls memory and caching. In serve, pages regenerate when content or assets change.
  • onPageDocument hook: changes a page's DOM before it becomes HTML, and may be async. Each render gets its own document through an injectable async scope (useDomScope in ts-minidom). ts-ssg installs AsyncLocalStorage, so overlapping renders never see each other's pages. As a result, renderApp is now async.
  • Dev middleware: plugins can answer requests during serve.

Fixes and cleanup

  • A full build now prepares content once. Discovery, generators, navigation, and partials used to run twice, once at builder creation and again in buildAll.
  • Removed the global component registry mutation from renderApp, along with createDom cleanup clearing whatever document happened to be current.
  • The Studio site runs on plain purestack serve/build/publish. frontend/studio.ts is removed; studioPlugin.ts and purestack.config.ts replace it.

Docs

New Plugins guide. Updated the CLI guide, the READMEs (ts-ssg, purestack, ts-render, ts-minidom), and the incremental build notes.

Verification

  • All tests pass, including new tests for plugins, config loading, generated pages, source functions, overlapping renders, and single preparation.
  • TS7 type-check and biome are clean.
  • The Studio build output is unchanged.

@koculu
koculu merged commit 610298b into main Oct 5, 2026
2 checks passed
@koculu
koculu deleted the feature-plugin branch October 5, 2026 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant