Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non browser compatible node-module required #23

Open
hlolli opened this issue Nov 4, 2020 · 5 comments
Open

Non browser compatible node-module required #23

hlolli opened this issue Nov 4, 2020 · 5 comments

Comments

@hlolli
Copy link

hlolli commented Nov 4, 2020

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

[!] 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'

perhaps some easy isBrowser will fix this. I'm also sure that it should be possible to find require ('util').inspect browserified (using built-in modules if in nodejs env).

@xpl
Copy link
Owner

xpl commented Nov 5, 2020

Could you provide a reproducible example as a github repo (I'm too lazy to configure rollup)?

@xpl
Copy link
Owner

xpl commented Nov 10, 2020

Could you please check if the issue is gone with the latest published version of Ololog?

@hlolli
Copy link
Author

hlolli commented Nov 10, 2020

Sorry for not replying, mix of lazyness and busy on my side. I will test today!

@hlolli
Copy link
Author

hlolli commented Nov 11, 2020

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.

@xpl
Copy link
Owner

xpl commented Nov 12, 2020

Thank you for the repro, I'll look into it in the coming days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants