React 使用一个名为commoner https://github.com/reactjs/commoner。他们的配置与如下所示的行相匹配:
* @providesModule ReactChildReconciler
To require('ReactChildReconciler')
来电。他们还将所有内容都放在一个目录中,因此路径最终为require('./ReactChildReconciler')
.
The source code is organized in a structured way, but the module names are globally unique to the repo (and all of facebook's internal code, I think
[citation needed]). This means there's no ambiguity in what it points to.
关于这个问题,react 的代码中还有一些其他神奇的东西。
致电invariant(assertion, explanation, ...)
和类似的warning
通过删除第一个参数之后的参数以节省空间,将调用转换为生产构建。警告调用被完全剥离,因为它们被包裹在下一个魔法中:仅开发块。
if (__DEV__) {
...
}
编译为:
if (process.env.NODE_ENV !== 'production') {
...
}
通过 envify,编译为此(正在开发中),并且代码运行:
if ('development' !== 'production') {
...
}
这在生产中:
if ('production' !== 'production') {
...
}
这缩小为: