Git Product home page Git Product logo

moles-packer's Introduction

Moles Packer

Join the chat at https://gitter.im/ctripcorp/moles-packer

Moles Packer is a light-weighted builder for React Native projects. You can create bundle(s), including a common (basic) bundle and one or more business bundles, from a standard React Native proejct. If pre-built common bundle supplied, you can also create business bundle from a stripped project (without ios, android, node_modules etc.).

Moles Packer is one of the key members in the Moles's tool chain.

Together with growing React Native, Moles Packer is also under continuous development and improvement, see ChangeLog for more details.

React Native Versions Supported

  • 0.28.0-rc0
  • 0.28.0
  • 0.29.0
  • 0.30.0-rc0
  • 0.37.0 *

* means this version got limited support.

Install

NPM

# install globally
npm install -g moles-packer

# command created
moles-packer -v
moles-packer-common -v

Run In CLI

# create an
react-native init rn28 --version 0.28.0

# build the project by Moles Packer
moles-packer \
	--input ./rn28 \
	--entry index.ios.js \
	--output ./build \
	--bundle \
    --verbose

Node.js API

var mp = require('moles-packer');
var options = {
    'input'   : './rn28',
    'entry'   : 'index.ios.js',
    'output'  : './build',
    'bundle'  : true
    };
mp.pack(options, function(err) {
    // !err means build success.
});

User Manual

About Us

Moles is developed and maintained by Framework R&D from ctrip.com.

Any questions, please send mail to [email protected].

Welcome to follow us in WeChat:
CtripMoles

moles-packer's People

Contributors

ctrip-moles avatar everplus avatar gitter-badger avatar youngoat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

moles-packer's Issues

命令行拆包报错

start ... fs.js:651
  var r = binding.read(fd, buffer, offset, length, position);
                  ^

Error: EISDIR: illegal operation on a directory, read
    at Error (native)
    at Object.fs.readSync (fs.js:651:19)
    at Object.fs.readFileSync (fs.js:472:24)
    at _one (/usr/local/lib/node_modules/moles-packer/lib/transform.js:101:20)
    at _ME (/usr/local/lib/node_modules/moles-packer/lib/transform.js:51:9)
    at _ME (/usr/local/lib/node_modules/moles-packer/lib/pack.js:25:5)
    at Object.<anonymous> (/usr/local/lib/node_modules/moles-packer/bin/pack.js:4:1)
    at Module._compile (module.js:398:26)
    at Object.Module._extensions..js (module.js:405:10)
    at Module.load (module.js:344:32)

最后报错是这样的?

-- v0.4.1 发布,暨项目仍在继续维护 --

很抱歉,很久没有发布更新了。这次的补丁版本,解决了自 react native v0.31.0 开始出现的兼容性问题。@wagon 计划本周会推出 ios 版本的模块加载器,让我们一起期待。

BTW,为了验证工具的可用性,我们忠实记录了从项目创建、构建到运行的整个过程,形成文档“从零开始”,欢迎指正:
https://youngoat.gitbooks.io/moles-unprofessional-guide/content/zh-cn/moles-packer.quickstart.html

致歉 AND 我们将继续维护本项目

因为种种原因,本项目的后续开发和维护停顿了一段时间,也没有及时回复各位开发者的提问。本周我们将重启本项目的维护和后续开发。

Can't find image asset when packing the bundle

I use in my login component like below:
<Image source={require('image!login-background')} style={{flexDirection: 'row',flex:1,resizeMode:'contain',alignSelf:'center'}} onProgress={this._onImageLoad.bind(this) }> {content} </Image>

The command I used to pack the bundle:
moles-packer --input ./ --entry index.ios.js --output ./build --bundle bu.bundle --common true

but I got the output:
[PACKER] Required "image!login-background" not found in "/Users/project/test/login/login.js"

And when the packing process is done, I only see common.jsbundle file, I didn't find the bu.bundle file, does this mean the packing process failed?

据说携程内部已经放弃moles-packer方案了?

我看了携程技术中心最新的分享,已经开始使用unbundle和prepack方案,另外最新的携程包打开就是unbundle方案了,请问是moles-packer在使用过程中有什么难解决的问题吗?

看了你们的dome我有一些疑问

demos下面的项目里面并没有关于拆包的任何命令可以查看,进去是一头雾水,不知道怎么进行拆包,都是拆好的,也不知道如何下手,能写一个详细的配置步骤或者很全面的dome吗?

require package 各种错误啊

Error: Cannot find module '../node_modules/babel-preset-es2015'
at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at _transform_react (/Users/fri3nds/coding/react-native-examples/AwesomeProject/node_modules/moles-packer/lib/transform.js:139:22)

我个人是用 npm script 来用的,

 "deploy": "moles-packer --entry index.ios.js --platform ios --standlone --output ./build --verbose"

首先是 yuancon 莫名其妙的只调用 node_modules 下的 react-native 命令,然后是
node_modules/moles-packer/lib/transform.js 中为什么 require babel plugin 相对路径

    console.log(process.cwd(), __dirname, '============');
    var result = babel.transform(info.code, {
        'presets': [ require('../node_modules/babel-preset-es2015'), require('../node_modules/babel-preset-stage-0'), require('../node_modules/babel-preset-react') ],
        'plugins': [ require('../node_modules/babel-plugin-transform-es5-property-mutators'), require('../node_modules/babel-plugin-transform-class-properties') ]
    });

moles-packer --entry index.ios.js --platform ios --standalone --output ./build --verbose 拆包错误

moles-packer --entry index.ios.js --platform ios --standalone --output ./build --verbose
[MOLES_PACKER] -- options parsed --

name value


base "/Users/iwangx/Cai8"
bundle true
commonOutput "BASE/build/moles.common"
dev false
entry "BASE/index.ios.js"
execOnRequired false
input "BASE/"
isCLI true
metaOutput "BASE/build/moles.meta.json"
minify false
output "BASE/build"
platform "ios"
single false
standalone true
verbose true

[MOLES_PACKER] -- Process common bundle --
[COMMON] Create common bundle ( ios )
[2017-02-09 08:55:23] Building Dependency Graph
[2017-02-09 08:55:23] Crawling File System
[2017-02-09 08:55:23] Finding dependencies
[2017-02-09 08:55:40] Crawling File System (17570ms)
[2017-02-09 08:55:40] Building in-memory fs for JavaScript
[2017-02-09 08:55:41] Building in-memory fs for JavaScript (928ms)
[2017-02-09 08:55:41] Building in-memory fs for Assets
[2017-02-09 08:55:42] Building in-memory fs for Assets (689ms)
[2017-02-09 08:55:42] Building Haste Map
[2017-02-09 08:55:42] Building (deprecated) Asset Map
[2017-02-09 08:55:43] Building (deprecated) Asset Map (295ms)
[2017-02-09 08:55:43] Building Haste Map (1506ms)
[2017-02-09 08:55:43] Building Dependency Graph (20717ms)

[2017-02-09 08:55:57] Finding dependencies (34611ms)
bundle: start
bundle: finish
bundle: Writing bundle output to: .moles/common.ios.jsbundle
bundle: Writing sourcemap output to: .moles/common.ios.sourcemap.json
bundle: Done writing sourcemap output
bundle: Done writing bundle output
[COMMON] Re-create common bundle ( ios )
[COMMON] Minify common bundle ( ios )
[COMMON] COMMON BUNDLE: /Users/iwangx/Cai8/build/moles.common/common.ios.jsbundle ( ios )
[COMMON] COMMON META: /Users/iwangx/Cai8/build/moles.common/common.ios.json ( cross )
[MOLES_PACKER] Common modules ready.
[MOLES_PACKER] -- Process business code --
[SOURCE] index.ios.js ( entry )
[SOURCE] src/index.js ( normal )
[SOURCE] node_modules/react-redux/lib/index.js ( normal )
[SOURCE] src/store/index.js ( normal )
[SOURCE] src/common/common.js ( normal )
[SOURCE] src/component/navigation.js ( normal )
[SOURCE] node_modules/react-redux/lib/components/Provider.js ( normal )
[SOURCE] node_modules/react-redux/lib/components/connect.js ( normal )
[SOURCE] node_modules/redux/lib/index.js ( normal )
[SOURCE] node_modules/redux-thunk/lib/index.js ( normal )
[SOURCE] node_modules/redux-persist/lib/index.js ( normal )
[SOURCE] src/reducer/index.js ( normal )
[SOURCE] node_modules/redux-persist/constants.js ( normal )
[SOURCE] src/config/config.js ( normal )
start ... react / es2015 ... cmd2amd ...
[MOLES_PACKER] Required "../../config" not found in "/Users/iwangx/Cai8/src/config/config.js"

[MOLES_PACKER] Terminated with error.

"/Users/iwangx/Cai8/src/config/config.js" 文件中的 "../../config" 引用一直报没有找到,是不是跟文件名称有关系?

0.4.1拆包报错

moles-packer --entry index.ios.js --platform ios --standalone --output ./build --verbose

[MOLES_PACKER] -- options parsed --

name value


base "/Users/iwangx/Cai8"
bundle true
commonOutput "BASE/build/moles.common"
dev false
entry "BASE/index.ios.js"
execOnRequired false
input "BASE/"
isCLI true
metaOutput "BASE/build/moles.meta.json"
minify false
output "BASE/build"
platform "ios"
single false
standalone true
verbose true

[MOLES_PACKER] -- Process common bundle --

[MOLES_PACKER] Failed to run command "react-native", try to reinstall module named "react-native-cli".


Command failed: react-native -v

  error: unknown option `-v'

[MOLES_PACKER] Terminated with error.

然而执行 react-native -v结果:

iwangx$ react-native -v
react-native-cli: 2.0.1
react-native: 0.35.0 

不知道错在哪里了

使用0.4.1出现的问题

image

错误提示如下:
[MOLES_PACKER] -- options parsed --

name value


base "/Users/xxx/ReactNative/v031"
bundle true
commonOutput "BASE/build/moles.common"
dev false
entry "BASE/index.ios.js"
execOnRequired false
input "BASE/"
isCLI true
metaOutput "BASE/build/moles.meta.json"
minify false
output "BASE/build"
platform "ios"
single false
standalone true
verbose true

[MOLES_PACKER] -- Process common bundle --
module.js:474
throw err;
^

Error: Cannot find module 'node-haste/lib/DependencyGraph/docblock.js'
at Function.Module._resolveFilename (module.js:472:15)
at Function.Module._load (module.js:420:25)
at Module.require (module.js:500:17)
at require (internal/module.js:20:19)
at _create_common (/usr/local/lib/node_modules/moles-packer/lib/packCommon.js:37:17)
at _ME (/usr/local/lib/node_modules/moles-packer/lib/packCommon.js:282:18)
at _ME (/usr/local/lib/node_modules/moles-packer/lib/pack.js:22:22)
at Object. (/usr/local/lib/node_modules/moles-packer/bin/pack.js:4:1)
at Module._compile (module.js:573:32)
at Object.Module._extensions..js (module.js:582:10)

打包就报错

Cannot find module 'node-haste/lib/DependencyGraph/docblock.js' 这个是因为喔安装出错了吗,少文件了吗?

命令参数不生效

--bundle xx.jsbundle 打出来的文件始终是index.jsbundle
--common false 每次仍然会打common包

拆包时有的图片找不到

[MOLES_PACKER] Resources related to "Image.Asset, ../../../image/lottery/history/lt-history-baskit-icon.png" required by "/Users/iwangx/Cai8/src/view/lottery/history/list.js" not found.

[MOLES_PACKER] Terminated with error.

图片明明在那,却找不到

error: unknown option `--minify'

moles-packer在打包过程中似乎用到了react-native bundle --minify 参数 在react-native0.31.0上已经不支持该参数了,求解决,日志如下:

COMMAND EXECUTION FAILED. By YC.RUN

[MOLES_PACKER] Failed to create common bundle.


Command failed: react-native bundle --entry-file .moles/index.common.js --bundle-output .moles/common.ios.jsbundle --platform  ios --dev false --minify false --verbose true --sourcemap-output .moles/common.ios.sourcemap.json

  error: unknown option `--minify'

打包失败各种问题

通过 https://github.com/ctripcorp/moles-packer/blob/master/README.md 这个指导 使用中还是遇到一些问题

通过指导安装完毕后
警告

image

image

安装成功 取了官方的demo做实验

文件结构
image

在上层 demo 目录下 执行 moles-packer --input ./demo --entry index.ios.js --output ./build —standalone

image

在demo/demo/ios 目录下 moles-packer --input ./demo --entry /Users/BHT/Documents/XQ_RN_Workspace/demo/demo/index.ios.js --output ./build —standalone

image

这些问题是怎么引起的? 是我使用的不对么?

打包失败,没有log信息

打包命令:
moles-packer --input ./ --entry index.android.js --output ../build --bundle bu.bundle --common true
log信息:
[MOLES_PACKER] -- Process common bundle --

[MOLES_PACKER] Failed to create common bundle.

[MOLES_PACKER] Terminated with error.

应用程序接口拆包报错

var mp = require('moles-packer');

var options = {
    'entry': 'index.ios.js',
    "platform": "ios",
    'output': './build',
    'bundle': true,
    'common-bundle': true,
    "verbose":true,
    "single":false,
    "minify":true,
    "standalone":false
};

var promise = mp.pack(options, function () {
});

promise
    .then(function () {

    })
    .catch(function (err) {
        console.log(err)
    });

这样拆包的时候报错:
[SOURCE] index.ios.js ( entry )
start ... react / es2015 ... [ReferenceError: Unknown plugin "transform-class-properties" specified in "base" at 1, attempted to resolve relative to "/Users/iwangx/Cai8"]

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.