fix(personal-server): bundle JS deps with esbuild to fix MODULE_NOT_FOUND crash#103
Open
aculich wants to merge 1 commit intovana-com:mainfrom
Open
fix(personal-server): bundle JS deps with esbuild to fix MODULE_NOT_FOUND crash#103aculich wants to merge 1 commit intovana-com:mainfrom
aculich wants to merge 1 commit intovana-com:mainfrom
Conversation
…OUND crash The personal server binary crashes on startup with: Error: Cannot find module '@opendatalabs/personal-server-ts-core/config' Root cause: The build script marks @opendatalabs/*, @hono/node-server, and hono as esbuild externals, converting their imports to require() calls in the CJS bundle. These modules are copied to dist/node_modules/ beside the binary, but two issues prevent runtime resolution: 1. pkg's virtual filesystem doesn't search beside process.execPath, and the _resolveFilename patch only redirects native addons (better-sqlite3 etc.) 2. The @opendatalabs packages only export ESM ("import" condition) — Node 22.10.0 (embedded by pkg) can't resolve ESM-only subpath exports via require() without --experimental-require-module Fix: Let esbuild bundle all JS dependencies directly (only native addons remain external). This eliminates runtime module resolution for JS packages entirely. The binary is also ~44% smaller (66MB vs 118MB) since duplicate copies in dist/node_modules/ are no longer needed. Made-with: Cursor
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.
Summary
The personal server binary crashes on startup with:
This makes the Personal Server unusable in the DataConnect v0.7.52 desktop app.
Root cause
The build script (
personal-server/scripts/build.js) marks@opendatalabs/*,@hono/node-server, andhonoas esbuild externals. This converts their ESM imports into CJSrequire()calls in the output bundle. These packages are then copied todist/node_modules/beside the binary, but two issues prevent runtime resolution:_resolveFilenamebanner patch only redirects native addons (better-sqlite3,bindings,file-uri-to-path) to look besideprocess.execPath. The runtime JS externals aren't included, so pkg's virtual filesystem never finds them.@opendatalabspackages only define"import"conditions in their exports maps — no"require"condition. Node 22.10.0 (the version embedded by pkg) cannot resolve ESM-only subpath exports viarequire()without the--experimental-require-moduleflag.Fix
Let esbuild bundle all JS dependencies directly into the CJS output. Only native addons (
better-sqlite3and its dependencies) remain external, since they require real filesystem access. This eliminates runtime module resolution for JS packages entirely.Results
dist/node_modules/copies of JS packages are no longer neededpkg.assetsconfig inpackage.jsonis cleaned up (those assets are now in the bundle)Test plan
npm installinpersonal-server/node scripts/build.jssucceeds without errorsPORT=9999 ./dist/personal-serveroutputs{"type":"ready","port":9999}Made with Cursor