feat(v2): webpack multicompile client & server#1363
Merged
Conversation
Contributor
|
Deploy preview for docusaurus-2 ready! Built with commit ca4c2b4 |
Contributor
|
Deploy preview for docusaurus-2 ready! Built with commit 244af99 |
Contributor
|
Deploy preview for docusaurus-preview ready! Built with commit ca4c2b4 |
Contributor
|
Deploy preview for docusaurus-preview ready! Built with commit 244af99 |
endiliey
commented
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(); |
Contributor
Author
There was a problem hiding this comment.
This also makes it not outputting html files. LOL 😭
endiliey
commented
Apr 13, 2019
| // 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)); |
Contributor
Author
There was a problem hiding this comment.
The safest way. Just delete it manually with nodejs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Motivation
Try to run in one instance
Edit: The idea here is to wait at
makewebpack 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 XXXXXbecause 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
WaitPluginand then fs.readFileSync(manifest) later on.Either way, it feels nicer to see the client and server bundle being run together
Others:
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Before

After

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.)