-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring to improve performance #1717
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
foo: () => 123 | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
name: "subapp1-server", | ||
listen: (port = 8080) => `server is listening on port: ${port}` | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
name: "Subapp4", | ||
subAppDir: "Subapp4/src", | ||
entry: "index.js", | ||
serverEntry: false | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
name: "subapp4", | ||
subAppDir: "subapp4/src", | ||
entry: "index.js", | ||
serverEntry: false | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,8 +62,11 @@ ${inlineRuntimeJS} | |
</script>`; | ||
|
||
// check if any subapp has server side code with initialize method and load them | ||
const subAppServers = Object.keys(subappUtil.getAllSubAppManifest()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Run this only for subapps for that specific route. In |
||
.map(name => subappUtil.loadSubAppServerByName(name)) | ||
const { subApps } = setupContext.routeOptions.__internals; | ||
const subAppServers = subApps | ||
.map(({ subapp }) => { | ||
subappUtil.loadSubAppServerByName(subapp.name, false); | ||
}) | ||
.filter(x => x && x.initialize); | ||
|
||
return { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,7 +139,7 @@ Response: ${err || body}` | |
// | ||
const prepareSubAppSplitBundles = async context => { | ||
const { assets, includedBundles } = context.user; | ||
const entryName = subApp.name.toLowerCase(); | ||
const entryName = name.toLowerCase(); | ||
// | ||
const entryPoints = assets.entryPoints[entryName]; | ||
const cdnJsBundles = util.getCdnJsBundles(assets, setupContext.routeOptions); | ||
|
@@ -193,10 +193,9 @@ Response: ${err || body}` | |
|
||
const loadSubApp = () => { | ||
subApp = loadSubAppByName(name); | ||
subAppServer = loadSubAppServerByName(name); | ||
subAppServer = loadSubAppServerByName(name, true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now we will call |
||
}; | ||
|
||
loadSubApp(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need this only if ssr is enabled |
||
prepareSubAppJsBundle(); | ||
|
||
const verifyUseStream = props => { | ||
|
@@ -221,10 +220,6 @@ Response: ${err || body}` | |
|
||
context.user.numOfSubapps = context.user.numOfSubapps || 0; | ||
|
||
if (request.app.webpackDev && subAppLoadTime < request.app.webpackDev.compileTime) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needto call |
||
subAppLoadTime = request.app.webpackDev.compileTime; | ||
loadSubApp(); | ||
} | ||
|
||
let { group = "_" } = props; | ||
group = [].concat(group); | ||
|
@@ -337,14 +332,6 @@ ${stack}`, | |
}; | ||
|
||
const processSubapp = async () => { | ||
const ref = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need this only for ssr flow. So moved it to line 358 |
||
context, | ||
subApp, | ||
subAppServer, | ||
options: props, | ||
ssrGroups | ||
}; | ||
|
||
context.user.numOfSubapps++; | ||
const { bundles, scripts, preLoads } = await prepareSubAppSplitBundles(context); | ||
outputSpot.add(`${comment}`); | ||
|
@@ -363,6 +350,21 @@ ${stack}`, | |
if (!context.user[`prepare-grp-${props.group}`]) { | ||
context.user[`prepare-grp-${props.group}`] = Date.now(); | ||
} | ||
|
||
if ( | ||
!request.app.webpackDev || | ||
(request.app.webpackDev && subAppLoadTime < request.app.webpackDev.compileTime) | ||
) { | ||
subAppLoadTime = _.get(request, "app.webpackDev.compileTime", 0); | ||
loadSubApp(); | ||
} | ||
const ref = { | ||
context, | ||
subApp, | ||
subAppServer, | ||
options: props, | ||
ssrGroups | ||
}; | ||
const lib = (ssrInfo.lib = util.getFramework(ref)); | ||
ssrInfo.awaitData = lib.handlePrepare(); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified to generate server from subapps main file only if ssr is enabled