Skip to content

Commit a138c7b

Browse files
committed
[feat]Remove RN async bundle loading timeout logic and delegate handling to the engine.
1 parent 0c71f25 commit a138c7b

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

‎packages/webpack-plugin/lib/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ class MpxWebpackPlugin {
651651
}, (chunk, set) => {
652652
compilation.addRuntimeModule(
653653
chunk,
654-
new LoadAsyncChunkModule(this.options.rnConfig && this.options.rnConfig.asyncChunk && this.options.rnConfig.asyncChunk.timeout)
654+
new LoadAsyncChunkModule()
655655
)
656656
return true
657657
})

‎packages/webpack-plugin/lib/react/LoadAsyncChunkModule.js‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ const Template = require('webpack/lib/Template')
33
const HelperRuntimeModule = require('webpack/lib/runtime/HelperRuntimeModule')
44

55
class LoadAsyncChunkRuntimeModule extends HelperRuntimeModule {
6-
constructor (timeout) {
6+
constructor () {
77
super('load async chunk')
8-
this.timeout = timeout || 10000
98
}
109

1110
generate () {
@@ -32,7 +31,7 @@ class LoadAsyncChunkRuntimeModule extends HelperRuntimeModule {
3231
]),
3332
'}',
3433
'inProgress[url] = [done]',
35-
'var callback = function (type, result) {',
34+
'var callback = function (type) {',
3635
Template.indent([
3736
'var event = {',
3837
Template.indent([
@@ -45,15 +44,13 @@ class LoadAsyncChunkRuntimeModule extends HelperRuntimeModule {
4544
]),
4645
Template.indent([
4746
'var doneFns = inProgress[url]',
48-
'clearTimeout(timeout)',
4947
'delete inProgress[url]',
5048
`doneFns && doneFns.forEach(${runtimeTemplate.returningFunction(
5149
'fn(event)',
5250
'fn'
5351
)})`
5452
]),
5553
'}',
56-
`var timeout = setTimeout(callback.bind(null, 'timeout'), ${this.timeout})`,
5754
`var loadChunkAsyncFn = ${RuntimeGlobals.global}.__mpx.config.rnConfig && ${RuntimeGlobals.global}.__mpx.config.rnConfig.loadChunkAsync`,
5855
'try {',
5956
Template.indent([

0 commit comments

Comments
 (0)