发现的问题,直接写es6d代码,在不经过babel编译发布后,会产生问题
解决办法:
- 一般所写的源代码放到src文件夹下
- 一般在package.json中添加几个script
- 安装具体的项目依赖
然后执行npm publish,在这个之前会触发prepublish,然后根据配置会进行bable编译
"scripts": {
"compile": "babel -d lib/ src/",
"prepublish": "npm run compile",
"server": "node app.babel.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-2": "^6.24.1"
}
网友评论