概述
(!) Unresolved dependencies
https://rollupjs.org/guide/en#warning-treating-module-as-external-dependency
@babel/runtime/regenerator (imported by srcmoduleajaxdownloadString.js, srcmoduleajaxdownloadUrl.js, srcmoduleajaxloadResource.js, srcmoduleajaxFetchLimiting.js, srcmodulearrayasyncFlatMap.js)
@babel/runtime/helpers/asyncToGenerator (imported by srcmoduleajaxdownloadString.js, srcmoduleajaxdownloadUrl.js, srcmoduleajaxloadResource.js, srcmoduleajaxFetchLimiting.js, srcmodulearrayasyncFlatMap.js)
@babel/runtime/helpers/toConsumableArray (imported by srcmoduleajaxFetchLimiting.js, srcmodulearrayasyncFlatMap.js)
@babel/runtime/helpers/classCallCheck (imported by srcmoduleajaxFetchLimiting.js, srcmoduledatestrToDate.js, srcmoduleeventwatchEventListener.js)
@babel/runtime/helpers/createClass (imported by srcmoduleajaxFetchLimiting.js)
(!) Missing global variable names
Use output.globals to specify browser global variable names corresponding to external modules
@babel/runtime/regenerator (guessing '_regeneratorRuntime')
@babel/runtime/helpers/asyncToGenerator (guessing '_asyncToGenerator')
@babel/runtime/helpers/toConsumableArray (guessing '_toConsumableArray')
@babel/runtime/helpers/classCallCheck (guessing '_classCallCheck')
@babel/runtime/helpers/createClass (guessing '_createClass')
created distrx-util.min.js in 3.2s
Done in 5.90s.
解决方案:安装并配置下 rollup-plugin-node-resolve 和 rollup-plugin-commonjs 就好了
/*
* @Author: weidong19
* @Date: 2020-12-09 15:40:30
* @LastEditTime: 2020-12-10 17:19:52
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: /ad-micro/rollup.config.js
*/
import serve from 'rollup-plugin-serve'
import babel from 'rollup-plugin-babel';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
// rollup 可以帮我们打包es6的模块化语法
export default {
input:'./src/ad-micro.js',
output:{
file:"./lib/umd/ad-micro.js",
format:'umd',
name:"adMicro",
sourcemap:true
},
plugins:[
serve({
openPage:'/index.html',
contentBase:'',
port:3000
}),
babel({
runtimeHelpers: true,
exclude: 'node_modules/**',
presets: ["@babel/preset-env"]
}),
resolve(),
commonjs()
]
}
.babel配置如下:@babel/plugin-transform-runtime 解决regeneratorRuntime is not defined 必备的包
{
"presets": [
"@babel/env"
],
"plugins": [
["@babel/plugin-transform-runtime", {
"regenerator": true
}]
]
}
最后
以上就是美丽帆布鞋为你收集整理的rollup+babel打包出错问题 解决丢失async await 不能使用的问题regeneratorRuntime is not defined的全部内容,希望文章能够帮你解决rollup+babel打包出错问题 解决丢失async await 不能使用的问题regeneratorRuntime is not defined所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复