We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
第2042天 webpack能动态加载require引入的模块吗?
3+1官网
我也要出题
The text was updated successfully, but these errors were encountered:
能,Webpack 支持动态加载通过 require 引入的模块。这种功能通常使用动态 import() 函数实现,这样在构建时 Webpack 就能够将这些模块分割为单独的块,从而实现懒加载。
可以使用requre.ensure()
require.ensure([], function(require) { const moduleA = require('./moduleA'); // 使用moduleA });
但这是旧版webpack的方案,现在更推荐使用import()加载
const loadModuleA = async () => { const moduleA = await import('./moduleA'); // 使用moduleA };
总结来说,Webpack 可以动态加载 require 引入的模块,但使用动态 import() 是更现代的做法
Sorry, something went wrong.
No branches or pull requests
第2042天 webpack能动态加载require引入的模块吗?
3+1官网
我也要出题
The text was updated successfully, but these errors were encountered: