diff --git a/lib/dependencies/CommonJsImportsParserPlugin.js b/lib/dependencies/CommonJsImportsParserPlugin.js index e74679f7e..d321bd928 100644 --- a/lib/dependencies/CommonJsImportsParserPlugin.js +++ b/lib/dependencies/CommonJsImportsParserPlugin.js @@ -73,6 +73,15 @@ class CommonJsImportsParserPlugin { "require.main.require is not supported by webpack." ) ); + parser.hooks.call + .for("require.main.require") + .tap( + "CommonJsPlugin", + expressionIsUnsupported( + parser, + "require.main.require is not supported by webpack." + ) + ); parser.hooks.expression .for("module.parent.require") .tap( @@ -82,6 +91,15 @@ class CommonJsImportsParserPlugin { "module.parent.require is not supported by webpack." ) ); + parser.hooks.call + .for("module.parent.require") + .tap( + "CommonJsPlugin", + expressionIsUnsupported( + parser, + "module.parent.require is not supported by webpack." + ) + ); // renaming // parser.hooks.canRename.for("require").tap("CommonJsPlugin", () => true); diff --git a/test/Errors.test.js b/test/Errors.test.js index 7a3a1442a..c7ca783f6 100644 --- a/test/Errors.test.js +++ b/test/Errors.test.js @@ -188,7 +188,7 @@ it("should emit warning for require.main.require", async () => { "errors": Array [], "warnings": Array [ Object { - "loc": "1:0-20", + "loc": "1:0-30", "message": "require.main.require is not supported by webpack.", "moduleId": 0, "moduleIdentifier": "/test/fixtures/errors/require.main.require.js", @@ -207,7 +207,7 @@ it("should emit warning for module.parent.require", async () => { "errors": Array [], "warnings": Array [ Object { - "loc": "1:0-21", + "loc": "1:0-31", "message": "module.parent.require is not supported by webpack.", "moduleId": 0, "moduleIdentifier": "/test/fixtures/errors/module.parent.require.js",