Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kmc

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kmc - npm Package Compare versions

Comparing version 1.0.17 to 1.0.19

test/src/package1/error.js

0

examples/build-with-module-name.js

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,1 +1,13 @@

## 2013.11.09, Version 1.0.19(Stable)
### enhancement
- issue #32: 解析css文件的具体信息
## 2013.11.05, Version 1.0.18(Stable)
### enhancement
- issue #24 #25: js文件解析出错时抛出异常
## 2013.10.29, Version 1.0.16(Stable)

@@ -2,0 +14,0 @@

1

index.js

@@ -50,3 +50,2 @@ /**

var c = new Compiler(self._config);
console.log(c.modules);
return c.analyze(inputFile);

@@ -53,0 +52,0 @@ },

@@ -68,5 +68,3 @@ /**

var self = this;
if(requiredModule.match(/\.css/)){
return requiredModule;
}else if(requiredModule.match(/^\./) && _.isObject(parentModule)){
if(requiredModule.match(/^\./) && _.isObject(parentModule)){
return path.resolve(path.dirname(parentModule.path), utils.addPathSuffix(requiredModule));

@@ -104,5 +102,2 @@ }else if(!requiredModule.match(/\//) || requiredModule.match(/^gallery\//)){

modPkg = null;
if(path.extname(filePath) == '.css'){
return 'css';
}
if(filePath.match(/^[a-zA-Z]+$/)){

@@ -232,2 +227,3 @@ return 'kissy';

modPkg,
modType,
modRealPath;

@@ -263,12 +259,2 @@ if(!inputFilePath) return null;

break;
case 'css':
// TODO
mod = {
name: inputFilePath,
pkg: null,
type: 'css',
status: ''
};
self.modules[mod.name] = mod;
break;
default :

@@ -284,8 +270,14 @@ // get module real path based on package path.

self.fileList.push(modRealPath);
// get this file's dependencies.
modRequires = dependencies(modRealPath);
// if user named module himself, use his name. map rules will not work then.
if(_.isPlainObject(modRequires) && modRequires.name){
modName = modRequires.name;
modRequires = modRequires.deps;
if(!modRealPath.match(/\.css$/)){
// get this file's dependencies.
modRequires = dependencies(modRealPath);
// if user named module himself, use his name. map rules will not work then.
if(_.isPlainObject(modRequires) && modRequires.name){
modName = modRequires.name;
modRequires = modRequires.deps;
}
modType = 'js';
}else{
modRequires = [];
modType = 'css';
}

@@ -302,16 +294,19 @@ var isModExcluded = self._isModuleExcluded(modName);

dependencyTree: {},
charset: modPkg.charset
charset: modPkg.charset,
type: modType
};
self.modules[modName] = mod;
// analyze sub modules' dependencies recursively.
_.forEach(modRequires, function(subModPath){
var subMod = self.analyze(self._getModuleRealPathByParent(subModPath, mod));
if(subMod){
mod.dependencies.push(subMod);
mod.dependencyTree[subMod.name] = subMod.dependencyTree;
}
});
if(modType === 'js'){
// analyze sub modules' dependencies recursively.
_.forEach(modRequires, function(subModPath){
var subMod = self.analyze(self._getModuleRealPathByParent(subModPath, mod));
if(subMod){
mod.dependencies.push(subMod);
mod.dependencyTree[subMod.name] = subMod.dependencyTree;
}
});
!isModExcluded && self.analyzedModules.push(modName);
!isModExcluded && self.analyzedModules.push(modName);
}
}else{

@@ -318,0 +313,0 @@ mod = self.modules[modName];

@@ -17,51 +17,50 @@ /**

call_expression = null,
obj_expression = null,
startTime = +new Date();
obj_expression = null;
var walker = new UglifyJS.TreeWalker(function(node, descend) {
if(node instanceof UglifyJS.AST_Call && (node.start.value == 'KISSY' || node.start.value == 'S') && node.expression && node.expression.property == 'add'){
var tmp = call_expression;
call_expression = node;
descend();
call_expression = tmp;
return true;
}
if(ast){
var walker = new UglifyJS.TreeWalker(function(node, descend) {
if(node instanceof UglifyJS.AST_Call && (node.start.value == 'KISSY' || node.start.value == 'S') && node.expression && node.expression.property == 'add'){
var tmp = call_expression;
call_expression = node;
descend();
call_expression = tmp;
return true;
}
if(node instanceof UglifyJS.AST_String && call_expression && obj_expression === null){
moduleName = node.getValue();
if(node instanceof UglifyJS.AST_String && call_expression && obj_expression === null){
moduleName = node.getValue();
// console.log('Found Module ID: ' + moduleName);
}
}
if(node instanceof UglifyJS.AST_Lambda && call_expression){
var tmp = call_expression;
call_expression = null;
descend();
call_expression = tmp;
if(node instanceof UglifyJS.AST_Lambda && call_expression){
var tmp = call_expression;
call_expression = null;
descend();
call_expression = tmp;
// console.log('Found Lambda');
return true;
}
return true;
}
if(node instanceof UglifyJS.AST_ObjectKeyVal && call_expression && obj_expression === null){
if(node.key && node.key === 'requires'){
if(node instanceof UglifyJS.AST_ObjectKeyVal && call_expression && obj_expression === null){
if(node.key && node.key === 'requires'){
// console.log('Found requires');
var tmp = obj_expression;
obj_expression = node;
descend();
obj_expression = null;
return true;
var tmp = obj_expression;
obj_expression = node;
descend();
obj_expression = null;
return true;
}
}
}
if(node instanceof UglifyJS.AST_String && call_expression && obj_expression){
var mod = node.getValue();
deps.push(mod);
if(node instanceof UglifyJS.AST_String && call_expression && obj_expression){
var mod = node.getValue();
deps.push(mod);
// console.log('Found required module: ' + mod);
}
});
}
});
ast.walk(walker);
ast.walk(walker);
}
// console.log('Use time: ' + (+ new Date() - startTime));
return moduleName ? { name: moduleName, deps: deps } :deps;
};

@@ -0,0 +0,0 @@ var fs = require('fs'),

@@ -15,9 +15,18 @@ /**

var fileContent = '';
if (fs.existsSync(inputFile)) {
inputFile = fs.readFileSync(inputFile, 'utf-8');
fileContent = fs.readFileSync(inputFile, 'utf-8');
}
return UglifyJS.parse(inputFile, {
comments: true
});
try{
return UglifyJS.parse(fileContent, {
comments: true
});
}catch(e){
e.message = 'file parse error.';
e.detail = e.message;
e.filePath = inputFile;
throw new Error(e);
}
};

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -110,3 +110,3 @@ var fs = require('fs'),

addPathSuffix: function(filePath){
return filePath.replace(/\/$/, '/index.js').replace(/\.js$/, '') + '.js';
return filePath.match(/\.css$/) ? filePath : filePath.replace(/\/$/, '/index.js').replace(/\.js$/, '') + '.js';
},

@@ -113,0 +113,0 @@ traverseDirSync: function(dir, traverse){

@@ -0,0 +0,0 @@ The MIT License

{
"name":"kmc",
"version":"1.0.17",
"version":"1.0.19",
"description":"KISSY Module Compiler",

@@ -5,0 +5,0 @@ "author":"daxingplay <daxingplay@gmail.com>",

@@ -0,0 +0,0 @@ # ModuleCompiler

@@ -795,2 +795,69 @@ /**

describe('When parsing process has an error', function(){
var result;
var hasError = false;
var inputFile = path.resolve(srcPath, 'package1/error.js'),
outputFile = path.resolve(distPath, 'package1/error.js');
before(function(){
ModuleCompiler.config({
packages: [{
name: 'package1',
path: srcPath
}],
silent: true
});
try{
result = ModuleCompiler.build(inputFile, outputFile);
}catch(e){
hasError = true;
}
});
after(function(){
ModuleCompiler.clean();
});
it('should throw error.', function(){
hasError.should.equal(true);
});
});
describe('When modules have css files', function(){
var result;
var hasError = false;
var inputFile = path.resolve(srcPath, 'package1/require-css.js'),
outputFile = path.resolve(distPath, 'package1/require-css.js');
before(function(){
ModuleCompiler.config({
packages: [{
name: 'package1',
path: srcPath
}],
silent: true
});
result = ModuleCompiler.build(inputFile, outputFile);
});
after(function(){
ModuleCompiler.clean();
});
it('should resolve css files.', function(){
var mod = result.files[0];
var dep = mod.dependencies[0];
var depModName = dep.name;
/package1/.test(mod.name).should.equal(true);
/package1/.test(depModName).should.equal(true);
dep.type.should.equal('css');
});
});
//describe('When build a directory and have ignore config', function(){

@@ -797,0 +864,0 @@ // var result;

@@ -0,0 +0,0 @@ KISSY.add(function(){

KISSY.add(function(){
return 'hello b'
});

@@ -0,0 +0,0 @@ /*

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc