简体   繁体   English

将“exceljs”lib导入角度的最佳方法是什么?

[英]What is best way to import “exceljs” lib to angular

I'm using exceljs( https://www.npmjs.com/package/exceljs ) to import and export excel file in an angular 7 app. 我正在使用exceljs( https://www.npmjs.com/package/exceljs )在角度7应用程序中导入和导出excel文件。 Here is how I import it : import {Workbook} from "exceljs"; 以下是我导入它的方法: import {Workbook} from "exceljs"; even if it work perfectly but after build production and look at main.js by source-map-explorer it has taken 483kb(20%) in node_modules, too large I think. 即使它完美地工作但是在构建生产之后并且通过source-map-explorer查看main.js它在node_modules中占用了483kb(20%),我认为它太大了。

does anyone have any solution to reduce the size of exceljs in node_modules ? 有没有人有任何解决方案来减少exceljs中的exceljs的大小?

The size in node_modules does not matter because not everything is put into the bundles. node_modules中的大小并不重要,因为并非所有内容都放入bundle中。 But if you want to reduce the bundle sizes you can exclude the library from the vendor bundle by loading the library via cdn and not including it in the project: 但是,如果要减小捆绑包大小,可以通过cdn加载库而不将其包含在项目中,从库中排除库:

  1. Import the type definitions to make exceljs available in your editor npm package 导入类型定义以使编辑器npm包中的 excelj可用

  2. Import the sources from cdn (via index.html) cdn导入源(通过index.html)

  3. Remove the exceljs npm package from your project 从项目中删除exceljs npm包

That does not lower the all in all size but it makes your vendor bundle smaller. 这不会降低所有尺寸的全部,但它会使您的供应商捆绑更小。 Hope that answers your question. 希望这能回答你的问题。 Hope this helps... 希望这可以帮助...

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

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