mirror of
https://github.com/status-im/react-native.git
synced 2025-02-25 15:45:32 +00:00
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
This commit is contained in:
parent
eb01f8fe59
commit
c2b3ee789c
@ -9,8 +9,23 @@
|
||||
|
||||
package com.facebook.react.devsupport;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
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.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.NotificationOnlyHandler;
|
||||
import com.facebook.react.packagerconnection.RequestHandler;
|
||||
import com.facebook.react.packagerconnection.RequestOnlyHandler;
|
||||
import com.facebook.react.packagerconnection.Responder;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
@ -18,31 +33,7 @@ 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.RequestOnlyHandler;
|
||||
import com.facebook.react.packagerconnection.Responder;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.ConnectionPool;
|
||||
@ -54,6 +45,9 @@ import okhttp3.Response;
|
||||
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 @@ public class DevServerHelper {
|
||||
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 @@ public class DevServerHelper {
|
||||
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 class DevServerHelper {
|
||||
mSettings.getPackagerConnectionSettings().getDebugServerHost(),
|
||||
jsModulePath,
|
||||
getDevMode(),
|
||||
getHMR(),
|
||||
getJSMinifyMode());
|
||||
}
|
||||
|
||||
@ -565,7 +550,6 @@ public class DevServerHelper {
|
||||
mSettings.getPackagerConnectionSettings().getDebugServerHost(),
|
||||
mainModuleName,
|
||||
getDevMode(),
|
||||
getHMR(),
|
||||
getJSMinifyMode());
|
||||
}
|
||||
|
||||
@ -576,7 +560,6 @@ public class DevServerHelper {
|
||||
mSettings.getPackagerConnectionSettings().getDebugServerHost(),
|
||||
mainModuleName,
|
||||
getDevMode(),
|
||||
getHMR(),
|
||||
getJSMinifyMode());
|
||||
}
|
||||
|
||||
@ -588,7 +571,6 @@ public class DevServerHelper {
|
||||
getHostForJSProxy(),
|
||||
mainModuleName,
|
||||
getDevMode(),
|
||||
getHMR(),
|
||||
getJSMinifyMode());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user