index.js
function amdDependencies(file, instance, options) {

    var dependencies = [ ];

    var config = instance.getAmdConfig(file);

    var fileInfo = parseFile(
        file.path,
        file.contents.toString(),
        config
    );

    fileInfo.modules.forEach(
        function (module) {

            var resources = parseFactoryResources(module.factory);

            [
                // 同步
                module.dependencies,
                // 异步
                resources.async,
                // 其他资源，如 toUrl('../../a.png')
                resources.other
            ]
            .forEach(function (resources) {

                resources.forEach(function (resource) {

                    if (util.keywords[ resource.id ]) {
                        return;
                    }

                    var resourceId = resolveResourceId(resource.id, module.id);
                    var filePath = resourceIdToFilePath(resourceId, config);

                    if (filePath) {
                        dependencies.push({
                            raw: resource.id,
                            absolute: filePath
                        });
                    }

                });

            });
        }
    );

    correctDependencies(
        file,
        dependencies,
        instance.correctDependency
    );

    filterDependencies(
        file,
        dependencies,
        instance.filterDependency
    );

    if (options.process) {
        options.process(file, dependencies);
    }

    if (options.rename) {

        var replaceRequireResource = config.replaceRequireResource;

        config.replaceRequireResource = function (resource, absolute) {
            return options.rename(
                file,
                {
                    raw: resource.id,
                    absolute: absolute
                },
                instance.hashMap,
                instance.dependencyMap
            );
        };

        replaceResources(
            fileInfo,
            config
        );

        config.replaceRequireResource = replaceRequireResource;

        file.contents = new Buffer(
            generateFileCode(fileInfo, config.minify)
        );

    }
}
function amdDependencies(file, instance, options) {

    var dependencies = [ ];

    var config = instance.getAmdConfig(file);

    var fileInfo = parseFile(
        file.path,
        file.contents.toString(),
        config
    );

    fileInfo.modules.forEach(
        function (module) {

            var resources = parseFactoryResources(module.factory);

            [
                // 同步
                module.dependencies,
                // 异步
                resources.async,
                // 其他资源，如 toUrl('../../a.png')
                resources.other
            ]
            .forEach(function (resources) {

                resources.forEach(function (resource) {

                    if (util.keywords[ resource.id ]) {
                        return;
                    }

                    var resourceId = resolveResourceId(resource.id, module.id);
                    var filePath = resourceIdToFilePath(resourceId, config);

                    if (filePath) {
                        dependencies.push({
                            raw: resource.id,
                            absolute: filePath
                        });
                    }

                });

            });
        }
    );

    correctDependencies(
        file,
        dependencies,
        instance.correctDependency
    );

    filterDependencies(
        file,
        dependencies,
        instance.filterDependency
    );

    if (options.process) {
        options.process(file, dependencies);
    }

    if (options.rename) {

        var replaceRequireResource = config.replaceRequireResource;

        config.replaceRequireResource = function (resource, absolute) {
            return options.rename(
                file,
                {
                    raw: resource.id,
                    absolute: absolute
                },
                instance.hashMap,
                instance.dependencyMap
            );
        };

        replaceResources(
            fileInfo,
            config
        );

        config.replaceRequireResource = replaceRequireResource;

        file.contents = new Buffer(
            generateFileCode(fileInfo, config.minify)
        );

    }
}
分析 amd 文件依赖

@inner
@param {Object} file
@param {Object} instance
@param {Object} options
@return {Object}