-
-
Notifications
You must be signed in to change notification settings - Fork 65
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
fengari doesn't work with webpack when targetting browser - dependency on fs #156
Comments
Are you using the distributed bundle? |
It looks like not. I was importing fengari separately (which has no distributed bundles?) rather than using the API calls exposed by fengariweb etc. So probably due to my Typescript typing files... |
OK, I have it working now, as long as I always However, I think this is still an issue, as code running in the browser should still be able to require just the "fengari" module. |
Doesn't webpack do this for you? |
If I explicitly |
A potential workaround here is to force webpack into the browser-compatible branch, using the new webpack.DefinePlugin({
'typeof process': JSON.stringify('undefined'),
}), We're currently using this successfully (wowserhq/client@8c61884) but it's worth noting that it may break other parts of the build that actually do rely on |
I wasn't feeling terribly comfortable with the workaround suggested by @timkurvers, so I had a go at trying to fix it within Fengari itself. I'm a bit of a Node/Webpack newbie, so I really hope I chose a sane approach -- if I didn't, please let me know. PR: #166 |
Agreed @hmans, definitely safer to fix from within. Like your approach 👍 |
I'm using fengari-web without problems in a browser-side app bundled with webpack 3. When I try pulling in fengari API calls directly, I get these kind of errors.
It seems to be because the conditional
if (typeof process !== "undefined") require()
s aren't handled by webpack, and the recommended solution seems to be to use__non_webpack_require__
https://hackernoon.com/building-isomorphic-javascript-packages-1ba1c7e558c5
The text was updated successfully, but these errors were encountered: