Open hlolli opened 3 years ago
Could you provide a reproducible example as a github repo (I'm too lazy to configure rollup)?
Could you please check if the issue is gone with the latest published version of Ololog?
Sorry for not replying, mix of lazyness and busy on my side. I will test today!
So I tested the changes, I got the exact same error
[!] Error: Could not load util (imported by node_modules/stacktracey/stacktracey.js): ENOENT: no such file or directory, open 'util'
Error: Could not load util (imported by node_modules/stacktracey/stacktracey.js): ENOENT: no such file or directory, open 'util'
to be sure it's new version, I looked into node_modules at the package.json version "version": "1.1.164",
So I just made a reproduceable example repo which actually starts with a different error message, as I've already made a browserify global alias for nodejs's path module (this I can't do with all modules as I have dependencies which require their own fs and util for example).
./index.ejs → index.js...
[!] Error: Could not load path (imported by node_modules/stacktracey/stacktracey.js): ENOENT: no such file or directory, open 'path'
Error: Could not load path (imported by node_modules/stacktracey/stacktracey.js): ENOENT: no such file or directory, open 'path'
This you can test out here https://github.com/hlolli/ololog_bug using the command yarn build
. The two plugins (which are potentially the culprits) are @rollup/plugin-node-resolve for putting the node_modules into scope, and @rollup/plugin-commonjs for importing commonjs modules as es module.
Thank you for the repro, I'll look into it in the coming days.
For reasons too long to explain here, I can't include browser compatible polyfills for built-in nodejs modules.
So when I'm compiling targeting the browser with rollup I'm getting
perhaps some easy
isBrowser
will fix this. I'm also sure that it should be possible to findrequire ('util').inspect
browserified (using built-in modules if in nodejs env).