xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

Node.js & module system

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

image

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

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

Node.js & 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

ES Modules

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

refs



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


posted @   xgqfrms  阅读(237)  评论(13编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2016-08-17 HTML5 动效
2016-08-17 Google 地图 API
2016-08-17 2016 JS 笔试题汇总 All In One
点击右上角即可分享
微信分享提示