源码分析: config配置里shim

在newContext内的 context.configure 方法中, 对配置文件进行初始化。 

//Merge shim
                if (cfg.shim) {
                    eachProp(cfg.shim, function (value, id) {
                        //shim 为数组类型, 很少用。
                        //一般为 对象类型
                        //Normalize the structure
                        if (isArray(value)) {
                            value = {
                                deps: value
                            };
                        }
                       
                        // 当前配置点有exports或 init.
                        // 没有初始化过exportsFn时
                        // 进行初始化
                        if ((value.exports || value.init) && !value.exportsFn) {
                            value.exportsFn = context.makeShimExports(value);
                        }
                        shim[id] = value;
                    });
                    config.shim = shim;
                }

posted @ 2016-07-17 08:22  陈同学  阅读(238)  评论(0编辑  收藏  举报