helenNote
Konck! Knock!
OK
helenNote
Choose mode
dark
auto
light
主页
分类
前端
Engineering
leetCode
SEO优化
axios
后端
浏览器
ajax
浏览器个方面的问题
css
css module
css面试
随笔
编辑器
开发经验
单元测试
flutter
h5
git
大文件上传下载
github
http
免费试用的接口
零碎面试题
学习es5
canvas
serviceworker
react500问
worker
学习es6
各个观察api
es5知识点
js技巧
jsp
生活书籍
学习方法
micro—front—end
媒体处理
小程序
miniProgram
tcp
信息聚合
node
es6
npm调试
前端资源
谷歌performance
页面性能
性能优化
js插件
js性能
总结
css性能
react
react面试
reac18新特性
react源码
svg
图床
云盘
typescript
styled-components
vue2
vue2学习
vue2源码
vite
vue3源码
vue3
webpack
websocket
EfficientPerformance
算法
webpack面试
标签
其它
怎么使用vuepress
使用vuepress写页面
怎么写vuepress插件
怎么使用git
目前使用小乌龟git的经验
自动化部署
利用github完成自动化部署
Projects🎈
My Project
Common sites🎈
友 链
Java SE API Documentation
(opens new window)
Program Creek
(opens new window)
Spring
(opens new window)
Stackoverflow
(opens new window)
LeetCode
(opens new window)
Vue.js
(opens new window)
BootCDN
(opens new window)
Linux命令大全
(opens new window)
编程语言排行榜
(opens new window)
时间线
关于我
GitHub
(opens new window)
模块化规范
Konck! Knock!
OK
模块化规范
wǎng luò shí huāng
2021-06-10
模块化
主要是介绍了模块化规范
#
模块化规范
代码参考:https://gitee.com/wangluoshihuang/zhufeng202103node/blob/master/3.node-core/1.js#L112
node 模块规范:
global 上有属性直接访问的叫全局属性,require exports module 也可以直接访问 但他们不在 global 上。node 里每个文件都是一个模块, 模块化的实现借助的是 函数,函数中有参数 参数里面有 五个属性 **dirname **filename require exports module,所以我们可以在 node 模块里直接使用这个 5 个属性,但是这 5 个属性直接使用 global.xxx 访问不到。
commonjs、esmodule 区别:
除了上面笔记里的。还有 commonjs 在导入的时候会运行代码,所以支持动态导入。但是 esmodule 语法在导入的时候,只是编译了一下代码,代码并没有运行,所以不支持动态导入。
node 和 esmodule 是如何解析模块的:
参考
这里
的 【模块解析策略】。
如何在现在浏览器上使用 esMoudle:
在浏览器中使用 ES 模块
(opens new window)
使用第三方模块需要
(opens new window)
最近更新
01
针对vscode前端协同eslint、stylelint、prettier工作
03-04
02
Git 和 Husky 添加提交钩子并实现代码任务自动化
01-30
03
其他工程化杂项
08-29
更多文章 >
展开
···
歌手: