formsy-react icon indicating copy to clipboard operation
formsy-react copied to clipboard

UMD package will not run without process.env.NODE_ENV set

Open twisty opened this issue 5 years ago • 0 comments

If process.env.NODE_ENV is not set, the umd build throws an error when run in browser.

react-is.development.js:14 Uncaught ReferenceError: process is not defined
    at react-is.development.js:14
    at createCommonjsModule (formsy-react.umd.js:248)
    at react-is.production.min.js:15
    at formsy-react.umd.js:4
    at formsy-react.umd.js:5

This prevents us from easily loading the library from cdns like unpkg.

It's possible to workaround by adding a mock process object on the window object before loading the library:

window.process = {
  env: {
    NODE_ENV: ''
  }
}

See https://codepen.io/twisty/full/dyodZZG

twisty avatar Mar 11 '20 16:03 twisty