mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Remove DevSplitBundleLoader
Summary: Changelog: [General][Removed] Remove internal DevSplitBundleLoader native module `DevSplitBundleLoader` was part of an experimental bundling strategy that offloaded Hermes bytecode compilation to the packager server. The React Native parts of this experiment were never part of the public API, and the Metro parts never fully shipped in open source. As part of implementing the simpler and more general [lazy bundling RFC](https://github.com/react-native-community/discussions-and-proposals/pull/605), we are removing `DevSplitBundleLoader` and associated code from React Native's internals. Reviewed By: robhogan Differential Revision: D43597007 fbshipit-source-id: 1460e9045cd7a0f5ef43144b10afb932172e223c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
fdb2af5bf1
commit
6dcdb93ec0
@@ -1,19 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict
|
||||
* @format
|
||||
*/
|
||||
|
||||
import type {TurboModule} from '../TurboModule/RCTExport';
|
||||
|
||||
import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
|
||||
|
||||
export interface Spec extends TurboModule {
|
||||
+loadBundle: (bundlePath: string) => Promise<void>;
|
||||
}
|
||||
|
||||
export default (TurboModuleRegistry.get<Spec>('DevSplitBundleLoader'): ?Spec);
|
||||
@@ -110,9 +110,6 @@ rn_apple_library(
|
||||
) + react_module_plugin_providers(
|
||||
name = "DevLoadingView",
|
||||
native_class_func = "RCTDevLoadingViewCls",
|
||||
) + react_module_plugin_providers(
|
||||
name = "DevSplitBundleLoader",
|
||||
native_class_func = "RCTDevSplitBundleLoaderCls",
|
||||
) + react_module_plugin_providers(
|
||||
name = "EventDispatcher",
|
||||
native_class_func = "RCTEventDispatcherCls",
|
||||
|
||||
@@ -51,7 +51,6 @@ Class RCTLogBoxCls(void) __attribute__((used));
|
||||
Class RCTWebSocketExecutorCls(void) __attribute__((used));
|
||||
Class RCTWebSocketModuleCls(void) __attribute__((used));
|
||||
Class RCTDevLoadingViewCls(void) __attribute__((used));
|
||||
Class RCTDevSplitBundleLoaderCls(void) __attribute__((used));
|
||||
Class RCTEventDispatcherCls(void) __attribute__((used));
|
||||
Class RCTBlobManagerCls(void) __attribute__((used));
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ Class RCTCoreModulesClassProvider(const char *name) {
|
||||
{"WebSocketExecutor", RCTWebSocketExecutorCls},
|
||||
{"WebSocketModule", RCTWebSocketModuleCls},
|
||||
{"DevLoadingView", RCTDevLoadingViewCls},
|
||||
{"DevSplitBundleLoader", RCTDevSplitBundleLoaderCls},
|
||||
{"EventDispatcher", RCTEventDispatcherCls},
|
||||
{"BlobModule", RCTBlobManagerCls},
|
||||
};
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <React/RCTBridgeModule.h>
|
||||
#import <React/RCTJSScriptLoaderModule.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface RCTDevSplitBundleLoader : NSObject <RCTBridgeModule, RCTJSScriptLoaderModule>
|
||||
@end
|
||||
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <React/RCTDevSplitBundleLoader.h>
|
||||
|
||||
#import <FBReactNativeSpec/FBReactNativeSpec.h>
|
||||
#import <React/RCTBridge.h>
|
||||
#import <React/RCTBundleURLProvider.h>
|
||||
#import <React/RCTConvert.h>
|
||||
#import <React/RCTDefines.h>
|
||||
#import <React/RCTDevSettings.h>
|
||||
#import <React/RCTUtils.h>
|
||||
|
||||
#import "CoreModulesPlugins.h"
|
||||
|
||||
using namespace facebook::react;
|
||||
|
||||
@interface RCTDevSplitBundleLoader () <NativeDevSplitBundleLoaderSpec>
|
||||
@end
|
||||
|
||||
#if RCT_DEV_MENU | RCT_PACKAGER_LOADING_FUNCTIONALITY
|
||||
|
||||
@implementation RCTDevSplitBundleLoader
|
||||
|
||||
@synthesize bridge = _bridge;
|
||||
@synthesize loadScript = _loadScript;
|
||||
@synthesize moduleRegistry = _moduleRegistry;
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
+ (BOOL)requiresMainQueueSetup
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(loadBundle
|
||||
: (NSString *)bundlePath resolve
|
||||
: (RCTPromiseResolveBlock)resolve reject
|
||||
: (RCTPromiseRejectBlock)reject)
|
||||
{
|
||||
NSURL *sourceURL = [[RCTBundleURLProvider sharedSettings] jsBundleURLForSplitBundleRoot:bundlePath];
|
||||
if (_bridge) {
|
||||
[_bridge loadAndExecuteSplitBundleURL:sourceURL
|
||||
onError:^(NSError *error) {
|
||||
reject(@"E_BUNDLE_LOAD_ERROR", [error localizedDescription], error);
|
||||
}
|
||||
onComplete:^() {
|
||||
resolve(@YES);
|
||||
}];
|
||||
} else {
|
||||
__weak __typeof(self) weakSelf = self;
|
||||
[RCTJavaScriptLoader loadBundleAtURL:sourceURL
|
||||
onProgress:^(RCTLoadingProgress *progressData) {
|
||||
// TODO: Setup loading bar.
|
||||
}
|
||||
onComplete:^(NSError *error, RCTSource *source) {
|
||||
if (error) {
|
||||
reject(@"E_BUNDLE_LOAD_ERROR", [error localizedDescription], error);
|
||||
return;
|
||||
}
|
||||
__typeof(self) strongSelf = weakSelf;
|
||||
if (strongSelf) {
|
||||
strongSelf->_loadScript(source);
|
||||
RCTDevSettings *devSettings = [strongSelf->_moduleRegistry moduleForName:"RCTDevSettings"];
|
||||
[devSettings setupHMRClientWithAdditionalBundleURL:source.url];
|
||||
resolve(@YES);
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (std::shared_ptr<TurboModule>)getTurboModule:(const ObjCTurboModule::InitParams &)params
|
||||
{
|
||||
return std::make_shared<NativeDevSplitBundleLoaderSpecJSI>(params);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#else
|
||||
|
||||
@implementation RCTDevSplitBundleLoader
|
||||
|
||||
@synthesize loadScript = _loadScript;
|
||||
|
||||
+ (NSString *)moduleName
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
- (void)loadBundle:(NSString *)bundlePath resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject;
|
||||
{
|
||||
}
|
||||
- (std::shared_ptr<TurboModule>)getTurboModule:(const ObjCTurboModule::InitParams &)params
|
||||
{
|
||||
return std::make_shared<NativeDevSplitBundleLoaderSpecJSI>(params);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
Class RCTDevSplitBundleLoaderCls(void)
|
||||
{
|
||||
return RCTDevSplitBundleLoader.class;
|
||||
}
|
||||
@@ -39,7 +39,6 @@ rn_android_library(
|
||||
react_native_target("java/com/facebook/react/module/model:model"),
|
||||
react_native_target("java/com/facebook/react/modules/appearance:appearance"),
|
||||
react_native_target("java/com/facebook/react/modules/appregistry:appregistry"),
|
||||
react_native_target("java/com/facebook/react/modules/bundleloader:bundleloader"),
|
||||
react_native_target("java/com/facebook/react/modules/debug:debug"),
|
||||
react_native_target("java/com/facebook/react/modules/debug:interfaces"),
|
||||
react_native_target("java/com/facebook/react/modules/deviceinfo:deviceinfo"),
|
||||
|
||||
-6
@@ -21,7 +21,6 @@ import com.facebook.react.module.annotations.ReactModule;
|
||||
import com.facebook.react.module.annotations.ReactModuleList;
|
||||
import com.facebook.react.module.model.ReactModuleInfo;
|
||||
import com.facebook.react.module.model.ReactModuleInfoProvider;
|
||||
import com.facebook.react.modules.bundleloader.NativeDevSplitBundleLoaderModule;
|
||||
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
|
||||
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
||||
import com.facebook.react.modules.core.ExceptionsManagerModule;
|
||||
@@ -57,7 +56,6 @@ import java.util.Map;
|
||||
SourceCodeModule.class,
|
||||
TimingModule.class,
|
||||
UIManagerModule.class,
|
||||
NativeDevSplitBundleLoaderModule.class,
|
||||
})
|
||||
public class CoreModulesPackage extends TurboReactPackage implements ReactPackageLogger {
|
||||
|
||||
@@ -103,7 +101,6 @@ public class CoreModulesPackage extends TurboReactPackage implements ReactPackag
|
||||
SourceCodeModule.class,
|
||||
TimingModule.class,
|
||||
UIManagerModule.class,
|
||||
NativeDevSplitBundleLoaderModule.class,
|
||||
};
|
||||
|
||||
final Map<String, ReactModuleInfo> reactModuleInfoMap = new HashMap<>();
|
||||
@@ -160,9 +157,6 @@ public class CoreModulesPackage extends TurboReactPackage implements ReactPackag
|
||||
return createUIManager(reactContext);
|
||||
case DeviceInfoModule.NAME:
|
||||
return new DeviceInfoModule(reactContext);
|
||||
case NativeDevSplitBundleLoaderModule.NAME:
|
||||
return new NativeDevSplitBundleLoaderModule(
|
||||
reactContext, mReactInstanceManager.getDevSupportManager());
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"In CoreModulesPackage, could not find Native module for " + name);
|
||||
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_root_target", "react_native_target", "rn_android_library")
|
||||
|
||||
rn_android_library(
|
||||
name = "bundleloader",
|
||||
srcs = glob(["*.java"]),
|
||||
autoglob = False,
|
||||
labels = [
|
||||
"pfh:ReactNative_CommonInfrastructurePlaceholder",
|
||||
],
|
||||
language = "JAVA",
|
||||
visibility = [
|
||||
"PUBLIC",
|
||||
],
|
||||
deps = [
|
||||
react_native_dep("third-party/android/androidx:annotation"),
|
||||
react_native_target("java/com/facebook/react/bridge:bridge"),
|
||||
react_native_target("java/com/facebook/react/common:common"),
|
||||
react_native_target("java/com/facebook/react/devsupport:interfaces"),
|
||||
react_native_target("java/com/facebook/react/module/annotations:annotations"),
|
||||
],
|
||||
exported_deps = [react_native_root_target(":FBReactNativeSpec")],
|
||||
)
|
||||
-50
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.modules.bundleloader;
|
||||
|
||||
import com.facebook.fbreact.specs.NativeDevSplitBundleLoaderSpec;
|
||||
import com.facebook.react.bridge.Promise;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.common.DebugServerException;
|
||||
import com.facebook.react.devsupport.interfaces.DevSplitBundleCallback;
|
||||
import com.facebook.react.devsupport.interfaces.DevSupportManager;
|
||||
import com.facebook.react.module.annotations.ReactModule;
|
||||
|
||||
@ReactModule(name = NativeDevSplitBundleLoaderSpec.NAME)
|
||||
public class NativeDevSplitBundleLoaderModule extends NativeDevSplitBundleLoaderSpec {
|
||||
private static final String REJECTION_CODE = "E_BUNDLE_LOAD_ERROR";
|
||||
|
||||
private final DevSupportManager mDevSupportManager;
|
||||
|
||||
public NativeDevSplitBundleLoaderModule(
|
||||
ReactApplicationContext reactContext, DevSupportManager devSupportManager) {
|
||||
super(reactContext);
|
||||
mDevSupportManager = devSupportManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadBundle(String bundlePath, final Promise promise) {
|
||||
mDevSupportManager.loadSplitBundleFromServer(
|
||||
bundlePath,
|
||||
new DevSplitBundleCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
promise.resolve(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String url, Throwable cause) {
|
||||
String message =
|
||||
cause instanceof DebugServerException
|
||||
? ((DebugServerException) cause).getOriginalMessage()
|
||||
: "Unknown error fetching '" + url + "'.";
|
||||
promise.reject(REJECTION_CODE, message, cause);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user