Giter Club home page Giter Club logo

Comments (21)

smallnew avatar smallnew commented on May 29, 2024 6

比如我一个工程里的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.

smallnew avatar smallnew commented on May 29, 2024

你的情况好像是打包基础包的时候没有修改 platformDep.js文件让基础包依赖react-navigation

from react-native-multibundler.

kongdongdong avatar kongdongdong commented on May 29, 2024

只能在platformDep.js里面依赖打进基础包吗,像这种第三方组件能打进业务包里面吗

from react-native-multibundler.

smallnew avatar smallnew commented on May 29, 2024

可以打进业务包,但是你要修改buz57.config.js的postProcessModulesFilter方法,不让该方法过滤你的第三方组件

from react-native-multibundler.

kongdongdong avatar kongdongdong commented on May 29, 2024

好的,我去试一下,多谢!

from react-native-multibundler.

feige-2011 avatar feige-2011 commented on May 29, 2024

不是特别明白使用第三方组件时怎么配置,大神帮帮忙demo里加上第三方组件,演示一下怎么配置奥?

from react-native-multibundler.

kongdongdong avatar kongdongdong commented on May 29, 2024

我按作者的方法不过滤第三方组件会出现一堆奇怪的报错,但是把第三方组件打到基础包里是可以的,所以还需要作者帮忙看一下怎么搞 @smallnew

from react-native-multibundler.

kongdongdong avatar kongdongdong commented on May 29, 2024

这样不就是把第三方包打进基础包里了吗,我按你说的修改buz57.config.js的postProcessModulesFilter方法不过滤第三方组件,会发生一些奇怪的错误,这个有什么解决方法吗?

from react-native-multibundler.

smallnew avatar smallnew commented on May 29, 2024

log?

from react-native-multibundler.

smallnew avatar smallnew commented on May 29, 2024

微信就不加了啊,你需要往业务包加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.

smallnew avatar smallnew commented on May 29, 2024

现在项目已经添加了UI打包功能,可以自动计算第三方依赖,试试看吧

from react-native-multibundler.

hxkuan avatar hxkuan commented on May 29, 2024

现在项目已经添加了UI打包功能,可以自动计算第三方依赖,试试看吧

你这样应该会有一些包同时被打包进入plat包和buz包吧?应该把plat包中的module id记录下来,打buz包过滤记录id,这样比较合理简单吧。

from react-native-multibundler.

smallnew avatar smallnew commented on May 29, 2024

现在项目已经添加了UI打包功能,可以自动计算第三方依赖,试试看吧

你这样应该会有一些包同时被打包进入plat包和buz包吧?应该把plat包中的module id记录下来,打buz包过滤记录id,这样比较合理简单吧。

首先,使用UI打包的时候最好基础包和业务包不要勾选重复的module,然后内部我也做了过滤,你打基础包的时候我会把module名添加计算基础包所有依赖的module然后去重

from react-native-multibundler.

kongdongdong avatar kongdongdong commented on May 29, 2024

ui打包工具报错,我的mac pro 系统的 10.14.2 (18C54)
qq20190220-102604 2x

from react-native-multibundler.

smallnew avatar smallnew commented on May 29, 2024

提交可执行文件node_module被过滤了,我改成压缩包吧

from react-native-multibundler.

smallnew avatar smallnew commented on May 29, 2024

ui打包工具报错,我的mac pro 系统的 10.14.2 (18C54)
qq20190220-102604 2x

改好上传了

from react-native-multibundler.

kongdongdong avatar kongdongdong commented on May 29, 2024

解压完是空白的

from react-native-multibundler.

smallnew avatar smallnew commented on May 29, 2024

解压完是空白的

单独下载试试,我看有大小的 八十多MB

from react-native-multibundler.

kongdongdong avatar kongdongdong commented on May 29, 2024

解压完是空白的

单独下载试试,我看有大小的 八十多MB

我下载下来看了,都是空白啊

from react-native-multibundler.

seuzxh avatar seuzxh commented on May 29, 2024

@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.

ruyadelaosan avatar ruyadelaosan commented on May 29, 2024

把下面这个条件删掉,业务包是不是就能包含第三方包了?这样所有的node_modules会被打进去吗?业务包体积变大?
module['path'].indexOf(pathSep+'node_modules'+pathSep)>0

from react-native-multibundler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.