[Javascript] Module systems

 

 

 

 

Difference betwen require and import

  • require can be called conditionally, while the import statement cannot
  • import statements are hoisted, but require calls are not
  • require synchronously loads modules, while import can load moudles asynchronously
  • import allow for static analysis and tree shaking, but require does not

 

posted @ 2024-03-19 15:45  Zhentiw  阅读(3)  评论(0编辑  收藏  举报