Comments (21)
比如我一个工程里的platformDep.js,把需要依赖的第三方module都在这个js import
import'prop-types';
import'react';
import'react-native';
import'react-native-badge-avatar';
import'react-native-calendars';
import'react-native-linear-gradient';
import'react-native-md5';
import'react-native-scrollable-tab-view';
import'react-native-splash-screen';
import'react-native-storage';
import'react-native-vector-icons';
import'react-navigation';
import'react-redux';
import'realm';
import'redux';
import'redux-logger';
import'redux-thunk';
import'urlencode';
import'antd-mobile-rn';
import'moment';
import 'react-native-code-push';
import React,{Component} from "react";
import {Text} from "react-native";
var _ = require('lodash');
Text.render = _.wrap(Text.render, function (func, ...args) {
let originText = func.apply(this, args)
return React.cloneElement(originText, {allowFontScaling: false})
})
from react-native-multibundler.
你的情况好像是打包基础包的时候没有修改 platformDep.js文件让基础包依赖react-navigation
from react-native-multibundler.
只能在platformDep.js里面依赖打进基础包吗,像这种第三方组件能打进业务包里面吗
from react-native-multibundler.
可以打进业务包,但是你要修改buz57.config.js的postProcessModulesFilter方法,不让该方法过滤你的第三方组件
from react-native-multibundler.
好的,我去试一下,多谢!
from react-native-multibundler.
不是特别明白使用第三方组件时怎么配置,大神帮帮忙demo里加上第三方组件,演示一下怎么配置奥?
from react-native-multibundler.
我按作者的方法不过滤第三方组件会出现一堆奇怪的报错,但是把第三方组件打到基础包里是可以的,所以还需要作者帮忙看一下怎么搞 @smallnew
from react-native-multibundler.
这样不就是把第三方包打进基础包里了吗,我按你说的修改buz57.config.js的postProcessModulesFilter方法不过滤第三方组件,会发生一些奇怪的错误,这个有什么解决方法吗?
from react-native-multibundler.
log?
from react-native-multibundler.
微信就不加了啊,你需要往业务包加react-navigation,现在的做法还是比较麻烦,我先给你配置,后面我再搞个工具自动配置。
业务包加react-navigation第三方module如下
const pathSep = require('path').sep;
const noFilterModules = ['react-navigation','clamp','create-react-context',
'hoist-non-react-statics','path-to-regexp','query-string','react-lifecycles-compat',
'react-native-safe-area-view','react-native-screens','react-navigation-deprecated-tab-navigator',
'react-navigation-drawer','react-navigation-stack','react-navigation-tabs',
'decode-uri-component','strict-uri-encode','isarray','hoist-non-react-statics',
'react-native-tab-view','react-native-drawer-layout-polyfill','react-navigation-stack',
'gud'
];//这里全是react-navigation所依赖的库名称
function packageToBundle(path){
for(let i=0;i<noFilterModules.length;i++) {
let moduleName = noFilterModules[i];
if (path.indexOf(pathSep + 'node_modules' + pathSep + moduleName) > 0) {
return true;
}
}
return false;
}
function postProcessModulesFilter(module) {//返回false则过滤不编译
const projectRootPath = __dirname;
if(module['path'].indexOf('prelude')>=0){
return false;
}
if(module['path'].indexOf(pathSep+'node_modules'+pathSep)>0){
if(packageToBundle(module['path'])){
return true;
}
if('js'+pathSep+'script'+pathSep+'virtual'==module['output'][0]['type']){
return true;
}
return false;
}
return true;
}
function createModuleIdFactory() {
const projectRootPath = __dirname;
return path => {
//console.log('path ',path);
let name = '';
if(path.indexOf('node_modules'+pathSep+'react-native'+pathSep+'Libraries'+pathSep)>0){
name = path.substr(path.lastIndexOf(pathSep)+1);
}else if(path.indexOf(projectRootPath)==0){
name = path.substr(projectRootPath.length+1);
}
name = name.replace('.js','');
name = name.replace('.png','');
name = name.replace(new RegExp(pathSep,"gm"),'_');
return name;
};
}
module.exports = {
serializer: {
createModuleIdFactory:createModuleIdFactory,
processModuleFilter:postProcessModulesFilter
/* serializer options */
}
};
from react-native-multibundler.
现在项目已经添加了UI打包功能,可以自动计算第三方依赖,试试看吧
from react-native-multibundler.
现在项目已经添加了UI打包功能,可以自动计算第三方依赖,试试看吧
你这样应该会有一些包同时被打包进入plat包和buz包吧?应该把plat包中的module id记录下来,打buz包过滤记录id,这样比较合理简单吧。
from react-native-multibundler.
现在项目已经添加了UI打包功能,可以自动计算第三方依赖,试试看吧
你这样应该会有一些包同时被打包进入plat包和buz包吧?应该把plat包中的module id记录下来,打buz包过滤记录id,这样比较合理简单吧。
首先,使用UI打包的时候最好基础包和业务包不要勾选重复的module,然后内部我也做了过滤,你打基础包的时候我会把module名添加计算基础包所有依赖的module然后去重
from react-native-multibundler.
ui打包工具报错,我的mac pro 系统的 10.14.2 (18C54)
from react-native-multibundler.
提交可执行文件node_module被过滤了,我改成压缩包吧
from react-native-multibundler.
改好上传了
from react-native-multibundler.
解压完是空白的
from react-native-multibundler.
解压完是空白的
单独下载试试,我看有大小的 八十多MB
from react-native-multibundler.
解压完是空白的
单独下载试试,我看有大小的 八十多MB
我下载下来看了,都是空白啊
from react-native-multibundler.
@smallnew 还是想请教下作者,这一段
if (path.indexOf('node_modules' + pathSep + 'react-native' + pathSep + 'Libraries' + pathSep) > 0) {
name = path.substr(path.lastIndexOf(pathSep) + 1);
} else if (path.indexOf(projectRootPath) == 0) {
name = path.substr(projectRootPath.length + 1);
}
为什么还需要单独判断下 node_modules/react-native/Libraries/
路径
from react-native-multibundler.
把下面这个条件删掉,业务包是不是就能包含第三方包了?这样所有的node_modules会被打进去吗?业务包体积变大?
module['path'].indexOf(pathSep+'node_modules'+pathSep)>0
from react-native-multibundler.
Related Issues (20)
- Buz1Activity cannot be cast to androidx.appcompat.app.AppCompatActivity
- RN 0.68.2 以及0.68.3版本使用路径作为ID ,打包出现问题
- useIndex设置为false,加载业务包出错
- rn 0.64 android 打出的jsbundle 有raw文件,ios 没有
- 请问 multibundler/platformNameMap.json 这个文件是如何生成的? HOT 2
- 请问基础bundle需要做更新逻辑吗,如果业务Abundle 依赖基础bundle更新策略是什么呢 HOT 1
- 想要加载其他rn项目的bundle文件应该怎么做呢 HOT 1
- 没有执行预加载的代码会报错 HOT 3
- SmartAssets 本地资源路径 HOT 2
- ModuleIdConfig.json 配置超过index3.js比方说index4打出来的bundle不能用
- 'text' has not been registered,this can happen if*Metro(the local dev server)is run from the wrong folder...... HOT 1
- SmartAssets的问题 HOT 3
- Swfit项目使用0.63.2版本创建RCTBridge对象会卡死 HOT 2
- ios的资源可以更新吗 在拆包后
- iOS远程加载bundle失败的问题 HOT 1
- 使用DEBUG模式调试,出现错误 HOT 6
- English translation
- Hot Reload Mode
- rn 选择0.66,打出的基础包和业务包有问题 HOT 11
- 拆包之后common和业务会分别有一个source Map文件,用于堆栈反混淆。有没有办法将两个source Map文件合并呀?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-multibundler.