node ncc 打包

柔情痞子 提交于 2020-02-28 17:04:05

https://github.com/zeit/ncc#readme

 

gcc的node版, 由webpack和rullup两位作者开发

 

用于js和ts的打包,  零配置, 不过还是需要tsonfig.json

简单版

{
  "compilerOptions": {
    "target": "es6",                          /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
    "module": "commonjs",                     /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
    "outDir": "./lib",                        /* Redirect output structure to the directory. */
    "rootDir": "./src",                       /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
    "strict": true,                           /* Enable all strict type-checking options. */
    "noImplicitAny": false,                 /* Raise error on expressions and declarations with an implied 'any' type. */
    "esModuleInterop": true                   /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
  },
  "exclude": ["node_modules", "**/*.test.ts"]
}

 

支持 ?. !.等高级语法

let obj = {
    a:{
        b:{
            c:'d'
        }
    }
}

console.log(obj?.a)
console.log(obj?.a!.b)
console.log(obj?.a?.b!)

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!