refactor: stop bundling frontman-core into framework wrappers#707
refactor: stop bundling frontman-core into framework wrappers#707BlueHotDog wants to merge 13 commits intomainfrom
Conversation
Move @frontman-ai/frontman-core from devDependencies to dependencies in all framework wrappers (nextjs, astro, vite) and externalize it from tsup bundles. This lets npm/yarn install frontman-core and all its transitive deps (lighthouse, chrome-launcher, bindings, protocol, sury, @rescript/runtime) automatically for consumers. - Remove noExternal for workspace deps in all tsup configs - Remove re-declared transitive deps (lighthouse, chrome-launcher) from wrapper package.json dependencies - Make @frontman/bindings publishable (remove private: true) - Deduplicate repeated external lists into shared constants Closes #419 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add prepublishOnly and build scripts matching the pattern used by frontman-core and frontman-protocol, so npm publish compiles the ReScript sources before shipping. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add publish targets to bindings, frontman-core, and frontman-protocol Makefiles, and wire them into the root Makefile with a publish-deps target that runs them in dependency order (protocol → bindings → core) before publishing the framework wrappers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2849fa3 to
dd33512
Compare
…packages Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| outDir: 'dist', | ||
| clean: false, | ||
| define: { '__PACKAGE_VERSION__': JSON.stringify(pkg.version) }, | ||
| noExternal: sharedNoExternal, | ||
| external: sharedExternal, | ||
| platform: 'browser', | ||
| target: 'es2020', |
There was a problem hiding this comment.
🔴 Astro toolbar build missing noExternal — workspace deps won't be bundled for the browser
The toolbar entry point runs in the browser (platform: 'browser'), so all workspace dependencies must be bundled into the output. The PR moved workspace deps (@frontman-ai/frontman-core, @frontman/bindings, @rescript/runtime, sury, etc.) from devDependencies to dependencies in libs/frontman-astro/package.json:55-60 and simultaneously removed the noExternal list that previously forced bundling. tsup v8 auto-externalizes all packages listed in dependencies for ESM builds, so these deps will now produce bare import statements (e.g. import ... from '@frontman-ai/frontman-core') in the toolbar bundle — which will fail at runtime in the browser where there is no node_modules resolution.
The comment on line 69 even acknowledges the intent: "workspace deps must be bundled, not externalized" — but the config doesn't accomplish this. The old config (libs/frontman-astro/tsup.config.ts at base) had noExternal: sharedNoExternal on the toolbar entry to force bundling. The fix is to add noExternal back for the toolbar build to override tsup's auto-externalization of dependencies.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
The premise here is incorrect. tsup does not auto-externalize packages listed in dependencies. It uses esbuild under the hood and only externalizes what's explicitly in the external array.
The toolbar config at line 76 has external: ['astro', 'astro/toolbar'] — the workspace deps (@frontman-ai/frontman-core, @frontman/bindings, @rescript/runtime, sury, etc.) are intentionally absent from that list, so esbuild will bundle them into dist/toolbar.js. The comment on line 69 even documents this intent: "workspace deps must be bundled, not externalized".
No change needed here.
Add @frontman-ai/frontman-protocol, @frontman/bindings, @rescript/runtime, sury, and dom-element-to-component-source to runtime dependencies of astro, nextjs, and vite packages. These were marked external in tsup but undeclared, causing ERR_MODULE_NOT_FOUND in strict package managers (pnpm, Yarn PnP). Fix browser toolbar entry in frontman-astro tsup config to only externalize astro and astro/toolbar. Previously all workspace deps were externalized via sharedExternal, but the browser has no node_modules resolution — they must be bundled into dist/toolbar.js. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ckages Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
@frontman-ai/frontman-corefrom tsup bundles in all framework wrappers (nextjs, astro, vite) — moved fromnoExternaltoexternal@frontman-ai/frontman-corefromdevDependenciestodependenciesso npm/yarn installs it (and all transitive deps) automatically for consumerslighthouse,chrome-launcher) from each wrapper'spackage.json— they propagate via frontman-core@frontman/bindingspublishable — removed"private": true, added publish metadata,prepublishOnlybuild script, and Makefilefrontman-protocol,@frontman/bindings, andfrontman-corein both lib and root MakefilesPublish order
These packages must be published to npm before releasing new wrapper versions. The root Makefile now handles this via
make publish-deps(ormake publishfor everything):@frontman-ai/frontman-protocol— no workspace deps@frontman/bindings— no workspace deps@frontman-ai/frontman-core— depends on (1) and (2)nextjs,astro,vite) — depend on (3)Test plan
frontman-nextjs,frontman-astro,frontman-vite) build successfully withyarn build:bundleimportstatements for@frontman-ai/frontman-core,@rescript/runtime,sury(not inlined)npm installof each published wrapper pulls infrontman-coreand its transitive depsmake publish-depsto publish protocol, bindings, and core before releasing wrappersCloses #419
🤖 Generated with Claude Code