Closed rhodey closed 5 years ago
Hmm, odd. We're enabling some optimizations for build
that we don't for start
. I wonder what the culprit might be.
it seems to be using sodium-native instead of sodium-javascript in prod for some reason.
hypercore has a conditional call to require('fd-lock')
. browser-pack-flat is overeager about inlining it. fd-lock doesn't work in the browser, so hypercore should probably explicitly exclude it using the browser
field in package.json:
"browser": {
"fd-lock": false
}
but it's also something that should be addressed in browser-pack-flat. it doesn't currently try to check if a require call may be conditional.
wow thanks for the quick research @goto-bus-stop! I tried debugging this myself yesterday but I'm very unfamiliar with bankai and js bundling in general. If you have any tips to share on your debug process I'm very curious to know. either way thanks! sounds like i should close this out and re-open a similar report on browser-pack-flat
Bug report w/ example app and steps to reproduce
Expected Behavior
bankai build index.js
should bundle the npm modulehypercore@6.25.0
correctly without problem. I am using bankai9.15.0
.Current Behavior
something about
require('hypercore')
is breaking the bankai output bundle, in the console I getReferenceError: require is not defined
.strangely,
bankai start index.js
works as expected and doesn't break require, hypercore and everything works just fine. this only appears to be a problem withbankai build index.js
.Context
I'm using choo and bankai for a P2P app that gossips hypercores over WebRTC. http://radiowitness.hashbase.io/
Code Sample
https://github.com/rhodey/bankai-hypercore-poc
Your Environment
$ node -v v10.4.0 $ npm -v 6.1.0