Skip to content
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

fix: remove addDependency and only require RefreshModuleRuntime once #22

Merged
merged 3 commits into from Dec 17, 2019

Conversation

mmhand123
Copy link
Contributor

Moved the require for the RefreshModuleRuntime outside of the loader function and removed the this.addDependency call, which seemed to be invalidating caching webpack was doing. This fixes incremental recompile performance in the fairly large project I'm working in. It's also noticeable in the example app wds project (although the recompiles are already really fast 😁):

Pre
image

Post
image

Fixes #20

src/loader.js Outdated
const { Template } = require('webpack');
const { refreshUtils } = require('./runtime/globals');
const RefreshModuleRuntime = require('./runtime/RefreshModuleRuntime');
const RefreshModuleRuntimeString = Template.getFunctionContent(RefreshModuleRuntime);

Choose a reason for hiding this comment

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

I thought there was already a comment here about this, but if this line is safe to remove from the function, is there any reason the trim() or the replace calls can't also be brought out and only run once?

@gaearon
Copy link

gaearon commented Dec 15, 2019

This makes sense to me

@pmmmwh
Copy link
Owner

pmmmwh commented Dec 17, 2019

Thanks a lot for this - I can confirm it brings huge performance improvements to large projects I'm working on.

@pmmmwh pmmmwh changed the title fix: remove addDependency and only require RefreshModuleRuntime once fix: remove addDependency and only require RefreshModuleRuntime o… Dec 17, 2019
@pmmmwh pmmmwh merged commit c00d407 into pmmmwh:master Dec 17, 2019
@pmmmwh pmmmwh changed the title fix: remove addDependency and only require RefreshModuleRuntime o… fix: remove addDependency and only require RefreshModuleRuntime once Dec 17, 2019
@pmmmwh
Copy link
Owner

pmmmwh commented Dec 17, 2019

Shipped in v0.1.2 🎉

@mmhand123
Copy link
Contributor Author

Awesome! Thank you!

@mmhand123 mmhand123 deleted the fix/incremental-build-slowness branch December 17, 2019 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incremental build performance issues
4 participants