[英]Using async await and dynamic import statements with Babel and Webpack
When using async await
, webpack guide recommends using babel-plugin-syntax-dynamic-import
. 使用
async await
,Webpack指南建议使用babel-plugin-syntax-dynamic-import
。 https://webpack.js.org/guides/code-splitting/ https://webpack.js.org/guides/code-splitting/
I ran into an error and figured that's not the only plugin required. 我遇到了一个错误,发现不是唯一需要的插件。 Babel docs recommends using
babel-polyfill
. Babel文档建议使用
babel-polyfill
。 So, I just want to confirm if this plugin handles both the async await
and dynamic imports
for older browsers? 因此,我只想确认此插件是否可以处理旧版浏览器的
async await
和dynamic imports
? Do I need to add babel-plugin-syntax-dynamic-import
as well? 我是否还需要添加
babel-plugin-syntax-dynamic-import
?
Sorry if the question seems naive, but from word polyfill it seems it should cover all of the cases for older browsers. 很抱歉,如果这个问题看起来很幼稚,但是从polyfill这个词看来,它应该涵盖了所有旧浏览器的情况。 Awaiting inputs!
等待输入!
syntax-dynamic-import
is inserted to allow you to use import(/path/to/file)
(dynamic import), this has nothing to do with async await. 插入了
syntax-dynamic-import
,以允许您使用import(/path/to/file)
(动态导入),这与异步等待无关。
For async await you will need async to generators
. 对于异步等待,您将需要
async to generators
。
When you add babel-polyfill
it adds everything necessary. 添加
babel-polyfill
它会添加所有必要的内容。 You must also add the browser versions you want to support on the babel-env options. 您还必须在babel-env选项上添加要支持的浏览器版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.