reactjs - are node modules dependency lazy loaded?
问题描述
My question is are the node modules dependencies are lazy loaded in any way? or it's just the magic of imports?
As I have built a git submodule and doing Lazy Loading
using react-loadable
but it hardly seems to work.
解决方案
Node_Modules 不是延迟加载的。在这里,您使用react-loadable
的只是 JS/JSX 文件中的动态导入。每当 webpack 在 js 文件中找到 import 语句时,它都会创建块文件并将引用添加到主 js 文件中。在浏览器网络选项卡中,您可以看到多个文件。
react-loadable
对于大型项目很有用,它会有多个页面。那个时候把所有的js打包成一个文件并不是一个好习惯。在这种情况下,react-loadable
创建多个块并在组件需要出现在屏幕上时加载。
推荐阅读
- android-studio - 高 CPU 使用率 - Android 模拟器 (qemu-system-x86)
- javascript - 从(更改)中获取价值无法正常工作
- python - 编码新手:迭代 Python 中的列表
- java - 如何编写java方法/算法从父子关系的平面层次结构构建json树
- python - 如何解决python中xarray的导入问题?
- android - 关于使用android相机开发
- svelte - 知道我的自定义 Svelte 组件中是否有单击事件处理程序
- spring-integration - 为什么 RedisLockRegistry 不支持 Transactional?
- aws-api-gateway - 如何将文件从 AWS REST API 网关复制到 s3 存储桶?
- r - 如何在批处理ggstatsplot2中显示两组的成对比较