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

Failing to compile correctly when built under Vite? #35

Open
Rohaq opened this issue May 27, 2023 · 0 comments
Open

Failing to compile correctly when built under Vite? #35

Rohaq opened this issue May 27, 2023 · 0 comments

Comments

@Rohaq
Copy link

Rohaq commented May 27, 2023

process.env calls don't compile under Vite, so it's odd to see it in the compiled code:

From uncompiled index.js

import process from 'node:process';

const ESC = '\u001B[';
const OSC = '\u001B]';
const BEL = '\u0007';
const SEP = ';';

/* global window */
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';

const isTerminalApp = !isBrowser && process.env.TERM_PROGRAM === 'Apple_Terminal';
const isWindows = !isBrowser && process.platform === 'win32';
const cwdFunction = isBrowser ? () => {
	throw new Error('`process.cwd()` only works in Node.js, not the browser.');
} : process.cwd;

const ansiEscapes = {};
// and so on...

Compiled output in browser:

const ESC = '\u001B[';
const OSC = '\u001B]';
const BEL = '\u0007';
const SEP = ';';
const isTerminalApp = process.env.TERM_PROGRAM === 'Apple_Terminal';

const ansiEscapes = {};
// and so on...

I'm guessing that the inBrowser check on line 9 probably isn't suitable for detecting a bundler like Vite

(or perhaps I have something set up wrong...)

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

No branches or pull requests

1 participant