-
Notifications
You must be signed in to change notification settings - Fork 169
Description
Context: I want to use TensorFlow.js in the browser. I'm using rollup to bundle my app for the browser.
The TensorFlow.js source imports from seedrandom in several places. This comes through in the ES modules distributed via npm.
To find the module seedrandom imported by TensorFlow, I'm using the plugin @rollup/plugin-node-resolve. This does find the node_modules/seedrandom package.
Unfortunately, @rollup/plugin-node-resolve does not find an ECMAScript module in the seedrandom package. So instead, it decides to bundle the seedrandom index.js. But this is a CommonJS module, not an ES module.
As a result, rollup gives me errors like alea is not exported by node_modules/seedrandom/index.js, and the browser gives me errors like require is not defined.
I think the right solution is for the seedrandom package to provide an ES module. The alternative is for TensorFlow to stop importing from a package that doesn't provide an ES module.
(You might say "well you just need to use a CommonJS->ES transpiler, like @rollup/plugin-commonjs". I'm reluctant to do so, because this transformation is gross, and in general, impossible.)