From 4e49638777d0a3db590bbfbc0943f4a6bfc2a132 Mon Sep 17 00:00:00 2001 From: Guido X Jansen Date: Sun, 8 Mar 2026 01:00:43 +0100 Subject: [PATCH] fix(plugins): restore static import for proper bundling (#201) * fix(plugins): restore static import for proper bundling + add plugins to CI The variable import path from bca0280 bypassed webpack bundling, preventing the plugin module from being included in the client bundle. Restores the static import so Next.js can resolve and bundle the plugin frontend at build time. CI now clones and builds barazo-plugins (frontend only) alongside barazo-lexicons so TypeScript can resolve the workspace dependency. * fix(ci): remove plugins cache to ensure fresh clone with latest exports The cache key was based on pnpm-lock.yaml which doesn't change when plugins repo changes. Remove caching for now so CI always gets the latest plugin-signatures with explicit exports entries. * fix(ci): replace plugin symlink with copy for Turbopack compatibility Turbopack cannot follow pnpm link: symlinks outside the project root. After pnpm install creates the symlink, replace it with a real copy so Turbopack can resolve and bundle the plugin frontend modules. --- .github/actions/setup/action.yml | 17 +++++++++++++++++ src/lib/plugins/loader.ts | 19 +++---------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index e2347e3..96ee0ce 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -25,6 +25,23 @@ runs: git clone --depth 1 https://github.com/singi-labs/barazo-lexicons.git ../barazo-lexicons cd ../barazo-lexicons && pnpm install --ignore-scripts && pnpm run build + - name: Clone and build barazo-plugins (frontend only) + shell: bash + run: | + git clone --depth 1 https://github.com/singi-labs/barazo-plugins.git ../barazo-plugins + cd ../barazo-plugins && pnpm install --ignore-scripts + cd packages/plugin-signatures && npx tsc -p tsconfig.frontend.json + - name: Install dependencies shell: bash run: pnpm install --frozen-lockfile + + - name: Replace plugin symlinks for Turbopack compatibility + shell: bash + run: | + LINK=node_modules/@barazo/plugin-signatures + if [ -L "$LINK" ]; then + TARGET=$(realpath "$LINK") + rm "$LINK" + cp -r "$TARGET" "$LINK" + fi diff --git a/src/lib/plugins/loader.ts b/src/lib/plugins/loader.ts index a4275d5..3249677 100644 --- a/src/lib/plugins/loader.ts +++ b/src/lib/plugins/loader.ts @@ -20,25 +20,12 @@ function createRegistryAdapter(pluginName: string): PluginComponentRegistry { } } -// Map of bundled plugin names to their frontend register module paths. -// Dynamic import uses a variable so TypeScript doesn't statically resolve the -// module — this lets CI pass without the workspace plugin packages checked out. -const BUNDLED_PLUGIN_PATHS: Record = { - '@barazo/plugin-signatures': '@barazo/plugin-signatures/frontend/register', -} - -function pluginLoader( - modulePath: string -): () => Promise<{ register: (r: PluginComponentRegistry) => void }> { - return () => import(/* webpackIgnore: true */ modulePath) -} - const BUNDLED_PLUGINS: Record< string, () => Promise<{ register: (r: PluginComponentRegistry) => void }> -> = Object.fromEntries( - Object.entries(BUNDLED_PLUGIN_PATHS).map(([name, path]) => [name, pluginLoader(path)]) -) +> = { + '@barazo/plugin-signatures': () => import('@barazo/plugin-signatures/frontend/register'), +} let loaded = false -- 2.51.2