-
Notifications
You must be signed in to change notification settings - Fork 58
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
Feature: browser support #337
Comments
So yeah, this totally works in the browser! We don't pre-package a minified/webpacked version in the browser, but if you follow along with our webpack config, you can make it work :) The |
Thank you, I have verified it works with webpack. The key is to make sure a user has this in their webpack config: module: {
rules: [
{
test: /node_modules\/https-proxy-agent\//,
use: 'null-loader',
}, With that, it works. I'll leave the issue open for the docs to get updated. feel free to close at any time! |
This still depends on the assumption that everyone is using & wants to edit their webpack configuration file. |
I'm using Vite instead of webpack. Is there an equivalent config setting? I currently get an error like this when trying to use in browser.
|
I worked around the "process is not defined" error by adding to my
I'll try and find answers for my next issue before commenting again here :) |
googleapis#337 This improves compatibility with blunders that don't implement hacks like Vite, as well as non Node.js JavaScript environments such as Browsers, Deno, v8js and WebContainers.
#337 This improves compatibility with blunders that don't implement hacks like Vite, as well as non Node.js JavaScript environments such as Browsers, Deno, v8js and WebContainers.
Visitors to this thread may be interested in https://github.com/developit/redaxios which wraps native |
Since this issue was opened, we've upgraded to a newer webpack, have integration tests for it, and have an example webpack config in the project root: https://github.com/googleapis/gaxios/blob/main/webpack.config.js Please let us know if folks continue bumping into any issues. |
Added this to my nextjs webpack config like so: file:
|
Didn't work for me. Instead I what works for me (vite / react) is the vite-plugin-node-polyfills plugin: import { defineConfig } from "vite";
import { nodePolyfills } from "vite-plugin-node-polyfills";
import react from "@vitejs/plugin-react";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
nodePolyfills(), // https://www.npmjs.com/package/vite-plugin-node-polyfills
],
//...
},
}); |
Is your feature request related to a problem? Please describe.
Want 'one net io to rule them all' for use in browser and node projects
Describe the solution you'd like
switch
gaxios
to use isomorphic dependencies. such ascross-fetch
instead ofnode-fetch
Describe alternatives you've considered
use a bloated complex library like
axios
Additional context
I see https://github.com/googleapis/gaxios/tree/master/browser-test so I'm confused. If browser is already supported, add some info to the readme!
The text was updated successfully, but these errors were encountered: