smallnew / react-native-multibundler Goto Github PK
View Code? Open in Web Editor NEWreact native可视化bundle拆包,支持远程加载和debug,支持官方的0.57~0.63.2版本,使用官方的metro拆包,适用于Android、iOS
License: MIT License
react native可视化bundle拆包,支持远程加载和debug,支持官方的0.57~0.63.2版本,使用官方的metro拆包,适用于Android、iOS
License: MIT License
platformEmptyDefaultExport 这个有什么用途呢
运行时报这个错 ,是什么原因Requiring unknown module "node_modules_react-navigation_src_react-navigation"
我把
比如我这边有三个包,一个基础包,两个业务包A和B,我现在的需求是业务包A里面需要引用业务包B里的js文件,请问可以这样吗?还是说要先加载业务包B,然后在加载业务包A,这样就可以?
Requiring unknown module "node_modules_@babel_runtime_helpers_interopRequireDefault"
大佬,打包之后加载业务包,提示这个错误,是什么原因呢?
我加上react-navigation这个包之后报错,
Requiring unknown module "node_modules_react-navigation_src_react-navigation"
感觉涉及这两个业务包根本没有他的功能了,我提到的这两个都只能放在基础包里面。。。或许只能修改源码了吧!
遇到几点疑问,需要和您交流以下。可以留下微信或qq联系方式吗?非常感谢。
iOS 打开的时候,显示这个报错
var _ = require('lodash');
Text.render = _.wrap(Text.render, function (func, ...args) {
let originText = func.apply(this, args)
return React.cloneElement(originText, {allowFontScaling: false})
})
请问platformDep.js中这段代码的作用是什么?望不吝赐教
希望大神就基础包打包配置,和业务包打包配置有更详细的说明和演示,比如加入第三方组件时要怎么配置?
相同名称的业务包从网络重新加载,界面不刷新,大神有没有碰到这种使用场景,怎么解决的
Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
Could not determine artifacts for com.facebook.fresco:fresco:1.10.0: Skipped due to earlier error
我是在native下载完包后把业务包里的图片都拷贝到基础包路径
你好,我也碰到同样的问题,能否分享一下具体做法???
Originally posted by @liyanfei1004774105 in #15 (comment)
Error message
'Cannot invoke completion without jsMessageThread'
RN_App.js
const ocFunction = NativeModules.OCFunction;
loadBundle() {
ocFunction.loadBizBundle(
'index2.ios',
'reactnative_multibundler2',
(bundle, module) => {
console.log(bundle + module);
},
);
}
iOS_OCFunction.h
#import <Foundation/Foundation.h>
#import <React/RCTBridgeModule.h>
NS_ASSUME_NONNULL_BEGIN
@interface OCFunction : NSObject<RCTBridgeModule>
@end
NS_ASSUME_NONNULL_END
iOS_OCFunction.m
#import "OCFunction.h"
@implementation OCFunction
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(loadBizBundle:(NSString *)bundle moduleName:(NSString *)module findEvents:(RCTResponseSenderBlock)callback)
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[[NSNotificationCenter defaultCenter]postNotificationName:@"loadBizBundle" object:@[bundle, module]];
callback(@[bundle, module]);
});
}
@end
iOS_AppDelegate.m
-(void)loadBundle:(NSNotification *)sender{
if ([sender.object isKindOfClass:[NSArray class]]) {
dispatch_async(dispatch_get_main_queue(), ^{
NSString *bundle = (NSString *) [sender.object objectAtIndex:0];
NSString *module = (NSString *) [sender.object objectAtIndex:1];
NSURL *jsCodeLocationBuz = [[NSBundle mainBundle] URLForResource:bundle withExtension:@"bundle"];
NSError *error = nil;
NSData *sourceBuz = [NSData dataWithContentsOfFile:jsCodeLocationBuz.path options:NSDataReadingMappedIfSafe error:&error];
[self->bridge.batchedBridge executeSourceCode:sourceBuz sync:NO];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:self->bridge moduleName:module initialProperties:nil];
UIViewController *controller = [UIViewController new];
[controller setView:rootView];
self.window.rootViewController = controller;
});
}
}
使用codepush热更新,更新完的assets中的图片无法加载,怎么解决跨域问题
离开应用后,再回到应用,就报java.lang.AssertionError: createReactContextInBackground should only be called when creating the react application for the first time. When reloading JS, e.g. from a new file, explicitlyuse recreateReactContextInBackground。
iOS打基础包,下载的工程可以,自建工程会报这个错,有遇到这个吗?
hi,大佬,请教一下这个现在06有问题么? 是否测试过啊,还更新么?
最新的rn项目中这个方法被取消了吗?
iOS打业务包后,图片只能引用到基础包asserts里面图片,请问需要怎么处理
通过alert可以看到图片路径是基础包asserts里面图片,而不是业务包里面的图片路径,从而导致图片显示不出来
RN拆包,debug是完全OK的,但是release爆了空指针异常,大概是什么问题呢?
java.lang.NullPointerException: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2911)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2989)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1680)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6707)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
Caused by: java.lang.NullPointerException: java.lang.NullPointerException
at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromFile(Native Method)
at com.facebook.react.bridge.CatalystInstanceImpl.loadScriptFromFile(CatalystInstanceImpl.java:224)
at club.fromfactory.baselibrary.utils.RNScriptLoadUtil.loadFile(RNScriptLoadUtil.java:78)
at club.fromfactory.baselibrary.utils.RNScriptLoadUtil.loadScriptFromFile(RNScriptLoadUtil.java:54)
谢谢大神分享的代码O(∩_∩)O
我的项目中使用了Redux,分包的时候是共用一份store吗?
还是建多个store,各用各的?
其中有一个reducer是用来做主题颜色切换的,所有的业务包都需要用到,这样的话只能共用一个store才能做到了。有没有更好的方式呢?
android项目中需要在fragment使用分包,不知道怎么处理
问题1: 使用介绍的方法打包,打出的platform包与原来的包有却别。这是正常的吗?
问题2: 打出的buz包,与原来包相比少了几个模块!且无法正常运行
遇到了这个问题,请问该怎么解决
package.json
{
"name": "App",
"version": "5.3.0",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
},
"dependencies": {
"club-rn-base": "^3.0.1"
},
"devDependencies": {
"babel-jest": "22.4.1",
"babel-plugin-transform-remove-console": "^6.9.4",
"babel-preset-react-native": "4.0.0",
"eslint": "^5.7.0",
"jest": "22.4.2",
"metro-react-native-babel-preset": "^0.52.0",
"react-test-renderer": "16.0.0",
"redux-logger": "^3.0.6"
},
"jest": {
"preset": "react-native"
}
}
基础包
"bundle-ios-platform": "node ./node_modules/react-native/local-cli/cli.js bundle --platform ios --dev false --entry-file platformDep.js --bundle-output ios/bundle/platform.jsbundle --assets-dest ./ios/ --config $(pwd)/platform57.config.js",
业务包
"bundle-ios-buz": "node ./node_modules/react-native/local-cli/cli.js bundle --platform ios --dev false --entry-file index.js --bundle-output ios/bundle/buz.jsbundle --assets-dest ./ios/ --config $(pwd)/buz57.config.js",
其中基础包配置 platformEmptyDefaultExport.js 中 必须要
import 'redux-logger'
因为业务包里用到了这个库,但这个库本应该在dev中,虽然业务包脚本指定了 --dev false,但为什么业务包中还是会用到呢?
我的理解是 如果指定 --dev false, 那么打包的时候会略过。
可能是因为现在业务包的配置没能忽略 devDependencies, 如果是这样,怎么配置忽略 devDependencies?
▸ Copying /Users/ryan/Downloads/react-native-multibundler-master/node_modules/react-native/ReactCommon/privatedata/PrivateDataBase.h
▸ Compiling PrivateDataBase.cpp
▸ Analyzing PrivateDataBase.cpp
▸ Building library libprivatedata.a
▸ Running script 'Install Third Party'
▸ Compiling fast-dtoa.cc
❌ error: Build input file cannot be found: '/Users/ryan/Downloads/react-native-multibundler-master/node_modules/react-native/third-party/double-conversion-1.1.6/src/fast-dtoa.cc'
▸ Compiling double-conversion.cc
❌ error: Build input file cannot be found: '/Users/ryan/Downloads/react-native-multibundler-master/node_modules/react-native/third-party/double-conversion-1.1.6/src/double-conversion.cc'
▸ Compiling fixed-dtoa.cc
❌ error: Build input file cannot be found: '/Users/ryan/Downloads/react-native-multibundler-master/node_modules/react-native/third-party/double-conversion-1.1.6/src/fixed-dtoa.cc'
▸ Compiling strtod.cc
❌ error: Build input file cannot be found: '/Users/ryan/Downloads/react-native-multibundler-master/node_modules/react-native/third-party/double-conversion-1.1.6/src/strtod.cc'
▸ Compiling diy-fp.cc
❌ error: Build input file cannot be found: '/Users/ryan/Downloads/react-native-multibundler-master/node_modules/react-native/third-party/double-conversion-1.1.6/src/diy-fp.cc'
▸ Compiling cached-powers.cc
❌ error: Build input file cannot be found: '/Users/ryan/Downloads/react-native-multibundler-master/node_modules/react-native/third-party/double-conversion-1.1.6/src/cached-powers.cc'
▸ Compiling bignum.cc
❌ error: Build input file cannot be found: '/Users/ryan/Downloads/react-native-multibundler-master/node_modules/react-native/third-party/double-conversion-1.1.6/src/bignum.cc'
▸ Compiling bignum-dtoa.cc
❌ error: Build input file cannot be found: '/Users/ryan/Downloads/react-native-multibundler-master/node_modules/react-native/third-party/double-conversion-1.1.6/src/bignum-dtoa.cc'
** BUILD FAILED **
The following build commands failed:
CompileC /Users/ryan/Downloads/react-native-multibundler-master/ios/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/double-conversion.build/Objects-normal/x86_64/fast-dtoa.o /Users/ryan/Downloads/react-native-multibundler-master/node_modules/react-native/third-party/double-conversion-1.1.6/src/fast-dtoa.cc normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
CompileC /Users/ryan/Downloads/react-native-multibundler-master/ios/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/double-conversion.build/Objects-normal/x86_64/double-conversion.o /Users/ryan/Downloads/react-native-multibundler-master/node_modules/react-native/third-party/double-conversion-1.1.6/src/double-conversion.cc normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
CompileC /Users/ryan/Downloads/react-native-multibundler-master/ios/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/double-conversion.build/Objects-normal/x86_64/fixed-dtoa.o /Users/ryan/Downloads/react-native-multibundler-master/node_modules/react-native/third-party/double-conversion-1.1.6/src/fixed-dtoa.cc normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
CompileC /Users/ryan/Downloads/react-native-multibundler-master/ios/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/double-conversion.build/Objects-normal/x86_64/strtod.o /Users/ryan/Downloads/react-native-multibundler-master/node_modules/react-native/third-party/double-conversion-1.1.6/src/strtod.cc normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
CompileC /Users/ryan/Downloads/react-native-multibundler-master/ios/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/double-conversion.build/Objects-normal/x86_64/diy-fp.o /Users/ryan/Downloads/react-native-multibundler-master/node_modules/react-native/third-party/double-conversion-1.1.6/src/diy-fp.cc normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
CompileC /Users/ryan/Downloads/react-native-multibundler-master/ios/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/double-conversion.build/Objects-normal/x86_64/cached-powers.o /Users/ryan/Downloads/react-native-multibundler-master/node_modules/react-native/third-party/double-conversion-1.1.6/src/cached-powers.cc normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
CompileC /Users/ryan/Downloads/react-native-multibundler-master/ios/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/double-conversion.build/Objects-normal/x86_64/bignum.o /Users/ryan/Downloads/react-native-multibundler-master/node_modules/react-native/third-party/double-conversion-1.1.6/src/bignum.cc normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
CompileC /Users/ryan/Downloads/react-native-multibundler-master/ios/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/double-conversion.build/Objects-normal/x86_64/bignum-dtoa.o /Users/ryan/Downloads/react-native-multibundler-master/node_modules/react-native/third-party/double-conversion-1.1.6/src/bignum-dtoa.cc normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
(8 failures)
Installing build/Build/Products/Debug-iphonesimulator/reactnative_multibundler.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=22):
Failed to install the requested application
The bundle identifier of the application could not be determined.
Ensure that the application's Info.plist contains a value for CFBundleIdentifier.
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/reactnative_multibundler.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Error: Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/reactnative_multibundler.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
at checkExecSyncError (child_process.js:603:11)
at Object.execFileSync (child_process.js:621:13)
at Promise.then (/Users/ryan/Downloads/react-native-multibundler-master/node_modules/react-native/local-cli/runIOS/runIOS.js:208:5)
at process._tickCallback (internal/process/next_tick.js:68:7)
Process: com.yuebaoxiaov2, PID: 31654
java.lang.RuntimeException: com.facebook.react.devsupport.JSException: Can't find variable: __d
at com.facebook.react.bridge.DefaultNativeModuleCallExceptionHandler.handleException(DefaultNativeModuleCallExceptionHandler.java:22)
at com.facebook.react.devsupport.DisabledDevSupportManager.handleException(DisabledDevSupportManager.java:170)
at com.facebook.react.bridge.CatalystInstanceImpl.onNativeException(CatalystInstanceImpl.java:547)
at com.facebook.react.bridge.CatalystInstanceImpl.access$1000(CatalystInstanceImpl.java:44)
at com.facebook.react.bridge.CatalystInstanceImpl$NativeExceptionHandler.handleException(CatalystInstanceImpl.java:563)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:148)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:818)
Caused by: com.facebook.react.devsupport.JSException: Can't find variable: __d
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
at android.os.Looper.loop(Looper.java:148)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:818)
Caused by: com.facebook.jni.CppException: Can't find variable: __d
global [email protected]:2:4
I tried to split by bundles, and when do the bridge initialization, it's take 1 ~ 2s. The white screen is occurred longer than I though. Is there a way to speed up?
我照着你这样写只能加载一个业务包,加载第二个的时候就会报 Application has not been registered. 请问可能的问题有哪些
node ./node_modules/react-native/local-cli/cli.js bundle --platform android --dev false --entry-file index.js --bundle-output ./android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/ --config /{你的绝对路径}/buz57.config.js
将 index 都换成 index3 打包出来的 包大小不对, 运行报错
react-native-multibundler-master/ios/assets: No such file or directory 报这个错误
感谢感谢
com.facebook.react.common.JavascriptException: Requiring unknown module "node_modules_@babel_runtime_helpers_taggedTemplateLiteralLoose".
我这是ios的工程, 如果我在这个demo目录下直接npm start, 里面的模块会加载失败, 请问这种多模块的开发要怎么弄
你好,有个问题请教一下。
在有多个业务包的情况下,每个业务包内都有几个页面,那么如何判断某个页面属于哪个业务包?这样根据要进入页面加载对应的业务包。按Demo的做法是在原生侧写死了业务包和对应的页面,这样会限制在js侧动态添加、删除页面,是否能支持在打开RN页面之前,先从js侧读取最新的业务包-页面对应表,然后再加载对应的业务包?
能否告知下解决方案?
react-native版本号
[email protected]
├── [email protected]
└─┬ [email protected]
└── [email protected]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.