Closed jscastro76 closed 3 years ago
I have found a workaround based on some threads facing similar issues with other modules using explicit require
in the code of core modules...
/// instead of var e = {}, assign e to eval
function(_f){"use strict";var e=eval;...
///then... use the e to eval the require first
try{e("require('worker_threads')").Worker}
It's not a big deal, but it will solve the issue with a minimum code change keeping compatibility with browser and bundle use. This thread gave me the clue, but specially this tweet
Actually, I foresaw this issue and provided an unminified ESM build and an unminified CJS build to avoid the problem. I was hoping that nobody would ever use Webpack on the UMD build; it was meant specifically for direct users. Could you try replacing this line with a require
call to this CJS build?
@jscastro76 Let me know if you have any issues after using the CJS build; I'll close this issue for now. If you find any further problems, I'll reopen it.
I solved it in the way commented above, but surely more people bundling the fflate version of three.js will face that issue. I was thinking on moving to CJS so then I can come back to the original monitors version. Thanks for your quick reply!
Background I'm maintaining Threebox, and I updated the repo to Three.js r127 which now uses
fflate
in many different loaders.The problem The problem is that I'm finding issues to bundle
fflate.min.js
through different bundling tools, including browserify, webpack and vue-cli-service.How to reproduce Using the file you provided to Three.js
fflate.min.js
, referenced from [FBXLoader
] that is also bundled in my plugin, and then bundlef with broserify or webpack (I have faced issues also with vue, but there could be ther more dependencies...) I get the following error every time I execute the bundle commands:browseryfy
:Webpack
:Alternatives Some bundlers accept the option to ignore a reference to a module, but not all of them. I was guessing if you find an easy way to avoid this reference or make it conditional in the code. Any hint will be also greatly appreciated.