Permalink
Browse files

Do not send 'hot' parameter when requesting a bundle from Android

Summary:
Since the `hot` parameter is not used anymore in metro-bundler (we are always applying the HMR transforms for bundlers requested through the HTTP server), we can remove it from the client request URL.

This allows us to reduce the metro-bundler memory by half when switching between HMR and not-HMR, since metro caches the bundles based on the requested URL path.

Reviewed By: davidaurelio

Differential Revision: D5630051

fbshipit-source-id: fb5dce4c31bbb38b1c0c93c97a525a992b2f6d8d
  • Loading branch information...
rafeca authored and facebook-github-bot committed Aug 16, 2017
1 parent eb01f8f commit c2b3ee789c6f7088f4b580de45980828ffcd0e0f
Showing with 14 additions and 32 deletions.
  1. +14 −32 ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java
@@ -9,40 +9,31 @@
package com.facebook.react.devsupport;
import javax.annotation.Nullable;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Handler;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.common.network.OkHttpCallUtil;
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
import com.facebook.react.devsupport.interfaces.PackagerStatusCallback;
import com.facebook.react.devsupport.interfaces.StackFrame;
import com.facebook.react.modules.systeminfo.AndroidInfoHelpers;
import com.facebook.react.packagerconnection.FileIoHandler;
import com.facebook.react.packagerconnection.JSPackagerClient;
import com.facebook.react.packagerconnection.RequestHandler;
import com.facebook.react.packagerconnection.NotificationOnlyHandler;
import com.facebook.react.packagerconnection.RequestHandler;
import com.facebook.react.packagerconnection.RequestOnlyHandler;
import com.facebook.react.packagerconnection.Responder;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.ConnectionPool;
@@ -54,6 +45,9 @@
import okhttp3.ResponseBody;
import okio.Okio;
import okio.Sink;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/**
* Helper class for all things about the debug server running in the engineer's host machine.
@@ -69,7 +63,7 @@
private static final String RELOAD_APP_ACTION_SUFFIX = ".RELOAD_APP_ACTION";
private static final String BUNDLE_URL_FORMAT =
"http://%s/%s.bundle?platform=android&dev=%s&hot=%s&minify=%s";
"http://%s/%s.bundle?platform=android&dev=%s&minify=%s";
private static final String RESOURCE_URL_FORMAT = "http://%s/%s";
private static final String SOURCE_MAP_URL_FORMAT =
BUNDLE_URL_FORMAT.replaceFirst("\\.bundle", ".map");
@@ -368,20 +362,12 @@ private boolean getJSMinifyMode() {
return mSettings.isJSMinifyEnabled();
}
/**
* @return whether we should enabled HMR when requesting JS bundles.
*/
private boolean getHMR() {
return mSettings.isHotModuleReplacementEnabled();
}
private static String createBundleURL(
String host,
String jsModulePath,
boolean devMode,
boolean hmr,
boolean jsMinify) {
return String.format(Locale.US, BUNDLE_URL_FORMAT, host, jsModulePath, devMode, hmr, jsMinify);
return String.format(Locale.US, BUNDLE_URL_FORMAT, host, jsModulePath, devMode, jsMinify);
}
private static String createResourceURL(String host, String resourcePath) {
@@ -401,7 +387,6 @@ public String getDevServerBundleURL(final String jsModulePath) {
mSettings.getPackagerConnectionSettings().getDebugServerHost(),
jsModulePath,
getDevMode(),
getHMR(),
getJSMinifyMode());
}
@@ -565,7 +550,6 @@ public String getSourceMapUrl(String mainModuleName) {
mSettings.getPackagerConnectionSettings().getDebugServerHost(),
mainModuleName,
getDevMode(),
getHMR(),
getJSMinifyMode());
}
@@ -576,7 +560,6 @@ public String getSourceUrl(String mainModuleName) {
mSettings.getPackagerConnectionSettings().getDebugServerHost(),
mainModuleName,
getDevMode(),
getHMR(),
getJSMinifyMode());
}
@@ -588,7 +571,6 @@ public String getJSBundleURLForRemoteDebugging(String mainModuleName) {
getHostForJSProxy(),
mainModuleName,
getDevMode(),
getHMR(),
getJSMinifyMode());
}

0 comments on commit c2b3ee7

Please sign in to comment.