0.5.0 • Published 9 years ago

node-kpc v0.5.0

Weekly downloads
5
License
BSD-3-Clause
Repository
github
Last release
9 years ago

KPC

Build a KISSY package, for KISSY 1.3+.

build status

Features

  • Simple
  • KISSY 1.3+
  • Online combo only
  • Support CJS Style
  • Support Module Name Flatten
  • Support KISSY.add auto generate for no-kissy module

Installation

This module is installed via npm:

$ npm install node-kpc

API

kpc.build(options, files)

  • options.name, String, Name of package, required
  • options.path, String, Path of package, required
  • options.flatten, Boolean, false, 是否压缩模块名, optional
  • files Array|String, Files to compile, optional

kpc.compile(options, files)

  • options.name, String, Name of package, required
  • options.path, String, Path of package, required
  • options.flatten, Boolean, false, 是否压缩模块名, optional
  • files Array|String, Files to compile, optional
  • Return Object

kpc.generateDepFile(modules);

  • modules Object, the module object compiled
  • return String

Example Usage

Case1. Build all file in a Package

var kpc = require('node-kpc');

// build a package
kpc.build({
    pkg: {
        name: 'xcake',
        path: 'sample/src'
    },
    dest: 'sample/build', // where the package is build to
    depFile: 'sample/build/map.js'
});

Case2. Specify Files to build

var kpc = require('node-kpc');

// build a package
kpc.build({
    pkg: {
        name: 'xcake',
        path: 'sample/src'
    },
    dest: 'sample/build', // where the package is build to
    depFile: 'sample/build/map.js' //
}, ['sample/src/app/*.js']);

After build:

Case3. Compile a package (all file in package path)

var kpc = require('node-kpc');

var pkg = kpc.compile({
    name: 'xcake',
    path: 'sample/src'
});

console.log(pkg);

```

the pkg look like this

```json
{
    "files": [
        {
            "srcCode": "/**\n * @fi...",
            "isKISSY": true,
            "modules": [
                {
                    "name": "xcake/app/cjs",
                    "requires": [
                        "node",
                        "../components/header/",
                        "./mod/",
                        "./example.css"
                    ]
                }
            ],
            "genCode": "/**\n * @fi...",
            "filename": "app/cjs.js",
            "srcFile": "sample/src/app/cjs.js"
        }
    ],
    "ignoredFiles": [],
    "modules": {
        "xcake/app/cjs": {
            "requires": [
                "node",
                "../components/header/",
                "./mod/",
                "./example.css"
            ]
        }
    }
}
```

#### Case5. Specify files to compile

````js
var kpc = require('node-kpc');

var pkg = kpc.compile({
    name: 'xcake',
    path: 'sample/src'
}, ['sample/src/app/*']);

console.log(pkg);

```
0.5.0

9 years ago

0.4.0

10 years ago

0.3.12

10 years ago

0.3.11

10 years ago

0.3.10

10 years ago

0.3.9

10 years ago

0.3.7

10 years ago

0.3.6

10 years ago

0.3.5

10 years ago

0.3.4

10 years ago

0.3.3

10 years ago

0.3.2

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.1.3

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago