calvinmetcalf / rollup-plugin-node-builtins

138 stars 40 forks source link

Builtin is undefined #35

Closed AlbertoElias closed 6 years ago

AlbertoElias commented 6 years ago

When compiling simple-peer, I've tried configuring rollup in different ways, but I can't get past an error in this line where superCtor is undefined.

This is a gist with the minimal use case where this error happens:

https://gist.github.com/AlbertoElias/2641c23cc8dc256b29bc4c018e1888fa

Not sure if I'm doing something wrong or if there's some clash with simple-peer's inherits dependency.

calvinmetcalf commented 6 years ago

so the issue there is that where it is being used in the code the thing is undefined, lemme dig into it in a bit

AlbertoElias commented 6 years ago

Great, thank you very much, let me know if you need any more information

calvinmetcalf commented 6 years ago

ok so the actual issue is that not every module can be used with rollup even with plugins, specifically readable stream can't, so instead you need to either bundle simple-peer up with some other bundler or substitute the version of streams that this library provides somehow

AlbertoElias commented 6 years ago

Thanks for checking it out. Could you provide any more information as to why it doesn't work with rollup?

calvinmetcalf commented 6 years ago

complex stuff commonjs specific related dependencies

AlbertoElias commented 6 years ago

Do you know of any solution that simple-peer could apply to fix this issue?

calvinmetcalf commented 6 years ago

I believe there is a plugin that allows you to substitute different modules in, which you could use to substitute stream in for readable stream

AlbertoElias commented 6 years ago

Ended up going with the solution mentioned in this issue: https://github.com/rollup/rollup-plugin-alias/issues/33

JoeMethven commented 3 years ago

@AlbertoElias Hi, I am having a similar issue Object prototype may only be an Object or null: undefined due to this line of my rollup bundle: ctor.prototype = Object.create(superCtor.prototype, { particularly superCtor.prototype is undefined instead of an Object or null.

What did you do in rollup-plugin-replace to fix this issue? I would've thought the rollup globals & builtins plugin would fix this issue but it doesn't.