ember-fastboot / ember-fastboot/ember-cli-fastboot

Fastboot ignores browserify's `browser` field in `package.json`

Open
#370 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
850
Forks
161
Avg merge
17h 45m
Merged PRs (30d)
19

Description

browserify defines a [`browser` field in `package.json`](https://github.com/substack/browserify-handbook#browser-field) 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?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.