简体   繁体   English

Webpack可以在客户端动态加载UMD模块吗?

[英]Can Webpack dynamic load a UMD module on client-side?

I did it with Systemjs, but the config is the worst part of it. 我是用Systemjs完成的,但是配置是最糟糕的部分。 I need to download a UMD library in the browser and render it as part of the application, but everything in Webpack is self-contained. 我需要在浏览器中下载一个UMD库,并将其呈现为应用程序的一部分,但是Webpack中的所有内容都是独立的。 Is it possible? 可能吗? Did it work for someone? 它对某人有用吗?

I need this to do some good stuff with Angular Universal but I don't want to keep using SystemJS. 我需要使用Angular Universal来做一些好事,但我不想继续使用SystemJS。

If you wish to load an umd library separately (not in your bundle) and still access it in your bundle through the global window, you can either add an import loader or an export loader: see https://webpack.js.org/guides/shimming . 如果您希望单独加载umd库(不在捆绑包中)并且仍通过全局窗口在捆绑包中访问它,则可以添加导入加载器或导出加载器:请参阅https://webpack.js.org/指南/调整

Otherwise you shouldn't encounter any problem importing a umd module with Webpack. 否则,使用Webpack导入umd模块不会遇到任何问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM