Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions personal-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@
"build": "node scripts/build.js"
},
"pkg": {
"assets": [
"node_modules/@opendatalabs/personal-server-ts-*/dist/**/*",
"node_modules/@opendatalabs/personal-server-ts-*/package.json",
"node_modules/@hono/node-server/dist/**/*",
"node_modules/@hono/node-server/package.json",
"node_modules/hono/**/*"
],
"targets": [
"node22-macos-arm64",
"node22-macos-x64",
Expand Down
34 changes: 6 additions & 28 deletions personal-server/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,15 @@ async function build() {
// Also provide import.meta.url shim for ESM code bundled to CJS
// Must redirect better-sqlite3, bindings, and file-uri-to-path to external node_modules
const nativeModulesList = ['better-sqlite3', 'bindings', 'file-uri-to-path'];
const runtimeExternalModules = [
'@opendatalabs/personal-server-ts-core/config',
'@opendatalabs/personal-server-ts-server',
'@opendatalabs/personal-server-ts-mcp',
'@hono/node-server',
'hono',
];
const nativeBanner = [
'var _M=require("module"),_P=require("path"),_U=require("url"),_R=_M._resolveFilename;',
// Shim for import.meta.url
'if(typeof globalThis.__importMetaUrl==="undefined"){globalThis.__importMetaUrl=_U.pathToFileURL(__filename).href;}',
// Patch require resolution for native modules
// _resolveFilename(request, parent, isMain, options) - paths goes in options (4th param)
// Patch require resolution so native addons load from beside the executable
`var _NM=${JSON.stringify(nativeModulesList)};`,
'var _np=_P.join(_P.dirname(process.execPath),"node_modules");',
'_M._resolveFilename=function(r,p,m,o){',
'if(_NM.includes(r)){var _np=_P.join(_P.dirname(process.execPath),"node_modules");',
'if(_NM.includes(r)){',
'try{return _R.call(this,r,p,m,Object.assign({},o||{},{paths:[_np]}));}catch(e){}}',
'return _R.call(this,r,p,m,o);};',
].join('');
Expand Down Expand Up @@ -174,7 +167,7 @@ async function build() {
platform: 'node',
format: 'cjs',
outfile: bundlePath,
external: runtimeExternalModules,
external: nativeModulesList,
plugins: [inlinePackageJsonPlugin, dynamicNativeRequirePlugin],
banner: { js: nativeBanner },
inject: [shimPath],
Expand Down Expand Up @@ -211,23 +204,8 @@ async function build() {
}
}

const runtimePackagesToCopy = [
'@opendatalabs/personal-server-ts-core',
'@opendatalabs/personal-server-ts-server',
'@opendatalabs/personal-server-ts-mcp',
'@hono/node-server',
'hono',
];
for (const mod of runtimePackagesToCopy) {
const src = join(ROOT, 'node_modules', ...mod.split('/'));
if (existsSync(src)) {
const dest = join(DIST, 'node_modules', ...mod.split('/'));
log(`Copying ${mod}...`);
cpSync(src, dest, { recursive: true });
} else {
log(`WARNING: ${mod} not found in node_modules`);
}
}
// @opendatalabs/*, @hono/node-server, and hono are bundled by esbuild
// (no longer external), so no copy step is needed for them.

// Re-download the better-sqlite3 prebuilt binary for the pkg target Node version.
// The local npm install compiles for the host Node.js, which may differ from the
Expand Down