rsnext/packages/next/compiled/webpack/webpack.js
Joe Haddad 04f37d0978
fix: load webpack hook before config is required (#22583)
This pull request ensures the webpack hook is installed before an attempt is made to load the configuration.

This pull request is tested by the PnP tests, which should now be passing as a result of this change.

---

Fixes #21679
2021-02-27 06:19:35 +00:00

27 lines
712 B
JavaScript

exports.__esModule = true
exports.isWebpack5 = false
exports.default = undefined
let initializedWebpack5 = false
let initializedWebpack4 = false
let initFns = []
exports.init = function (useWebpack5) {
if (useWebpack5) {
Object.assign(exports, require('./bundle5')())
exports.isWebpack5 = true
if (!initializedWebpack5) for (const cb of initFns) cb()
initializedWebpack5 = true
} else {
Object.assign(exports, require('./bundle4')())
exports.isWebpack5 = false
if (!initializedWebpack4) for (const cb of initFns) cb()
initializedWebpack4 = true
}
}
exports.onWebpackInit = function (cb) {
if (initializedWebpack5 || initializedWebpack4) cb()
else initFns.push(cb)
}