Dynamic import 提出已有一段时间,围绕着它也产生了许多的解决方案。今天我分享一下最近在React工程中使用它的一些心得。
Dynamic import的基本使用形式,在Github中有案例:
Dynamic import 提出已有一段时间,围绕着它也产生了许多的解决方案。今天我分享一下最近在React工程中使用它的一些心得。
Dynamic import的基本使用形式,在Github中有案例:
有的机器上会配备一些小容量的SSD,在大多数时候,我们会选择将其作为系统盘(Windows),但是在用Linux制作一些服务器的时候,主要的性能瓶颈往往不在基础的系统文件上,而是对应的服务频繁读写的目录上。
比如Gitlab Runner可使用Docker模式进行构建,其主要的读写行为集中在 /var/lib/docker 目录下。
如果将相关存储直接写到小容量SSD上,往往是不够的,但是有SSD不用也实在是浪费。
The following code will produce code-splitting in Webpack, which means that the source code will be split into several files that will be loaded async at runtime.. More info here;
import('./some-module').then((SomeModule) => {});有时因为一些安全方面的原因,需要使用跳板机才能访问到指定的ssh服务器。直接访问的时候是不通的。
这种情况下,就需要先ssh登录到跳板机,再从跳板机上ssh到真正的主机。
通过设置 ~/.ssh/config 文件,可以简化这个过程。
今天在重构一个项目的时候,遇到了一个诡异的bug,调试过程中发现,原来是Function的name的属性丢失导致的。
后来出于好奇研究了下Javascript中Function/Class的name属性,这里和大家分享下。
事情是这样的,我在重构一段代码,去除new Function这种用法,换成正常的function。为便于理解,代码做了简化,原代码如下:
| import {Project, SyntaxKind, ts, Node} from "ts-morph"; | |
| const trim = (str: string) => str.substr(1, str.length - 2) | |
| // const printChildren = (node: Node<ts.Node>) => { | |
| // for (const item of node.getChildren()) { | |
| // console.log('kind: ', item.getKindName()) | |
| // console.log('text: ', item.getText()) | |
| // console.log('>'.repeat(50)) | |
| // } |