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

kmc

Package Overview
Dependencies
Maintainers
2
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.34 to 1.0.35

test/src/package1/pkgNameWithSlash.js

6

HISTORY.md

@@ -0,1 +1,7 @@

## 2014.04.14, Version 1.0.35(Stable)
### bugfix
- issue #44: 修复包名.js文件模块名错误
## 2014.02.20, Version 1.0.34(Stable)

@@ -2,0 +8,0 @@

5

index.js

@@ -132,3 +132,4 @@ /**

if(depFile){
utils.writeFileSync(path.resolve(path.dirname(outputFilePath), depFile), utils.joinCombo(combo), outputCharset);
utils.writeFileSync(path.resolve(path.dirname(outputFilePath), depFile),
utils.joinCombo(combo,path.extname(depFile)==='.json'), outputCharset);
}

@@ -156,3 +157,3 @@

var result = c.analyze(inputFile);
content = c.combo(fixModuleName, outputDir,comboOnly);
content = c.combo(fixModuleName, outputDir,comboOnly,path.extname(depFileName)==='.json');
if(content && depFileName){

@@ -159,0 +160,0 @@ utils.writeFileSync(depFileName, content, depFileCharset);

18

lib/compiler.js

@@ -134,3 +134,3 @@ /**

isBelongPkg = true;
} else if (pkg.ignorePackageNameInUri && dirname.indexOf(pkg.path) > -1) {
} else if (pkg.ignorePackageNameInUri && (dirname.indexOf(pkg.path) > -1 || path.basename(filePath, '.js') === pkg.name)) {
//增加ignorePackageNameInUri支持,使用路径判断,如果pkg.path和

@@ -167,3 +167,3 @@ //filePath的路径进行对比

}
return moduleName.replace(/\.js$/i, '');
return path.normalize(moduleName.replace(/\.js$/i, ''));
};

@@ -424,3 +424,3 @@ Compiler.prototype._buildCombo = function(mod){

};
Compiler.prototype.combo = function(fixModuleName, outputDir ,comboOnly){
Compiler.prototype.combo = function(fixModuleName, outputDir ,comboOnly, isJson){
var self = this;

@@ -441,3 +441,8 @@ var content = [];

});
content.push("'" + modName + "': { requires: [" + requires.join(', ') + "]}");
if(isJson){
content.push("\"" + modName + "\": [\"" + requires.join("\", \"") + "\"]");
}else{
content.push("'" + modName + "': { requires: ['" + requires.join("', '") + "']}");
}
}

@@ -477,3 +482,6 @@ if(fixModuleName === true && mod && mod.path){

}
return content.length ? "KISSY.config('modules', {" + os.EOL + " " + content.join("," + os.EOL + " ") + " " + os.EOL + "});" : "";
var json="{" + os.EOL + " " + content.join("," + os.EOL + " ") + " " + os.EOL + "}";
return content.length ?
(isJson?json:"KISSY.config('modules', "+json+");") :
"";
};

@@ -480,0 +488,0 @@

@@ -54,2 +54,17 @@ /**

if(node instanceof UglifyJS.AST_Call && (node.start.value == 'KISSY' || node.start.value == 'S') && node.expression && node.expression.property == 'add'){
if(walker.find_parent(UglifyJS.AST_Call)){
var PASS = walker.stack.some(function(iNode){
return (
iNode !== node &&
iNode instanceof UglifyJS.AST_Call &&
(iNode.start.value == 'KISSY' || iNode.start.value == 'S') &&
iNode.expression && iNode.expression.property == 'add'
);
});
if(PASS){
return true;
}
}
var tmp = call_expression;

@@ -92,2 +107,3 @@ call_expression = node;

}
});

@@ -94,0 +110,0 @@

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

},
joinCombo: function(mods){
joinCombo: function(mods,isJson){
var result = [];

@@ -93,6 +93,15 @@ if(!_.isArray(mods)){

_.forEach(mod, function(subMods, modName){
!_.isEmpty(subMods) && result.push("'" + modName + "': { requires: ['" + subMods.join("', '") + "']}");
if(!_.isEmpty(subMods)){
if(isJson){
result.push("\"" + modName + "\": [\"" + subMods.join("\", \"") + "\"]");
}else{
result.push("'" + modName + "': { requires: ['" + subMods.join("', '") + "']}");
}
}
});
});
return result.length ? "KISSY.config('modules', {" + os.EOL + " " + result.join(", " + os.EOL) + " " + os.EOL + "});" : "";
var json="{" + os.EOL + " " + result.join("," + os.EOL + " ") + " " + os.EOL + "}";
return result.length ?
(isJson?json:"KISSY.config('modules', "+json+");") :
"";
},

@@ -99,0 +108,0 @@ isExcluded: function(str, rules){

{
"name": "kmc",
"version": "1.0.34",
"version": "1.0.35",
"description": "KISSY Module Compiler",

@@ -5,0 +5,0 @@ "author": {

# ModuleCompiler
[![Build Status](https://secure.travis-ci.org/daxingplay/ModuleCompiler.png)](http://travis-ci.org/daxingplay/ModuleCompiler)
[![Build Status](https://travis-ci.org/daxingplay/kmc.svg?branch=master)](https://travis-ci.org/daxingplay/kmc)

@@ -5,0 +5,0 @@ [![NPM version](https://badge.fury.io/js/kmc.png)](http://badge.fury.io/js/kmc)

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

describe('When clean', function(){

@@ -1238,5 +1239,108 @@ it('should get an empty options', function(){

var file = result.files[0];
console.log(file);
// console.log(file);
file.autoCombo['package1/kissy-sub-module'].length.should.equal(4);
});
});
describe('When build package file(eg: packageName + .js)', function(){
var result;
var inputFile = path.resolve(srcPath, 'package5/menu.js'),
outputFile = path.resolve(distPath, 'package5/menu.js');
before(function(){
ModuleCompiler.config({
packages: [{
name: 'menu',
path: path.resolve(srcPath, './package5/src'),
charset: 'gbk',
ignorePackageNameInUri: true
}],
silent: true,
charset: 'gbk'
});
result = ModuleCompiler.build(inputFile, outputFile);
});
after(function(){
ModuleCompiler.clean();
});
it('should have proper main module.', function(){
var file = result.files[0];
file.name.should.equal('menu');
file.should.have.property('requires').with.lengthOf('1');
});
it('should have some modules in combo file', function(){
var submods = result.files[0].dependencies;
submods.length.should.equal(1);
submods[0].name.should.equal('menu/control');
});
});
describe('When package name has slash and package name ignored', function(){
var result;
var inputFile = path.resolve(srcPath, 'package1/pkgNameWithSlash.js'),
outputFile = path.resolve(distPath, 'package1/pkgNameWithSlash.js');
before(function(){
ModuleCompiler.config({
packages: [{
name: 'test/abc',
path: path.resolve(srcPath, './package1'),
charset: 'gbk',
ignorePackageNameInUri: true
}],
silent: true,
charset: 'gbk'
});
result = ModuleCompiler.build(inputFile, outputFile);
});
after(function(){
ModuleCompiler.clean();
});
it('should have proper main module.', function(){
var file = result.files[0];
file.name.should.equal('test/abc/pkgNameWithSlash');
file.should.have.property('requires').with.lengthOf('0');
});
});
describe('When package name has slash and package name not ignored', function(){
var result;
var inputFile = path.resolve(srcPath, 'package1/pkgNameWithSlash.js'),
outputFile = path.resolve(distPath, 'package1/pkgNameWithSlash.js');
before(function(){
ModuleCompiler.config({
packages: [{
name: 'src/package1',
path: path.resolve(srcPath, '../'),
charset: 'gbk',
ignorePackageNameInUri: false
}],
silent: true,
charset: 'gbk'
});
result = ModuleCompiler.build(inputFile, outputFile);
});
after(function(){
ModuleCompiler.clean();
});
it('should have proper main module.', function(){
var file = result.files[0];
file.name.should.equal('src/package1/pkgNameWithSlash');
file.should.have.property('requires').with.lengthOf('0');
});
});
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