Skip to content

sockIntegration: 'whm' may inject webpack-hot-middleware/client twice #16

Description

@morrighan

If end-user provide webpack-hot-middleware/client explicitly in the entry. this plugin should skip to inject it.

Scenario

// `rspack.config.js`

export default {
    // ...

    entry: {
	    application: [
		    './src/app.js'
            'webpack-hot-middleware/client?overlay=false&quiet=true',
        ]
    },

    // ...
}

In this case, the output bundle be like below

// ...

function(__webpack_require__) {
var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId) }
__webpack_require__.O(0, ["common",], function() {
        return __webpack_exec__("./node_modules/@rspack/plugin-react-refresh/client/reactRefreshEntry.js"),
             __webpack_exec__("./node_modules/webpack-hot-middleware/client.js"),
             // ^ Injected by this plugin
             __webpack_exec__("./node_modules/@rspack/plugin-react-refresh/client/errorOverlayEntry.js"),
             __webpack_exec__("./src/app.js"),
             __webpack_exec__("./node_modules/webpack-hot-middleware/client.js?overlay=false&quiet=true");
             // ^ Provided by the config
      });
var __webpack_exports__ = __webpack_require__.O();

}
// ...

Prior art

https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/lib/index.js#L82-L98

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions