microsoft / iot-cardboard-js

iot-cardboard-js is a React library for building experiences for IoT applications
https://main--601c6b2fcd385c002100f14c.chromatic.com/
MIT License
84 stars 26 forks source link

Update npm package to webpack 5 compatible #975

Open K1vs opened 9 months ago

K1vs commented 9 months ago

Hi, At the moment it is impossible to simply install the package and use in CRA application. At a minimum, you need to use something like CRACO + node-polyfill-webpack-plugin. But the worst thing is that even after this the application still does not work due to

bootstrap:27 Uncaught TypeError: util__WEBPACK_IMPORTED_MODULE_0__.TextEncoder is not a constructor
    at ./node_modules/@microsoft/iot-cardboard-js/internal/axios-1bc8e67b.js (formDataToStream.js:8:1)
    at options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:62:1)
    at ./node_modules/@microsoft/iot-cardboard-js/internal/HierarchyNode-05d12d93.js (ErrorBoundary.tsx:150:1)
    at options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:62:1)
    at ./node_modules/@microsoft/iot-cardboard-js/internal/ADT3DSceneAdapter-0423f1cf.js (ADT3DGlobe.tsx:150:1)
    at options.factory (react refresh:6:1)

This problem exists even if you use a template https://github.com/Azure-Samples/cra-template-iot-cardboard-js