Skip to content

feat(v2): webpack multicompile client & server#1363

Merged
endiliey merged 5 commits into
facebook:masterfrom
endiliey:parallel
Apr 13, 2019
Merged

feat(v2): webpack multicompile client & server#1363
endiliey merged 5 commits into
facebook:masterfrom
endiliey:parallel

Conversation

@endiliey

@endiliey endiliey commented Apr 13, 2019

Copy link
Copy Markdown
Contributor

Motivation

Try to run in one instance

Edit: The idea here is to wait at make webpack compilation hook (https://webpack.js.org/api/compiler-hooks/#make) which is done before finishing the compilation.
This is roughly before static-site-generator-webpack-plugin begins to execute its function.

Note that we cannot do import manifest from XXXXX because at that time, the manifest still doesn't exist until client bundle finish serving.

We can however, do fs.existSync first at webpack level using our newly created WaitPlugin and then fs.readFileSync(manifest) later on.

Either way, it feels nicer to see the client and server bundle being run together

Others:

  • Fix sitemap plugin to remove annoying callback deprecation warning

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Before
image

image

After
multicompiler

image

The performance gain is not so much actually (around 2-3s gain in my pc, my total build time is 12s). Because the server actually compiles really fast even if compiled sequentially (~5s only). But for long term it is definitely better to run it together

Related PRs

(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)

@endiliey endiliey requested a review from yangshun as a code owner April 13, 2019 12:01
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Apr 13, 2019
@docusaurus-bot

Copy link
Copy Markdown
Contributor

Deploy preview for docusaurus-2 ready!

Built with commit ca4c2b4

https://deploy-preview-1363--docusaurus-2.netlify.com

@docusaurus-bot

docusaurus-bot commented Apr 13, 2019

Copy link
Copy Markdown
Contributor

Deploy preview for docusaurus-2 ready!

Built with commit 244af99

https://deploy-preview-1363--docusaurus-2.netlify.com

@docusaurus-bot

Copy link
Copy Markdown
Contributor

Deploy preview for docusaurus-preview ready!

Built with commit ca4c2b4

https://deploy-preview-1363--docusaurus-preview.netlify.com

@docusaurus-bot

docusaurus-bot commented Apr 13, 2019

Copy link
Copy Markdown
Contributor

Deploy preview for docusaurus-preview ready!

Built with commit 244af99

https://deploy-preview-1363--docusaurus-preview.netlify.com

@endiliey endiliey left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @yangshun had to merge this out because our docusaurus 2 site was broken due to previous PR (output to filesystem). My bad! If anything needs changes/ review, I'll submit a patch

image

@endiliey endiliey merged commit f37300a into facebook:master Apr 13, 2019
const compiler = webpack(config);
if (isServer) {
// Don't output server bundle to disk. Write files to memory instead
compiler.outputFileSystem = new MemoryFS();

@endiliey endiliey Apr 13, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also makes it not outputting html files. LOL 😭

// Build the server bundles (render the static HTML and pick client bundle),
await compile(serverConfig, true);
// Remove server.bundle.js because it is useless
await fs.unlink(path.join(outDir, serverConfig.output.filename));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The safest way. Just delete it manually with nodejs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants