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

Add support for import { platform } from "process" #8033

Open
mindplay-dk opened this issue Apr 30, 2022 · 3 comments
Open

Add support for import { platform } from "process" #8033

mindplay-dk opened this issue Apr 30, 2022 · 3 comments

Comments

@mindplay-dk
Copy link

🙋 feature request

I'm trying to bundle ansi-colors for the web, which references process.platform.

Tthis is currently not supported, which means a Node.JS import statement is currently left behind in web-targeted output:

import{platform as e}from"process";

🤔 Expected Behavior

The bundler should perform static analysis on process.platform properties and resolve expressions at compile-time - similar to how process.env gets resolved, perhaps even reusing the same code.

🔦 Context

#7904 was recently resolved and received an enhancement to better support ansi-colors, but didn't get all the way there.

💻 Example

See this project for reference.

@mischnic
Copy link
Member

This should replace process.platform with undefined in browsers, because it's not declared here
https://github.com/defunctzombie/node-process/blob/77caa43cdaee4ea710aa14d11cea1705293c0ef3/browser.js#L155

@mindplay-dk
Copy link
Author

This should replace process.platform with undefined in browsers

It probably should statically resolve process.platform and compile it away entirely, if possible - same way process.env expressions get evaluated at compile-time, pruning conditional branches that can't/shouldn't be executed in the browser.

@mischnic
Copy link
Member

mischnic commented May 1, 2022

That's what I meant. Replacing the expression process.platform statically with an undefined literal at build time.

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

No branches or pull requests

2 participants