omodule
是一种以项目目录结构为基础的「命名空间」规范。目前可使用 babel 插件 babel-plugin-transform-omodule-namespace 进行 omodule 命名空间常量的代码编译。
javascript 的项目缺少命名空间规范。
例子: ./omodule-structure-example
root
|__ omodules
|__ account
| |__ omodules
| |__ login
| |__ register
|__ homepage
|__ order
当前 omodule 的命名空间(基于根节点)
路径:root/omodules/account/omodules/login/loginPage.js
console.log(__onamespace); // 打印log: /account/login
基于 omodule 根节点的文件路径常量
路径:root/omodules/homepage/homePage.js
console.log(__ofilepath); // 打印log: omodules/homepage/homePage.js
目前可配合 babel-plugin-transform-omodule-namespace 编译 omodule 作用域常量。