1.1.3 • Published 4 years ago

xng-cjs v1.1.3

Weekly downloads
48
License
-
Repository
-
Last release
4 years ago

xng-cjs

把 JavaScript 模块从CommonJs 规范转化为 ES6 规范.

快速开始

全局安装:

npm install xng-cjs -g

本地调试:

cnpm i

node bin/xng-cjs [文件或者文件名]

每次更新后npm run build

全局命令使用:

xng-cjs [文件或者文件名]
如 xng-cjs src | xng-cjs src/fileName.js

暂时不支持的转换格式

const a = require('a').default;
const {a, b} = require('a');
const a, {b, c} = require('a');

const obj = {};
let a = {
    a,
  ...obj
}
module.exports = a

转换效果

const a = require('./a'); -> import a from './a';


module.exports = {a:1}; -> exports defualt {a:1};

························································
// import PROFILE_SIZE from './sss';
let COMMIT_SIZE = {};
const COVER_SIZE = {
  COMMIT_SIZE,
  PROFILE_SIZE
};


module.exports = COVER_SIZE;
       

    ↓


// The current module is compiled by xng-cjs
// import PROFILE_SIZE from './sss';
let COMMIT_SIZE = {};
const COVER_SIZE = {
  COMMIT_SIZE,
  PROFILE_SIZE
};




export const PROFILE_SIZE = COVER_SIZE['PROFILE_SIZE'];

export default COVER_SIZE;

························································

const COVER_SIZE = {
  COMMIT_SIZE,
  PROFILE_SIZE
};


module.exports = COVER_SIZE;



    ↓


const COVER_SIZE = {
  COMMIT_SIZE,
  PROFILE_SIZE
};




export const COMMIT_SIZE = COVER_SIZE['COMMIT_SIZE'];
export const PROFILE_SIZE = COVER_SIZE['PROFILE_SIZE'];

export default COVER_SIZE;

························································


exports.c = 'c'; - > export const c = "c";





exports.f = function() {          
  return 'f';                    
};                                


    ↓


export const f = function () {
  return "f";
};



let COMMIT_SIZE = '180x140';
let PROFILE_SIZE = '180x140';
const COVER_SIZE = {

  COMMIT_SIZE,
  PROFILE_SIZE,
};

module.exports = COVER_SIZE;


    ↓


let COMMIT_SIZE = "180x140";
let PROFILE_SIZE = "180x140";
const COVER_SIZE = {
  COMMIT_SIZE,
  PROFILE_SIZE
};
export default COVER_SIZE;
1.1.3

4 years ago

1.1.1

4 years ago

1.1.2

4 years ago

1.1.0

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago