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

Prevent proxying node APIs completely #11568

Closed
4 tasks done
Ineluki opened this issue Jan 3, 2023 · 2 comments
Closed
4 tasks done

Prevent proxying node APIs completely #11568

Ineluki opened this issue Jan 3, 2023 · 2 comments

Comments

@Ineluki
Copy link

Ineluki commented Jan 3, 2023

Description

I am trying to build a vue app using vite 4.0.4. It will not run in a regular browser, but in nw.js (https://nwjs.io/) - Therefore all node APIs already exist. But vite is creating these __vite-browser-external:os proxies that prevent access to them. I am trying to completely prevent that behavior, or at least exclude all node APIs, but I have not found an option to do so.

Simplest example:

//main.ts
import os from 'os';
console.log(os.platform())

is transformed to:

import os from "/@id/__vite-browser-external:node:os";
console.log(os.platform());

The optimizeDeps.exclude option has no effect;

the resolve.alias happens, but cannot circumvent the problem.
alias: { 'os': 'node:os' } just causes the error to shift to 'node:os' instead.

Suggested solution

Add a config option that stops interception of any specified or all node:* imports

Alternative

No response

Additional context

No response

Validations

@Tanimodori
Copy link

Have you tried build.rollupOptions.external? Also turn on ssr as your code is running under node-ish envs.

@bluwy
Copy link
Member

bluwy commented Apr 1, 2023

Vite supports browser by default only. If you're looking for node support, you should use the SSR feature, or follow this discussion: #7821

@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Apr 1, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Apr 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants