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

Browser Support #6

Open
wesleytodd opened this issue Mar 26, 2016 · 12 comments
Open

Browser Support #6

wesleytodd opened this issue Mar 26, 2016 · 12 comments

Comments

@wesleytodd
Copy link

I see #5, but it is not mentioned in the readme and imports fs.

I can open a PR to run the tests in Sauce Labs like @feross mentioned, and add a badge to the readme if you want. I am not sure how to do it without a tool like mocha, but I am sure I could figure it out.

If you are bundling the package with a tool like browserify you would have to exclude the fs module. There is a fairly simple way I have used to support smaller browser builds using a small DI wrapper. I can make a PR for this to if you are interested.

Thanks!!

@yoshuawuyts
Copy link

This package runs fine in the browser, here's a working example: requirebin.

@mafintosh
Copy link
Owner

we should just update the module to not require fs anymore and feature detect for an fs stream to avoid further confusion

@wesleytodd
Copy link
Author

@mafintosh if you can tell me how you want that change made I can do it for sure. Is there another way to correctly check if we should call close? Does just checking for its existence work?

@yoshuawuyts Thanks, I know that it does work, but that does not mean much unless it is tested and officially supported :)

@bnolan
Copy link

bnolan commented Oct 31, 2016

Hey, I'm having problems getting this module to work in react native. If someone can point out to me how to remove the fs dependency I'll send a PR.

@bnolan
Copy link

bnolan commented Oct 31, 2016

Ah herp derp that was easy, patch isFS to return false.

@jdnichollsc
Copy link

Hello folks, hope you're doing well

I'm getting issues with SSR using this package:

index.js:6 Uncaught ReferenceError: process is not defined
    at ../../node_modules/@toruslabs/openlogin-jrpc/node_modules/pump/index.js (index.js:6:29)
    at __require2 (chunk-ZMEXVS3E.js:47:50)
    at utils.ts:25:2

I was wondering if you can use process package as a dependency to avoid this issue? 🤔

Thanks for your help!

@dayoherrera
Copy link

Hola gente, espero que estéis bien

Tengo problemas con SSR al usar este paquete:

index.js:6 Uncaught ReferenceError: process is not defined
    at ../../node_modules/@toruslabs/openlogin-jrpc/node_modules/pump/index.js (index.js:6:29)
    at __require2 (chunk-ZMEXVS3E.js:47:50)
    at utils.ts:25:2

Me preguntaba si puede usar el paquete de proceso como una dependencia para evitar este problema.🤔

¡Gracias por tu ayuda!

Same here!

@mafintosh
Copy link
Owner

We can just typedef check if it’s there. Wanna PR that?

@markoorn
Copy link

markoorn commented Dec 5, 2022

@mafintosh I've made a PR to move the process check to be after we confirm whether or not we're ina browser: #58

@resession
Copy link

@mafintosh can you take a look at @markoorn pr? i am getting error Uncaught ReferenceError: process is not defined on the browser.

@saugion
Copy link

saugion commented Aug 22, 2023

Same here, any solution? Thanks

@saugion
Copy link

saugion commented Aug 23, 2023

I've managed to solve the process issue with this vite config, hope it helps

import {UserConfigFn, splitVendorChunkPlugin} from 'vite';
import { overrideVaadinConfig } from './vite.generated';
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill'
import rollupNodePolyFill from 'rollup-plugin-polyfill-node'

const customConfig: UserConfigFn = (env) => ({
  // Here you can add custom Vite parameters
  // https://vitejs.dev/config/
    optimizeDeps: {
        esbuildOptions: {
            target: "esnext",
            define: {
                global: 'globalThis'
            },
            plugins: [
                NodeGlobalsPolyfillPlugin({
                    buffer: true,
                    process: true,
                }),
                NodeModulesPolyfillPlugin()
            ]
        },
    },

    build: {
        minify: false,
        target: "esnext",
        commonjsOptions: {
            transformMixedEsModules: true
        },
        rollupOptions: {
            plugins: [
                rollupNodePolyFill()
            ]
        }
    },

    plugins: [splitVendorChunkPlugin()],

    define: {
        "process.env.NODE_ENV": JSON.stringify(env.mode)
    }
});

export default overrideVaadinConfig(customConfig);

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

9 participants