/** * `@barefootjs/jinja/vite` — a Jinja2-specific COMPOSITION of core * `@barefootjs/vite`'s `barefoot()`, mirroring `@barefootjs/go-template/ * vite`'s, `@barefootjs/hono/vite`'s, and `@barefootjs/blade/vite`'s shape * and naming (`barefoot`, named AND default export; a user never passes * `adapter`, this constructs `JinjaAdapter` itself). * * import { barefoot } from '@barefootjs/jinja/vite' * * export default defineConfig({ * base: '/integrations/django/client/', * build: { outDir: 'dist/client' }, * plugins: barefoot({ * components: ['../shared/components', '../shared/blog'], * templates: 'dist/templates', * }), * }) * * ## Why this needs no `afterEmit`-driven type-combination step (unlike Go) * * `@barefootjs/go-template/vite` exists mainly to combine every discovered * file's `types` fragment into ONE compilable `components.go` — Go's * per-file fragments assume a shared `randomID` helper and a single package * header, so they are not independently valid Go source, and an unused * import fails the build outright (see that module's docstring). * `JinjaAdapter.generate()` never produces a `types` section at all (Jinja2 * templates have no JS-style imports/types/exports to combine — see * `jinja-adapter.ts`'s `generate()`, whose `sections.types` is always * `''`), so there is nothing across files to stitch together, and no * unused-import failure mode to guard against either. So this composition's * core job is just what core's `barefoot()` already does: construct * `JinjaAdapter` and hand it to core. * * ## No `adapterOptions` either — the other thing Go/Hono still need * * `JinjaAdapterOptions` has exactly two fields, `clientJsBasePath` and * `barefootJsPath` — and `JinjaAdapter.generateScriptRegistrations` only * falls back to them when `scriptAssets` is `undefined` (i.e. the adapter * is invoked without this Vite plugin). Core's `barefoot()` plugin ALWAYS * passes a resolved `scriptAssets` array (build: manifest-hashed; dev: * origin-based — see `plugin.ts`), so that fallback is dead code on every * Vite-driven build. * Unlike Go (`packageName`, still real) or Hono (`clientJsFilename`, still * real), Jinja has no adapter option left with any effect once Vite drives * the build — so this options interface simply omits the field rather than * plumbing through two options that would always be ignored. * * ## `assets` — the one thing this DOES need, mirroring go-template/hono/blade * * A hand-written, non-component client bootstrap (e.g. an integration's * `client/router-entry.ts`, which boots `@barefootjs/router` for the blog) * isn't a `.tsx` component, so core's own discovery/`scriptAssets` machinery * never sees it — but the compiled blog shell still needs a `