Skip to content

Commit bee4577

Browse files
committed
fix: lazy load native modules
Signed-off-by: Chapman Pendery <cpendery@vt.edu>
1 parent fc9482c commit bee4577

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@microsoft/inshellisense",
3-
"version": "0.0.1-rc.28",
3+
"version": "0.0.1-rc.29",
44
"description": "IDE style command line auto complete",
55
"type": "module",
66
"engines": {

src/isterm/pty.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import path from "node:path";
88
import fs from "node:fs";
99
import { Unicode11Addon } from "@xterm/addon-unicode11";
1010

11-
import pty, { IPty, IEvent } from "node-pty";
11+
import pty from "node-pty";
12+
import type { IPty, IEvent } from "node-pty";
1213
import { Shell, userZdotdir, zdotdir } from "../utils/shell.js";
1314
import { IsTermOscPs, IstermOscPt, IstermPromptStart, IstermPromptEnd } from "../utils/ansi.js";
1415
import xterm from "@xterm/headless";

src/ui/suggestionManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import { Suggestion, SuggestionBlob } from "../runtime/model.js";
55
import { getSuggestions } from "../runtime/runtime.js";
6-
import { ISTerm, ISTermPatch } from "../isterm/pty.js";
6+
import type { ISTerm, ISTermPatch } from "../isterm/pty.js";
77
import { renderBox, truncateText, truncateMultilineText } from "./utils.js";
88
import chalk from "chalk";
99
import { Shell } from "../utils/shell.js";

src/ui/ui-root.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import { Command } from "commander";
88

99
import log from "../utils/log.js";
1010
import { getBackspaceSequence, Shell } from "../utils/shell.js";
11-
import isterm from "../isterm/index.js";
1211
import { enableWin32InputMode, resetToInitialState } from "../utils/ansi.js";
13-
import { SuggestionManager, MAX_LINES, KeyPressEvent } from "./suggestionManager.js";
14-
import { ISTerm } from "../isterm/pty.js";
12+
import { MAX_LINES, type KeyPressEvent, type SuggestionManager } from "./suggestionManager.js";
13+
import type { ISTerm } from "../isterm/pty.js";
1514
import { v4 as uuidV4 } from "uuid";
1615

1716
export const renderConfirmation = (live: boolean): string => {
@@ -72,7 +71,11 @@ const _direction = (term: ISTerm): "above" | "below" => {
7271
};
7372

7473
export const render = async (program: Command, shell: Shell, underTest: boolean, login: boolean) => {
75-
const term = await isterm.spawn(program, { shell, rows: process.stdout.rows, cols: process.stdout.columns, underTest, login });
74+
const [isterm, { SuggestionManager }] = await Promise.all([
75+
import("../isterm/index.js"),
76+
import("./suggestionManager.js"),
77+
]);
78+
const term = await isterm.default.spawn(program, { shell, rows: process.stdout.rows, cols: process.stdout.columns, underTest, login });
7679
const suggestionManager = new SuggestionManager(term, shell);
7780
let hasSuggestion = false;
7881
let direction = _direction(term);

0 commit comments

Comments
 (0)