我是靠谱客的博主 美丽帆布鞋,最近开发中收集的这篇文章主要介绍rollup+babel打包出错问题 解决丢失async await 不能使用的问题regeneratorRuntime is not defined,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

(!) 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所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(50)

评论列表共有 0 条评论

立即
投稿
返回
顶部