webmachinelearning / webnn-polyfill

🧠⚙️ Web Neural Network API polyfill based on TensorFlow.js
https://www.npmjs.com/package/@webmachinelearning/webnn-polyfill
Apache License 2.0
101 stars 18 forks source link

Tests running under Node don't know they're running in Node #235

Open reillyeon opened 10 months ago

reillyeon commented 10 months ago

In trying to test #233 I discovered that TensorFlow.js is not automatically detecting that it is running in the Node environment when running tests. This seems to be because webpack is building in process/browser.js, which overrides the process global in a way that hides that the environment is Node. This is useful when running libraries that expect to run in browser but breaks libraries that need to know, like TensorFlow. This seems like a Webpack 4 issue and upgrading to Webpack 5 seems to fix the problem but results in new problems.

At this point I have discovered too many yaks and would like someone more familiar with this library to take a look. The end result might be that we need to build Node and non-Node versions of the bundle. I'm not familiar with the solutions in this space.