Skip to content

global is not defined - minimal.js assumes node environment? #874

Open
@ghost

Description

protobuf.js version: 6.8.0

We run this:

$ pbjs -t static-module -w es6 -o proto.js entity.proto

(Same thing with -w commongjs, by the way)

Then import it like so in a JSX:

import { Entity } from 'proto.js'

Using babel, webpack emits the client code, using this babel configuration:

{
    "presets":[
        "es2015", "react"
    ]
}

But when running in the browser, we get:

Uncaught ReferenceError: global is not defined
    at Object.<anonymous> (minimal.js:49)
    ...

Which is that line in minimal.js:

util.isNode = Boolean(global.process && global.process.versions && global.process.versions.node);

Now that makes sense, since we are in browser environment and not node.

I just wonder if we're doing something wrong, or should minimal.js not assume node environment?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions