const Module = module.constructor
const mfs = new MemoryFs
const serverCompiler = webpack(serverConfig)
serverCompiler.outputFileSystem = mfs
let serverBundle
serverCompiler.watch({},(err,stats) => {
if(err) throw err
stats = stats.toJson()
stats.errors.forEach(err => console.error(err))
stats.warnings.forEach(warn => console.warn(warn))
const bundlePath = path.join(
serverConfig.output.path,
serverConfig.output.filename
)
const bundle = mfs.readFileSync(bundlePath,'utf-8')
const m = new Module()
m._compiler(bundle,'server-entry.js')
serverBundle = m.default
})
跟着视频一步步来的,webpack是4.启动dev:server时报错,m._compiler is not a function