Fixed uncontrolled second compile when entering watch mode for offline. #280
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.
What did you implement:
Closes #279
How did you implement it:
webpack.compiler.watch()automatically triggers a compile. This led to a double compile (with the second one being uncontrolled and asynchronous) on startup of the plugin together with serverless offline. The second unwanted compile was running in parallel with the serverless-offline start.Now, for watch mode, the inital compile is skipped as the watch will do it anyway. For non-watch mode the regular
webpack:compilelifecycle is triggered.Additionally a new switch
--webpack-no-watchhas been added to turn off the default watch mode with serverless-offline. This is needed, if you use serverless-offline in an automated build that does integration tests (and changes the source tree) with an external script given to offline. There you only want to build once and test the output withserverless offline --execautomatically. As soon as the given script changes the source tree, it leads to a recompile which breaks the script.How can we verify it:
Use
serverless offlineorserverless offline startand check that there is only one compile in the beginning (and not two) and that the plugin waits for its completion. Only then the offline plugin should start its work (watch mode enabled as before).Use
serverless offline --webpack-no-watchto start with watch mode disabled. Changes in the sources should not trigger a rebuild now.Todos:
Is this ready for review?: YES
Is it a breaking change?: NO