fix(build): externalize node:* in the Vite lib build so CLI bundles work - #159
Merged
Conversation
Vite's library build bundled `node:*` imports into its browser-external stub
(an empty default export). That left `await import('node:fs/promises')` in the
optional CLI entry resolving to `undefined`, so the published
`bquery-view-compile` CLI crashed at runtime ("e is not a function").
Mark `node:*` as external in `rollupOptions` so those imports are emitted
verbatim and resolved by Node at runtime. Browser entries never import
`node:*`, so this is a no-op for them.
Verified: rebuilt `dist`, the browser-external stub is gone from
`dist/view-compiler.es.mjs` (0 references), and `bquery-view-compile` runs
end-to-end against the built bundle.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Problem
Vite's library build bundled
node:*imports into its browser-external stub (an empty default export). That leftawait import('node:fs/promises')in the optional CLI entry resolving toundefined, so the publishedbquery-view-compileCLI crashed at runtime withe is not a functionwhen run against thedistbuild.Fix
Mark
node:*as external inrollupOptionsso those imports are emitted verbatim and resolved by Node at runtime:Browser entries never import
node:*, so this is a no-op for them.Verification
dist; thevite-browser-externalstub is gone fromdist/view-compiler.es.mjs(0 references, was 1).bquery-view-compile --out-dir … file.htmlruns end-to-end against the built bundle (1/1 compiled).Note
This is the standalone hotfix for
dev. The same one-line change is also present in the stable-graduation PR #157 (which introduces thebquery-i18nCLI that surfaced the bug); since the change is byte-identical, the branches reconcile cleanly when both land — or the line can be dropped from #157 once this merges.🤖 Generated with Claude Code