Issue 1:
Bug report

What is the current behavior?

I have a .js file which uses AMD using the define() method. IF the file contains a particular JS warning (i.e. "no-dupe-keys" == an object with duplicate keys such as { a: 6, a: 6 }) THEN the define() is not currently processed, and it is outputted in the transpiled content (leading to an JS runtime error such as "define is not defined").

NOTE: the above happens ONLY for a production build. Development build works OK.

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

This stack overflow post I described the situation more in detail; I'm copying here a TLDR;

I have a create-react-app based project. In it, I have a legacy JS file, e.g.:

define(["jquery", "backbone"],
function($, Backbone) {

var AppInit = function() {
// this.initialize.apply(this, arguments);
};

_.extend(AppInit.prototype, {

initApp: function() {
var originalBackboneSync = Backbone.sync;

if (window.isWindowsApp) {
var path = decodeURI(window.location.pathname);
window.operationDomain = new NodeDomain("operation", path.substr(1, path.lastIndexOf("/")) + "lib/modules/node/OperationDomain");

This file contains such a construct (observe the data key twice), that gives a linter warning: "no-dupe-keys" = there are duplicate keys:

var requestResponse = {
url: ajaxOptions.url,
method: ajaxOptions.type,
data: ajaxOptions.data,
httpStatus: jqXHR.status,
error: data || jqXHR.statusText,
data: ajaxOptions.data
};

What is the expected behavior?

For a "development" build, the output for this file is correct and looks like this:

/***/ "./src/old-app/AppInit.js":
/*!**************************************************!*\
!*** ./src/old-app/AppInit.js ***!
\**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"), __webpack_require__(/*! backbone */ "./node_modules/backbone/backbone.js")], __WEBPACK_AMD_DEFINE_RESULT__ = (function ($, Backbone) {
var AppInit = function () {// this.initialize.apply(this, arguments);
};

_.extend(AppInit.prototype, {
initApp: function () {
var originalBackboneSync = Backbone.sync;

if (window.isWindowsApp) {
var path = decodeURI(window.location.pathname);
window.operationDomain = new NodeDomain("operation", path.substr(1, path.lastIndexOf("/")) + "lib/modules/node/OperationDomain");

But for a "production" build, the output looks cf. below. Observe the presence of "define()" in the code, which is not correct.

/***/ "./src/old-app/AppInit.js":
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _home_poweruser_git2_xops_xops6_xops6_react_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/defineProperty.js");

define(["jquery", "backbone"], function ($, Backbone) {
var AppInit = function AppInit() {// this.initialize.apply(this, arguments);
};

_.extend(AppInit.prototype, {
initApp: function initApp() {
var originalBackboneSync = Backbone.sync;

if (window.isWindowsApp) {
var path = decodeURI(window.location.pathname);
window.operationDomain = new NodeDomain("operation", path.substr(1, path.lastIndexOf("/")) + "lib/modules/node/OperationDomain");

Other relevant information:

webpack version: 4.42.0

Node.js version: 14.17.0

Operating System: Linux Ubuntu 20.04 (within WSL)

Additional tools: create-react-app

Issue 2:
We have a problem with performance when enabling source-maps (cheap-module-eval-source-map) in our project. After some investigation I found an issue with replace function inside FunctionModuleTemplatePlugin. replace took too much time even when the string (req) is small.

webpack@3.12.0
webpack-dev-server@2.11.3
node@v10.15.0
npm@6.4.1
darwin 18.2.0 MacOs Mojave (10.14.3) 2.3GHz i5/ 8GB

https://github.com/webpack/webpack/blob/master/lib/FunctionModuleTemplatePlugin.js#L44-L46

source.add("/*!****" + req.replace(/./g, "*") + "****!*\\\n");
source.add(" !*** " + req.replace(/\*\//g, "*_/") + " ***!\n");
source.add(" \\****" + req.replace(/./g, "*") + "****/\n");

First simple solution just remove duplications req.replace(/./g, "*").

Second I replaced replace with Array

const x = Array(req.length).fill("*").join('');
const y = Array(req.length).fill(null).map((_, i) => (i > 0 && req[i - 1] === '*' && req[i] === '/') ? '_/' : req[i]).join('');
source.add("/*!****" + x + "****!*\\\n");
source.add(" !*** " + y + " ***!\n");
source.add(" \\****" + x + "****/\n");

After this fixes rebuild time decreased 3-4 times.

Performance of FunctionModuleTemplatePlugin increased in ~15 times (by profile)

I have created a small test file which reproduces this problem

https://gist.github.com/maksimr/cff8cb1ebda05d530071c9c78cd0d82e

CPU profile for replace

CPU profile for Array

All CPU profiles I have added to gist

https://gist.github.com/maksimr/cff8cb1ebda05d530071c9c78cd0d82e

Thanks