antelle/argon2-browser

ReferenceError: process is not defined (WebPack build issue)

tbelch-at-eHealth-Tec opened this issue · 3 comments

Hi it's me again!

I can't seem to get it running with webpack and create-react-app. Maybe you @antelle could have a look? Do you have an idea?

It does build, but when I open the project in the browser (being served by the webpack dev server), it doesn't load the application but throws this error:

Uncaught ReferenceError: process is not defined
    at Object../node_modules/chalk/index.js (index.js:8)
    at __webpack_require__ (bootstrap:784)
    at fn (bootstrap:150)
    at Object../node_modules/react-dev-utils/formatWebpackMessages.js (formatWebpackMessages.js:10)
    at __webpack_require__ (bootstrap:784)
    at fn (bootstrap:150)
    at Object../node_modules/react-dev-utils/webpackHotDevClient.js (webpackHotDevClient.js:22)
    at __webpack_require__ (bootstrap:784)
    at fn (bootstrap:150)
    at Object.1 (serviceWorker.js:141)

Here is my minimal project: https://github.com/tbelch-at-eHealth-Tec/argon2-browser/tree/cra_a2b-webpack

I appreaciate any help!

Best regards,
Tobias

Where does it throw this error? I see that process is wrapped in global in argon2 library code.

The error is thrown here:

image

I also tried building the project and simply serving it. Then I'll get the following error message:

image

argon2.wasm:1 resolves to

image

Where is process wrapped in argon2?

Btw, when I remove config.module.noParse = /\.wasm$/; from config-overrides.js the application starts as expected but throws and error:

image

I see that it's not our code, there's some other module that reads from process. In argon2 it's here:
https://github.com/antelle/argon2-browser/blob/master/lib/argon2.js#L30
The error should be there if you remove argon2 as well.