Skip to content

Fastboot ignores browserify's browser field in package.json #370

@gabrielgrant

Description

@gabrielgrant

browserify defines a browser field in package.json as the recommended method for library authors to account for the differences between a browser and node environment in universal JS packages. This allows, for example, using the same websocket API in client-side and browser-side code: https://github.com/gabrielgrant/javascript-universal-websocket-client

Unfortunately, fastboot doesn't take this field into account, and tries to use the browser implementation despite running in Node. Is the expectation that every library in the npm ecosystem currently using the browser field also add fastboot guards? This seems unlikely to happen, especially given that (afaiu) require()s can't be wrapped in conditionals, making the changes required not-entirely-trivial to do (and also requiring that all node polyfill code be included in browser-compiled bundles)

Is there any way to get fastboot to respect browserify's browser field?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions