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
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
Functions and objects
are added tothe root of a module
by specifying additional properties on the specialexports
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 发布文章使用:只允许注册用户才可以访问!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/9493550.html
未经授权禁止转载,违者必究!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 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