formio / angular

JSON powered forms for Angular
https://formio.github.io/angular-demo
MIT License
613 stars 461 forks source link

[BUG] Formio throws error while running SSR build #1074

Open rishi-soul opened 3 weeks ago

rishi-soul commented 3 weeks ago

Environment

Local Build

Steps to Reproduce

  1. ng run sr-front:serve-ssr:local

Observed behavior

./node_modules/formiojs/providers/storage/s3.js:54 var AbortController = window.AbortController || require('abortcontroller-polyfill/dist/cjs-ponyfill'); ^

ReferenceError: window is not defined at Object.29290 (./node_modules/formiojs/providers/storage/s3.js:54:23) at require (./webpack/bootstrap:19:1) at Object.83889 (./node_modules/formiojs/providers/storage/index.js:9:33) at require (./webpack/bootstrap:19:1) at Object.52573 (./node_modules/formiojs/providers/Providers.js:21:39) at require (./webpack/bootstrap:19:1) at Object.73119 (./node_modules/formiojs/providers/index.js:8:41) at require (./webpack/bootstrap:19:1) at Object.36673 (./node_modules/formiojs/Formio.js:47:41) at __webpack_require__ (./webpack/bootstrap:19:1)

Node.js v20.12.1 A server error has occurred. node exited with 1 code.

Observation: This generally happens with any third party library if window code is not protected. Any ssr build will throw an reference error.