Skip to content
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

Tell bundlers to not package a crypto module for the browser. #70

Merged
merged 1 commit into from
May 7, 2020

Conversation

jasongrout
Copy link
Contributor

In Webpack 5, builtin nodejs modules are no longer automatically polyfilled. This means that any project packaging lumino coreutils with webpack 5 will need to include either a polyfill or tell webpack to not package the module.

Looking at the current state of polyfills, the webpack-recommended package, crypto-browserify, does not implement the needed randomBytes (https://github.com/crypto-browserify/crypto-browserify/blob/460a13b5bf1e4ea60dc995906ba0543f7933a32b/example/bundle.js#L408). Additionally, “modern” browsers (FF 34, Chrome 37, Safari 6.1, IE 11) will use their own native crypto functions, so we do not need a module. Also, in a browser, polyfills for the crypto modules should implement the window.crypto interface rather than providing a module replacing the npm module.

In short, for a browser, Lumino should be using the browser api, and not trying to package a replacement for the nodejs module ‘crypto’.

See https://github.com/defunctzombie/package-browser-field-spec for the spec for this package.json field.

In Webpack 5, builtin nodejs modules are no longer automatically polyfilled. This means that any project packaging lumino coreutils with webpack 5 will need to include either a polyfill or tell webpack to not package the module.

Looking at the current state of polyfills, the webpack-recommended package, crypto-browserify, does not implement the needed randomBytes (https://github.com/crypto-browserify/crypto-browserify/blob/460a13b5bf1e4ea60dc995906ba0543f7933a32b/example/bundle.js#L408). Additionally, “modern” browsers (FF 34, Chrome 37, Safari 6.1, IE 11) will use their own native crypto functions, so we do not need a module. Also, in a browser, polyfills for the crypto modules should implement the window.crypto interface rather than providing a module replacing the npm module.

In short, for a browser, Lumino should be using the browser api, and not trying to package a replacement for the nodejs module ‘crypto’.

See https://github.com/defunctzombie/package-browser-field-spec for the spec for this package.json field.
Copy link
Contributor

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

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

Thanks!

@blink1073 blink1073 merged commit 5b175a5 into jupyterlab:master May 7, 2020
@blink1073
Copy link
Contributor

Published as @lumino/coreutils@1.4.3

@jasongrout
Copy link
Contributor Author

Thanks!

@jasongrout jasongrout deleted the browser branch May 7, 2020 18:38
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants