fix(tui): map .js imports to .ts sources in esbuild bundle - #454
Open
hashbender wants to merge 1 commit into
Open
fix(tui): map .js imports to .ts sources in esbuild bundle#454hashbender wants to merge 1 commit into
hashbender wants to merge 1 commit into
Conversation
|
Review Complete Risk: 🟡 Medium (25/100) — no findings · 34 LOC across 1 file Adds a jsToTsPlugin to the esbuild configuration in ui-tui/scripts/build.mjs that resolves .js imports to .tsx/.ts/.jsx extensions. Minor concern about the plugin not excluding node_modules directories. Files Reviewed (1 files) |
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.
What does this PR do?
Adds an esbuild resolver plugin to
ui-tui/scripts/build.mjsthat maps.jsimport paths to.ts/.tsx/.jsxsource files on disk. Fixes thehermes --tuirebuild failure on first launch.Related Issue
The TUI build script (
scripts/build.mjs) uses esbuild without a resolver plugin. Combined withui-tui/tsconfig.jsonadoptingmoduleResolution: "nodenext"(which requires every relative import to spell the.jsextension even when the file on disk is.ts/.tsx), this means the first launch on any user install fails with errors like:The user has to manually patch the build script before the TUI can start. This PR adds the missing esbuild plugin so the build script works with the existing nodenext module resolution.
Related closed issue: NousResearch#31227 (different root cause — async
__esmdeadlock — but adjacent area)Type of Change
Changes Made
ui-tui/scripts/build.mjs: addjsToTsPluginesbuild resolver plugin (32 lines including doc comment) and register it in thepluginsarray.The plugin:
.js.tsx,.ts,.jsxextensions on disk in ordernullto fall through to esbuild's default resolution for real.jsfiles (e.g. innode_modules/)How to Test
ui-tui/dist/entry.js(or test on a clean install)hermes --tuidist/entry.jsis producedVerified on: Windows 11 ARM64 (Snapdragon X Plus), Node.js 22, esbuild 0.28.x. The
jsToTsPluginis platform-agnostic — runs in esbuild on Linux, macOS, Windows alike.Checklist
Code
fix(tui): map .js imports to .ts sources in esbuild bundle)pytest tests/ -q— N/A (no Python changes)Documentation & Housekeeping
Screenshots / Logs
Before (clean install, first
hermes --tui):After (same clean install):
TUI launches and runs as expected.
Mirror-of: NousResearch#56543
NousResearch#56543