Node.js & module system

Node.js v10.9.0 Documentation

https://nodejs.org/api/modules.html#modules_modules

https://nodejs.org/api/modules.html#modules_the_module_wrapper
https://nodejs.org/api/modules.html#modules_exports_shortcut


CommonJS

CommonJS module system

http://nodejs.wikia.com/wiki/Modules

https://requirejs.org/docs/whyamd.html#commonjs
http://www.adequatelygood.com/JavaScript-Module-Pattern-In-Depth.html
https://darrenderidder.github.io/talks/ModulePatterns/#/

https://addyosmani.com/writing-modular-js/

CJS

http://unscriptable.com/2011/09/30/amd-versus-cjs-whats-the-best-format/
http://www.commonjs.org/

Asynchronous Module Definition (AMD)

https://requirejs.org/docs/whyamd.html
https://github.com/amdjs/amdjs-api/wiki/AMD

UMD

UMD: Universal Module Definition

https://www.davidbcalhoun.com/2014/what-is-amd-commonjs-and-umd/

https://www.zhihu.com/question/20351507


node.js & exports & module.exports

node.js

  1. Functions and objects are added to the root of a module by specifying additional properties on the special exports object.

https://www.w3schools.com/nodejs/nodejs_modules.asp

https://www.sitepoint.com/understanding-module-exports-exports-node-js/

npx

https://stackoverflow.com/questions/9679932/how-to-use-package-installed-locally-in-node-modules


nodejs & es6 & import & export

https://stackoverflow.com/questions/31354559/using-node-js-require-vs-es6-import-export

Keep in mind that there is no JavaScript engine yet that natively supports ES6 modules. You said yourself that you are using Babel. Babel converts import and export declaration to CommonJS(require/module.exports) by default anyway. So even if you use ES6 module syntax, you will be using CommonJS under the hood if you run the code in Node.

https://medium.com/the-node-js-collection/an-update-on-es6-modules-in-node-js-42c958b890c

ESM

https://hackernoon.com/node-js-tc-39-and-modules-a1118aecf95e

https://github.com/tc39/proposal-dynamic-import


webpack.config.js

https://github.com/carloluis/webpack-demo/tree/master/config

webpack dev & prod

https://github.com/carloluis/webpack-demo

https://github.com/carloluis/webpack-demo/blob/master/config/webpack.config.dev.js

https://github.com/carloluis/webpack-demo/blob/master/config/webpack.config.prod.js

Node.js & module system的更多相关文章

  1. 如何發佈一個完整Node.js Module

    本文會透過以下幾個段落,讓各位一步一步學習如何寫一個自已的Node.js Module並且發佈到npm package上 Node.js Module 結構 我們先建立一個 NodeModuleDem ...

  2. (转)Node.js module.exports与exports

    本文转自Node.js module.exports与exports 作者: chemdemo 折腾Node.js有些日子了,下面将陆陆续续记录下使用Node.js的一些细节. 熟悉Node.js的童 ...

  3. 创建并发布node.js module

      创建node.js module. 创建一个文件夹,用来存放module. Cd到新创建的文件夹,运行npm init,会提示输入package的信息. 可以按照这个视频的来输入.Test com ...

  4. node.js module.exports & exports & module.export all in one

    node.js module.exports & exports & module.export all in one cjs const log = console.log; log ...

  5. Node.js & module.exports & exports

    Node.js & module.exports & exports https://www.cnblogs.com/xgqfrms/p/9493550.html exports &a ...

  6. node.js module初步理解

    在开发一个复杂的应用程序的时候,我们需要把各个功能拆分.封装到不同的文件,在需要的时候引用该文件.没人会写一个几万行代码的文件,这样在可读性.复用性和维护性上都很差,几乎所有的编程语言都有自己的模块组 ...

  7. Node.js module.exports和exports的区别

    require 用来加载代码,而 exports 和 module.exports 则用来导出代码,从接触node.js就不会它们两陌生,上代码: foo.js exports.a = functio ...

  8. node.js module初步理解-(转载)

    在开发一个复杂的应用程序的时候,我们需要把各个功能拆分.封装到不同的文件,在需要的时候引用该文件.没人会写一个几万行代码的文件,这样在可读性.复用性和维护性上都很差,几乎所有的编程语言都有自己的模块组 ...

  9. How to use Request js (Node js Module) pools

    Can someone explain how to use the request.js pool hash? The github notes say this about pools: pool ...

随机推荐

  1. 使用HttpClient携带pfx证书调用HTTPS协议的WebService

    调用第三方服务时,厂商提供了一个WSDL文件.调用的地址和一个后缀为pfx的证书文件,通过SOUPUI记载证书是可以正常调用WebService服务,那么如何将该服务转换为代码呢? 咨询了厂商的支持, ...

  2. L 裁纸片 贪心 + 模拟

    https://biancheng.love/contest-ng/index.html#/123/problems 如果只是输出最小的值,那么好办,a升序,b降序,这样是最优的. 但是需要次数,这就 ...

  3. AngularJS ng-repeat下使用ng-model

    1 2 3 blue:<input type="radio" value="1" ng-model="selectValue"/> ...

  4. SpringBoot2.1.3修改tomcat参数支持请求特殊符号

    最近遇到一个问题,比如GET请求中,key,value中带有特殊符号,请求会报错,见如下URL: http://xxx.xxx.xxx:8081/aaa?key1=val1&a.[].id=1 ...

  5. input 全选 jquery封装方法

    HTML代码 <table class="table table-striped"> <thead> <tr> <th><in ...

  6. es6核心特性-数组扩展

    1. Array.from() : 将伪数组对象或可遍历对象转换为真数组 如果一个对象的所有键名都是正整数或零,并且有length属性,那么这个对象就很像数组,称为伪数组.典型的伪数组有函数的argu ...

  7. spring 中文乱码问题

    spring 开发过程中的中文乱码问题主要分为以下几种: 1.前端传参数到后台前  就已经乱码. 这个很大原因就是前端的问题了! 2.传入后台后,乱码. 可能存在几个原因: 2.1 传入tomcat前 ...

  8. win8怎么打开或关闭快速启动(进入BIOS前的设置)

    win8系统之后,系统添加了快速启动功能,这让Windows的启动速度快了不少.但是,任何事物有利有弊,相信不少人在进入BIOS或者重装系统时遇到了麻烦.接下来我们看看在win8及以上版本怎么打开或关 ...

  9. 通过 GCC 学习 OpenMP 框架

     OpenMP 框架是使用 C.C++ 和 Fortran 进行并发编程的一种强大方法.GNU Compiler Collection (GCC) V4.4.7 支持 OpenMP 3.0 标准,而 ...

  10. Win7 与win10绘制桌面壁纸的区别

    win7使用csrss.exe绘制壁纸. win10使用explorer.exe绘制壁纸.