Skip to content

Conversation

@dcousens
Copy link

@dcousens dcousens commented May 24, 2017

This, combined with #10 should resolve the issues at large.

buffer, the dependency, is only used in browser.js, otherwise the native Buffer is used (intrinsically) and therefore we shim it if necessary.

@calvinmetcalf calvinmetcalf mentioned this pull request May 24, 2017
@dcousens dcousens mentioned this pull request May 25, 2017
@dcousens
Copy link
Author

dcousens commented May 27, 2017

ping @feross - it'd be good to resolve this as currently, it breaks a few peoples builds

@jibeizhao
Copy link

hey guys, when are we planning to merges these two PRs?

@dcousens
Copy link
Author

ping @feross

Copy link
Owner

@feross feross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR doesn't make sense. If the goal is to prevent node users from using the npm buffer package, then no change is needed. require('buffer') will always return the built-in buffer package in Node.js. Built-in modules get priority over packages in node_modules.

Tip: the way to require the npm package is require('buffer/')


if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
module.exports = buffer
module.exports = Buffer
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a huge breaking change. require('buffer') !== Buffer. Try doing require('buffer') and look at what you get.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed! Sorry

throw new TypeError('Argument must be a number')
}
return buffer.SlowBuffer(size)
return Buffer.SlowBuffer(size)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buffer.SlowBuffer is undefined...

@feross feross closed this Jun 2, 2017
@dcousens
Copy link
Author

dcousens commented Jun 3, 2017

Built-in modules get priority over packages in node_modules.

I was not aware of this. Awesome!

@dcousens dcousens deleted the patch-1 branch June 3, 2017 00:27
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

Successfully merging this pull request may close these issues.

4 participants