Code Monkey home page Code Monkey logo

kmc's People

Contributors

daxingplay avatar dickeylth avatar gitter-badger avatar guangwong avatar jayli avatar jdz321 avatar shepherdwind avatar xspider avatar yiminghe avatar yuanyan 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kmc's Issues

支持打包kissy的模块

需求来源于承玉
支持把一些kissy本身的模块打包到用户的脚本中,比如dom、event等,需要注意的是分析这些的依赖的时候一个文件内可能有很多的子模块

目标文件没有找到的时候有报错!

ubuntu 12.04 LTS
node:0.8.2
module-compiler:0.0.5

/home/qiaofu/node_modules/module-compiler/lib/index.js:471
        !self._config.silent && console.info('[err]'.bold.red + ' cannot f

TypeError: Cannot read property 'silent' of undefined

分析依赖需要遍历所有子目录

@拔赤 的需求,遍历文件夹的时候需要遍历所有的子目录,这样,每个模块文件都可以单独被use,讨论了一下,打包的时候单独增加一个参数解决这个问题。

添加silent配置,完全关闭控制台输出, 将打包信息输出为reporter

{
  mods: [{
    output: '/xx/page/xx-out.js', //输出
    name: 'page/xx',              // 主模块名
    path: '/path/to/mod',         // 路径
    submods: [
      {                           //所有被打包进来的模块
        name: 'utils/mods/a',     //被依赖模块名
        path: '/path/to/mod',     // 被依赖模块的路径 path of mods package
        status: 'ok'              // 模块状态 如: missing, ok, error
      },
      {
        name: 'utils/mods/a',     //被依赖模块名
        path: '/path/to/mod',     // 被依赖模块的路径 path of mods package
        status: 'ok'              // 模块状态 如: missing, ok, error
      }
    ]
  }]
}

KISSY.NodeList.add方法导致模块无法被打包

例子:

KISSY.add(function(S) {
var triggers = S.all('.selector1').add('.selector2');
....
});

由于代码中调用了这个add方法,会导致整个模块无法被打包,但不会终端整个打包流程(感觉像是跳过了该模块)。

文件出错时请抛出异常

正常打包不管是否有错都一路成功,不仔细看 log 的话看不到有问题。。。所以,如果有文件错误的话直接抛出来个异常停止掉好了

Unsafe use of eval

In file lib/index.js the following use of eval is dangerous

var requiredModules = eval('(' + requires[i]).requires;

A malicious package may place a require clause that would lead to code execution. Either validate all inputs passed to eval using a regex or use a more advanced sanitization library like:
https://github.com/cristianstaicu/eval-sanitizer

支持打包包名同名模块

比如

.
|-- menu.js
`-- src
    `-- control.js

这么配置:

kmc.config({
            packages: [{
                name: 'menu',
                path: './src',
                charset: 'gbk',
                ignorePackageNameInUri: true
            }]
        });

kmc.build('./menu.js')

那么menu.js的模块名就是menu/../menu,这是因为menu.js文件在包的外面所以不被支持。

理论上这种应该也是支持的:

KISSY.use('menu')

也应该use到这个模块

四个场景的bug

项目地址:http://gitlab.taobao.ali.com/trip/h5-tt/tree/daily/0.0.21

场景1

配置:

options: {
    // depFilePath:'build/deps.js',
    comboOnly: false,
    fixModuleName:true,
    comboMap: false,
    packages: [
        {
            name: '<%= pkg.name %>',
            path: './src',
            charset:'utf-8',
            ignorePackageNameInUri:true
        }
    ],
},

main: {
    files: [
        {
            expand: true,
            cwd: 'src/',
            src: [ '**/*.js', '!Gruntfile.js', '!libs/**/*'],
            dest: 'build/'
        }
    ]
}

输出

.
├── config.js
├── mods
│   ├── footer
│   │   └── index.js
│   └── header
│       └── index.js
├── pages
│   ├── detail
│   │   └── index.js
│   ├── list
│   │   ├── index.js
│   │   └── mock.js
│   └── telephone
│       └── index.js
├── test
│   └── abc
│       └── index.js
└── widgets
    ├── scroll-list
    │   └── 1.0
    │       └── index.js
    └── tabview
        └── 1.0
            └── index.js
  • 错误:文件结构正确,为什么comboOnly:false,每个文件都执行了静态合并
  • 应该只补全modName

场景2

options: {
    depFilePath:'build/deps.js',
    comboOnly: false,
    fixModuleName:true,
    comboMap: false,
    packages: [
        {
            name: '<%= pkg.name %>',
            path: './src',
            charset:'utf-8',
            ignorePackageNameInUri:true
        }
    ],
},

main: {
    files: [
        {
            expand: true,
            cwd: 'src/',
            src: [ '**/*.js', '!Gruntfile.js', '!libs/**/*'],
            dest: 'build/'
        }
    ]
}

输出结果

├── test
│   └── abc
│       ├── build
│       │   └── deps.js
│       └── index.js
  • 为什么每个index.js所在目录下会多一个build/deps.js

场景3

options: {
    depFilePath:'build/deps.js',
    comboOnly: false,
    fixModuleName:true,
    comboMap: true,
    packages: [
        {
            name: '<%= pkg.name %>',
            path: './src',
            charset:'utf-8',
            ignorePackageNameInUri:true
        }
    ],
},

main: {
    files: [
        {
            expand: true,
            cwd: 'src/',
            src: [ '**/*.js', '!Gruntfile.js', '!libs/**/*'],
            dest: 'build/'
        }
    ]
}

输出结果

├── build
│   └── deps.js
├── config.js
├── deps.js
├── mods
│   ├── footer
│   │   ├── build
│   │   │   └── deps.js
│   │   └── index.js
│   └── header
│       ├── build
│       │   └── deps.js
│       └── index.js
├── pages
│   ├── detail
│   │   ├── build
│   │   │   └── deps.js
│   │   └── index.js
│   └── telephone
│       ├── build
│       │   └── deps.js
│       └── index.js
├── test
│   └── abc
│       ├── build
│       │   └── deps.js
│       └── index.js
└── widgets
    ├── autocomplete
    │   └── 1.0
    │       ├── build
    │       │   └── deps.js
    │       └── index.js
    └── tabview
        └── 1.0
            ├── build
            │   └── deps.js
            └── index.js
  • 错误1:每个index.js旁边的build/deps.js不应该出现
  • 错误2:每个index.js不应该被静态合并(因为comboOnly:fase)

场景4

options: {
    depFilePath:'build/deps.js',
    comboOnly: true,
    fixModuleName:true,
    comboMap: true,
    packages: [
        {
            name: '<%= pkg.name %>',
            path: './src',
            charset:'utf-8',
            ignorePackageNameInUri:true
        }
    ],
},
main: {
    files: [
        {
            expand: true,
            cwd: 'src/',
            src: [ '**/*.js', '!Gruntfile.js', '!libs/**/*'],
            dest: 'build/'
        }
    ]
}

结果:

├── config.js
├── deps.js
├── mods
│   └── header
│       └── mods
│           └── header
│               └── index.js
├── pages
│   ├── detail
│   │   └── pages
│   │       └── detail
│   │           └── index.js
│   ├── global
│   │   └── pages
│   │       └── global
│   │           └── index.js
│   ├── list
│   │   └── pages
│   │       ├── global
│   │       │   └── index.js
│   │       └── list
│   │           ├── index.js
│   │           └── mock.js
│   ├── news
│   │   └── pages
│   │       └── news
│   │           └── index.js
│   ├── news-list
│   │   └── pages
│   │       └── news-list
│   │           └── index.js
│   ├── query
│   │   ├── pages
│   │   │   ├── global
│   │   │   │   └── index.js
│   │   │   └── query
│   │   │       └── index.js
│   │   └── widgets
│   │       ├── checkbox
│   │       │   └── 1.0
│   │       │       └── index.js
│   │       └── radio
│   │           └── 1.0
│   │               └── index.js
│   ├── station
│   │   ├── pages
│   │   │   ├── global
│   │   │   │   └── index.js
│   │   │   └── station
│   │   │       └── index.js
│   │   └── widgets
│   │       ├── autocomplete
│   │       │   └── 1.0
│   │       │       └── index.js
│   │       ├── scroll-list
│   │       │   └── 1.0
│   │       │       └── index.js
│   │       └── tabview
│   │           └── 1.0
│   │               └── index.js
│   └── telephone
│       └── pages
│           └── telephone
│               └── index.js
├── test
│   └── abc
│       └── test
│           └── abc
│               └── index.js
└── widgets
    ├── autocomplete
    │   └── 1.0
    │       └── widgets
    │           └── autocomplete
    │               └── 1.0
    │                   └── index.js
    ├── checkbox
    │   └── 1.0
    │       └── widgets
    │           └── checkbox
    │               └── 1.0
    │                   └── index.js
    ├── loading
    │   └── 1.0
    │       └── widgets
    │           └── loading
    │               └── 1.0
    │                   └── index.js
    ├── radio
    │   └── 1.0
    │       └── widgets
    │           └── radio
    │               └── 1.0
    │                   └── index.js
    ├── scroll-list
    │   └── 1.0
    │       └── widgets
    │           └── scroll-list
    │               └── 1.0
    │                   └── index.js
    └── tabview
        └── 1.0
            └── widgets
                └── tabview
                    └── 1.0
                        └── index.js
  • 文件结构乱掉了
  • deps.js 是正确的

require分析bug

{ 'requires': } 的方式(requires前面有引号之类的)解析会有问题

支持kissy 1.3+的包配置方式

即支持下面的这种配置包的方式:

KISSY.config({
    packages:{
        x:{
            // x 包的基准路径
            base:'http://x.com/biz/',
            // x 包的时间戳
            tag:'x',
            // 开启 x 包 debug 模式
            debug:true
        },
        y:{
           // y 包的基准路径
           base:'http://x.com/biz/',
           // y 包不开启自动 combo
           combine:false
           // 不配置 tag,则取 kissy 内置模块的时间戳
        }
    }
}

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.