Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/webpack-plugin/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
7 changes: 2 additions & 5 deletions packages/webpack-plugin/lib/react/LoadAsyncChunkModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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([
Expand All @@ -45,15 +44,13 @@ class LoadAsyncChunkRuntimeModule extends HelperRuntimeModule {
]),
Template.indent([
'var doneFns = inProgress[url]',
'clearTimeout(timeout)',
'delete inProgress[url]',
`doneFns && doneFns.forEach(${runtimeTemplate.returningFunction(
'fn(event)',
'fn'
)})`
]),
'}',
`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([
Expand Down
Loading