Skip to content
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

Support in-browser uses #31

Merged
merged 7 commits into from Mar 16, 2023
Merged

Support in-browser uses #31

merged 7 commits into from Mar 16, 2023

Conversation

Reverier-Xu
Copy link
Contributor

Hi, thank you for your awesome work!

I'd like to developing a fake shell based on xterm.js in frontend. I found that Vite dev server gives a warning like that:

Module "node:process" has been externalized for browser compatibility. Cannot access "node:process.env" in client code. See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
get @ browser-external:node:process:9

The TERM_PROGRAM env variable also does not exist in browser:

TypeError: Cannot read properties of undefined (reading 'TERM_PROGRAM')

According to the Node | Webpack documentation, the webpack can make polyfills for different node functions, but it appears as the node.process is a "mock";

"mock": Provide a mock that implements the expected interface but has little or no functionality.

So I added some code to judge the current running environment in advance, and moved some code related to Node to conditional judgment.

@Reverier-Xu Reverier-Xu marked this pull request as draft February 27, 2023 09:03
@Reverier-Xu Reverier-Xu marked this pull request as ready for review February 27, 2023 09:16
@countfak
Copy link

Hi, is this getting merged soon by any chance?

@Reverier-Xu
Copy link
Contributor Author

Hi, is this getting merged soon by any chance?

I published an alternative package isomorphic-ansi-escapes to temporarily replace this. You can use it before this pr gets merged.

@countfak
Copy link

countfak commented Mar 15, 2023

Hi, thank you!

index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
@sindresorhus
Copy link
Owner

Maybe also mention in the readme that it can be used in the browser with xterm.js

@Reverier-Xu Reverier-Xu marked this pull request as draft March 16, 2023 06:54
@Reverier-Xu Reverier-Xu marked this pull request as ready for review March 16, 2023 06:59
@sindresorhus sindresorhus merged commit 3aaa131 into sindresorhus:main Mar 16, 2023
3 checks passed
@countfak
Copy link

You're great, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants