_From @wearhere on August 14, 2016 22:53_
I'm submitting a feature request
Webpack version:
1.13.1
Please tell us about your environment:
OSX 10.11.5
Current behavior:
Webpack's automatic shimming of Node built-ins is not documented so far as I can tell.
Expected/desired behavior:
It would be documented, specifically (my stabs at documentation follow the colons):
require a Node built-in or use a Node global anywhere inos, crypto, and BufferDefinePlugin to wrap the require in a dead branchI'm actually not advocating changing the automatic shimming, I just think it should be documented. It can be very nice, but is somewhat surprising, and you might accidentally bundle a huge shim using code like:
js
var os = require('os');
var crypto;
if (os.platform() === 'browser') {
crypto = window.crypto;
} else {
crypto = require('crypto');
}
not realizing that you need to either mark 'crypto' as an external or define-out the latter branch.
Also if the shims used aren't documented, it's not clear where you'd go to file bugs against them (is Webpack responsible for them per se?)
_Copied from original issue: webpack/webpack#2871_
_From @wearhere on August 14, 2016 23:35_
Some further niceties:
SubtleCrypto is almost equivalent to crypto, the former's use of promises aside. Developers can save 100kB of JS, and worry less about correctness, by using the browser's API vs. a 3rd-party implementation._From @TheLarkInn on August 18, 2016 15:3_
@wearhere you mind posting this issue also on Our new docs repo. This will help us track it in both places.
Closing in favor of #13.
Let's re-open. We need to cover the Node bits in greater detail. Missed that on the first pass.
Ah! I think this was actually tackled recently by @oneforwonder -- see this page. Maybe we should just add a small section to the shimming guide that links there?
Ah! I think this was actually tackled recently by @oneforwonder -- see this page. Maybe we should just add a small section to the shimming guide that links there?
Yup. Good to close after that.
Most helpful comment
Let's re-open. We need to cover the Node bits in greater detail. Missed that on the first pass.