Issue 1:
Bug report

What is the current behavior?

A 5 row NodeJS application, https://github.com/MorganLindqvist/webpack5-http-auth-failure, works as it should without Webpack-5. But when running after webpack the application crashes.

If the current behavior is a bug, please provide the steps to reproduce.

git clone https://github.com/MorganLindqvist/webpack5-http-auth-failure.git

cd webpack5-http-auth-failure

npm install

npm run build_dev

node dist/main.js

The 5-row application that crashes is as follows:

const auth = require("http-auth");
const basic = auth.basic({
realm: "Realm",
file: __dirname + "/../htpasswd"
});

What is the expected behavior?

This small snippit is a part of a larger NodeJS application and the same error/crash (see below) is triggered in that one when the usage of http-auth module was added. The error message I receive s as follows:

TypeError: Can not find node binding files from @node-rs/bcrypt-linux-x64-gnu, @node-rs/bcrypt-linux-x64-gnux32, @node-rs/bcrypt-linux-x64-musl and /home/user/webpack5-http-auth-failure/dist/bcrypt.linux-x64-gnu.node, /home/user/webpack5-http-auth-failure/dist/bcrypt.linux-x64-gnux32.node, /home/user/webpack5-http-auth-failure/dist/bcrypt.linux-x64-musl.node

Until it is fixed, can I bypass it in some way?

Other relevant information:

webpack version: 5.30.0

Node.js version: v14.16

Operating System: Ubuntu 20.04

Additional tools: npm: 6.14.11

Issue 2:
Bug report

What is the current behavior?

Crashes with a stack trace of

$ npm run webpack:dev

> @hyperledger/cactus@ webpack:dev *REDACTED_PATH*
> node --max-old-space-size=8192 node_modules/webpack/bin/webpack.js --display-error-details --env env-csv=dev --env target-csv=node

*REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:371
if (item) flattenedResult.push(...item);
^

RangeError: Maximum call stack size exceeded
at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:371:34
at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)

If the current behavior is a bug, please provide the steps to reproduce.

Clone the repo where the failure can be reproduced: https://github.com/petermetz/blockchain-integration-framework/tree/build/webpack-optimization-139

Check out the branch called build/webpack-optimization-139

Execute npm run configure which will produce the crash logs stated above.

You can observe the effective webpack config file after the build has run at least once at ./webpack.config.json

What is the expected behavior?

Build succeeds without RangeError.

Other relevant information:

webpack version: v5.4.0

Node.js version: v12.16.3

Operating System: Ubuntu 20.04 LTS

Additional tools: Lerna, Typescript, ts-loader