-
Notifications
You must be signed in to change notification settings - Fork 16
fix: resolve Cannot find module @altimateai/altimate-core on npm install #259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -204,17 +204,26 @@ for (const item of targets) { | |
| tsconfig: "./tsconfig.json", | ||
| plugins: [solidPlugin], | ||
| sourcemap: "external", | ||
| // Packages excluded from the compiled binary — loaded lazily at runtime. | ||
| // NOTE: @altimateai/altimate-core is intentionally NOT external — it's a | ||
| // napi binary that must be bundled for the CLI to work out of the box. | ||
| // Packages excluded from the compiled binary — resolved from node_modules | ||
| // at runtime. Bun compiled binaries resolve externals via standard Node | ||
| // resolution from the binary's location, walking up to the wrapper | ||
| // package's node_modules. | ||
| // | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Key insight: external ≠ lazy without code splitting. Bun's This is why Rule of thumb for this build config: Only mark packages as external if they truly cannot be bundled (native addons like NAPI |
||
| // IMPORTANT: Without code splitting, Bun inlines dynamic import() targets | ||
| // into the main chunk. Any external require() in those targets will fail | ||
| // at startup — not when the import() is called. Only mark packages as | ||
| // external when they truly cannot be bundled (e.g. NAPI native addons). | ||
| external: [ | ||
| // dbt integration — heavy transitive deps, loaded on first dbt operation | ||
| "@altimateai/dbt-integration", | ||
| // Database drivers — users install on demand per warehouse | ||
| // NAPI native module — cannot be embedded in Bun single-file executable. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why altimate-core must be external (not bundled):
So the JS loader gets inlined but the native binary doesn't → runtime crash. Making it external + installing via npm deps is the correct approach. |
||
| // The JS loader dynamically require()s platform-specific .node binaries | ||
| // (e.g. @altimateai/altimate-core-darwin-arm64). | ||
| // Must be installed as a dependency of the published wrapper package. | ||
| "@altimateai/altimate-core", | ||
| // Database drivers — native addons, users install on demand per warehouse | ||
| "pg", "snowflake-sdk", "@google-cloud/bigquery", "@databricks/sql", | ||
| "mysql2", "mssql", "oracledb", "duckdb", "better-sqlite3", | ||
| // Optional infra packages | ||
| "keytar", "ssh2", "dockerode", "yaml", | ||
| // Optional infra packages — native addons or heavy optional deps | ||
| "keytar", "ssh2", "dockerode", | ||
| ], | ||
| compile: { | ||
| autoloadBunfig: false, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
NODE_PATH?Bun compiled binaries resolve external
require()calls from/$bunfs/root/— a virtual filesystem with nonode_modules. Standard Node resolution (walking up parent dirs from the binary's physical location) doesn't apply.NODE_PATHis the only mechanism that works across all Bun versions to inject additional module search paths into a compiled binary. Tested and confirmed working with Bun 1.3.10.Alternative considered: shipping altimate-core alongside the binary in the platform package — rejected because it would require cross-compiling the NAPI addon per-platform in our CI, which the altimate-core repo already handles via its own release pipeline.