From a138c7bd45f3602b883844c3672b14bc30c9b5fb Mon Sep 17 00:00:00 2001 From: xiaolei <1017653702@qq.com> Date: Thu, 12 Mar 2026 21:51:36 +0800 Subject: [PATCH] [feat]Remove RN async bundle loading timeout logic and delegate handling to the engine. --- packages/webpack-plugin/lib/index.js | 2 +- packages/webpack-plugin/lib/react/LoadAsyncChunkModule.js | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/webpack-plugin/lib/index.js b/packages/webpack-plugin/lib/index.js index 185490931e..ca9b11d4f9 100644 --- a/packages/webpack-plugin/lib/index.js +++ b/packages/webpack-plugin/lib/index.js @@ -651,7 +651,7 @@ class MpxWebpackPlugin { }, (chunk, set) => { compilation.addRuntimeModule( chunk, - new LoadAsyncChunkModule(this.options.rnConfig && this.options.rnConfig.asyncChunk && this.options.rnConfig.asyncChunk.timeout) + new LoadAsyncChunkModule() ) return true }) diff --git a/packages/webpack-plugin/lib/react/LoadAsyncChunkModule.js b/packages/webpack-plugin/lib/react/LoadAsyncChunkModule.js index af70b461a2..73bde6a076 100644 --- a/packages/webpack-plugin/lib/react/LoadAsyncChunkModule.js +++ b/packages/webpack-plugin/lib/react/LoadAsyncChunkModule.js @@ -3,9 +3,8 @@ const Template = require('webpack/lib/Template') const HelperRuntimeModule = require('webpack/lib/runtime/HelperRuntimeModule') class LoadAsyncChunkRuntimeModule extends HelperRuntimeModule { - constructor (timeout) { + constructor () { super('load async chunk') - this.timeout = timeout || 10000 } generate () { @@ -32,7 +31,7 @@ class LoadAsyncChunkRuntimeModule extends HelperRuntimeModule { ]), '}', 'inProgress[url] = [done]', - 'var callback = function (type, result) {', + 'var callback = function (type) {', Template.indent([ 'var event = {', Template.indent([ @@ -45,7 +44,6 @@ class LoadAsyncChunkRuntimeModule extends HelperRuntimeModule { ]), Template.indent([ 'var doneFns = inProgress[url]', - 'clearTimeout(timeout)', 'delete inProgress[url]', `doneFns && doneFns.forEach(${runtimeTemplate.returningFunction( 'fn(event)', @@ -53,7 +51,6 @@ class LoadAsyncChunkRuntimeModule extends HelperRuntimeModule { )})` ]), '}', - `var timeout = setTimeout(callback.bind(null, 'timeout'), ${this.timeout})`, `var loadChunkAsyncFn = ${RuntimeGlobals.global}.__mpx.config.rnConfig && ${RuntimeGlobals.global}.__mpx.config.rnConfig.loadChunkAsync`, 'try {', Template.indent([