webpack: dependOn with multiple entry points and dynamic imports broken in 5.19.0

Bug report

What is the current behavior?

Getting errors after updating to 5.19.0

Uncaught ReferenceError: __webpack_require__ is not defined Uncaught (in promise) TypeError: c(...).Z is not a function

The compiled code is missing __webpack_require__

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

Here’s a very minimal setup that reproduces this bug.

// webpack.config.js
const path = require("path");

module.exports = {
  entry: {
    app: "./src/app.js",
    home: {
      import: './src/home.js',
      dependOn: 'app' // removing this line fixes it
    }
  },
  output: {
    path: path.resolve("./dist"),
  },
  optimization: {
    runtimeChunk: "single",
  },
};
// src/app.js
import("./test.js");
// src/log.js
export default function (msg) {
  console.log(msg);
}
// src/test.js
import log from "./log";
log("Hi");
// src/home.js
import log from "./log";
log("Hi");
<script src="runtime.js"></script>
<script src="app.js"></script>
<script src="home.js"></script>

What is the expected behavior?

This error should not happen, it was working without errors on 5.18.0

Other relevant information: webpack version: 5.19.0 Node.js version: v15.7.0 Operating System: macOS 11.2 Additional tools:

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 18 (11 by maintainers)

Commits related to this issue

Most upvoted comments