Skip to content

Hot reload #1786

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

Merged
merged 23 commits into from
Aug 28, 2018
Merged

Hot reload #1786

merged 23 commits into from
Aug 28, 2018

Conversation

samogot
Copy link
Contributor

@samogot samogot commented Aug 23, 2018

Added --hot-reload cli option and appropriate functionality.

samogot added 21 commits August 7, 2018 10:23
This entry point will be used for hot reloading, in order to initially
retrieve digests of all assets, as build_runner might not know list of
all of them, unlike client.
Instead of just 'update' emit json with updated build results and its
digests
# Conflicts:
#	build_runner/lib/src/server/server.dart
It is expected that client code will become complicated, so in separate
dart file it would be easier to test and maintain.
Reload any changed modules without any specific order, then reload main
module and call main func to hopefully apply changes.

Still need to get module dependency graph to reload in topological order
and find correct ancessor chain where reloaded modules can be saved in
closures.
We still lack handling situations when graph is dynamically updated
between reloads.
- Get rid of `roughLibraryKeyDecode` - use library path exposed from
  dart runtime now.
- Get load modules from cache directly and throw if it isn't loaded
  instead of using require.js and hoping that module already loaded and
  no network request would be done.
- Don't mess with `.ddc` extension in `build_runner` code - encapsulate
  all of it on build_web_compilers side.

Fixes #1760
Fixes #1762
- Rename live-reload to hot-reload
- Add debug logging about reloading
- Add documentation
- Version bump and changelog

Fixes #1766
@samogot samogot requested review from jakemac53 and natebosch August 23, 2018 20:54
@googlebot googlebot added the cla: yes Google is happy with the PR contributors label Aug 23, 2018
var moduleValues =
List<HotReloadableLibrary>.from(_jsObjectValues(moduleObj));
var moduleLibraries = moduleValues.map((x) => LibraryWrapper(x));
var module = Module(Map.fromIterables(moduleKeys, moduleLibraries));
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: just return directly here

var moduleObj = dartLoader.getModuleLibraries(moduleId);
if (moduleObj == null) {
throw HotReloadFailedException("Failed to get module '$moduleId'. "
"This error might appear if such module doesn't exist or isn't alredy loaded");
Copy link
Contributor

Choose a reason for hiding this comment

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

sp: already

(path) => dartLoader.urlToModuleId.get(currentOrigin + path), manager);

var webSocket =
WebSocket('ws://' + window.location.host, [_buildUpdatesProtocol]);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: use string interpolation 'ws://${window.location.host}'

@@ -1,5 +1,5 @@
name: build_web_compilers
version: 0.4.3-dev
Copy link
Contributor

Choose a reason for hiding this comment

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

did 0.4.3 get released? We can roll this into it if not.

@samogot samogot merged commit ab759a7 into master Aug 28, 2018
@samogot samogot deleted the hot-reload branch August 28, 2018 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Google is happy with the PR contributors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants