xtermjs / xterm.js

A terminal for the web
https://xtermjs.org/
MIT License
17.52k stars 1.62k forks source link

Vercel deployment error #4999

Closed gasper94 closed 6 months ago

gasper94 commented 6 months ago

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch xterm-addon-fit@0.9.0-beta.37 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/xterm-addon-fit/src/FitAddon.ts b/node_modules/xterm-addon-fit/src/FitAddon.ts
index f724546..01410c2 100644
--- a/node_modules/xterm-addon-fit/src/FitAddon.ts
+++ b/node_modules/xterm-addon-fit/src/FitAddon.ts
@@ -4,7 +4,7 @@
  */

 import { Terminal, ITerminalAddon } from 'xterm';
-import { IRenderDimensions } from 'browser/renderer/shared/Types';
+// import { IRenderDimensions } from 'browser/renderer/shared/Types';

 interface ITerminalDimensions {
   /**
@@ -57,7 +57,8 @@ export class FitAddon implements ITerminalAddon {

     // TODO: Remove reliance on private API
     const core = (this._terminal as any)._core;
-    const dims: IRenderDimensions = core._renderService.dimensions;
+    // const dims: IRenderDimensions = core._renderService.dimensions;
+    const dims: any = core._renderService.dimensions;

     if (dims.css.cell.width === 0 || dims.css.cell.height === 0) {
       return undefined;

This issue body was partially generated by patch-package.

gasper94 commented 6 months ago

build locally & vercel deployment

jerch commented 6 months ago

Can you describe, what that actually fixes? To me it seems, that you only commented out/widened TS types?

gasper94 commented 6 months ago

I was trying to deploy a project to vercel using xTerm and xterm-addon-fit().

I got this error build error (dev worked fine): 7:10 Error: FitAddon not found in 'xterm-addon-fit' import/named

I had the library "xterm-addon-fit": "^0.8.0" and import { FitAddon } from 'xterm-addon-fit';

I pointed the library to this: import { FitAddon } from 'xterm-addon-fit/src/FitAddon';

but on that file: browser/renderer/shared/Types is nowehere to be found

so, I removed that line and everything worked as spected. I was able to run and build. I'm I doing something wrong?

Untitled

Tyriar commented 6 months ago

You're pointing it to src/ which includes the typescript code. You are meant to use whatever main in the package.json points to:

"main": "lib/addon-fit.js",

Otherwise you have to deal with compiling the TS yourself which isn't possible without the rest of the core repo.

gasper94 commented 6 months ago

Totally. I understand that but when I point it to "main" I get this error (7:10 Error: FitAddon not found in 'xterm-addon-fit' import/named): I have xtermjs + xterm-addon-fit on node_modules.

Tyriar commented 6 months ago

@gasper94 we've moved over to the @xterm scope so you want the modules @xterm/xterm and @xterm/addon-fit

gasper94 commented 6 months ago

Great!!! Thank you!