public RequireReferenceParser(IAsset asset, ScriptBundle bundle, CommonJsSettings settings, IExternalModuleResolver moduleResolver)
 {
     _asset          = asset;
     _bundle         = bundle;
     _settings       = settings;
     _moduleResolver = moduleResolver;
     _moduleAsset    = _asset as IModuleAsset;
 }
            public override void Visit(BinaryOperator node)
            {
                // if the file has no dependencies it might end up here
                // all we care about is whether it has any exports
                if (_moduleAsset == null && node.IsAssign && this.IsExportMember(node.Operand1))
                {
                    _moduleAsset = new ModuleAsset(_asset);
                }

                base.Visit(node);
            }
            public override void Visit(CallNode node)
            {
                if (this.IsRequireCall(node))
                {
                    var constWrapper = node.Arguments[0] as ConstantWrapper;
                    if (constWrapper != null && constWrapper.PrimitiveType == PrimitiveType.String)
                    {
                        _moduleAsset = _moduleAsset ?? new ModuleAsset(_asset);
                        var path = (string)constWrapper.Value;

                        if (FileUtility.IsRelativePath(path))
                        {
                            if (path.StartsWith("./", StringComparison.Ordinal))
                            {
                                path = path.Length == 2 ? string.Empty : path.Substring(2);
                            }

                            if (path.EndsWith("/", StringComparison.Ordinal))
                            {
                                path += "index.js";
                            }

                            if (path.EndsWith(".js", StringComparison.OrdinalIgnoreCase) == false)
                            {
                                path += ".js";
                            }

                            _moduleAsset.AddReference(path, 0);
                        }
                        else if (this.ShouldIncludeReference(path))
                        {
                            var mainFile = _moduleResolver.Resolve(path);
                            _bundle.Assets.Add(new ExternalModuleAsset(path, mainFile, _bundle));
                        }
                    }

                    return;
                }

                base.Visit(node);
            }