How The Viall Files Became Meet the Press for Reality TV
ByBethy Squires,
a Vulture news blogger who covers comedy
Nick Viall’s podcast eclipsed Bachelor Nation to comprise the wide world of unscripted drama.
Photo: Nick Viall via YouTube
If you were on TikTok or Instagram Reels during Scandoval’s peak, you saw Nick Viall a lot. On his podcast, The Viall Files, the former Bachelor dove all the way into Bravo’s big, nasty lagoon and came back with pearls: a play-by-play of what happened the night Ariana Madix found evidence of Tom Sandoval’s affair, courtesy of Ariana’s bestie Bradley Kearns; what amounted to Charli Burnett’s exit interview as she quit VPR; memories of a one-on-one interaction with Sandoval when the two starred on Special Forces together.
There are plenty of podcasts hosted by reality stars, and there are plenty of podcasts that cover multiple reality-TV franchises. But nobody brings such nuanced and in-depth analysis to the genre. As the hyperreality of social media fills what used to be downtime between seasons, Viall and his co-hosts debate Bethenny Frankel’s union push from all sides and acknowledge the humanity of the people withstanding drama for content. More than that, The Viall Files has become Meet the Press for reality-TV stars: From sprawling convos with the full Bravo roster to explorations of Netflix’s growing reality-verse, The Viall Files is the podcast of record to air one’s feelings about the “reality reckoning” or just state who you think should’ve won The Masked Singer.
Now Viall has started his own podcast network with VPR’sKatie Maloney launching Disrespectfully as its flagship show. Ahead of Vanderpump’s season-11 premiere, The Viall Files dropped an episode with Toms Schwartz and Sandoval. Here, Viall weighs in on the big reality scandals of the past year and discusses how he gets his guests comfortable enough to spill the tea.
Talking to people from so many shows across so many networks, have you noticed any big differences between the casts? They’re different experiences. With The Bachelor or Love Is Blind, there seems to be a clear stop and start. It’s a very controlled environment, you’re cut off from the rest of the world — it’s almost a social experiment. Things like the Bravosphere immerse you in people’s actual lives. Their lives are the show.
I’ve become more of a Bravo fan. That started with Scandoval and Vanderpump. How do they separate being on TV from their reality? As intense as it was being on The Bachelor, once I got done and got out of that bubble, I was able to go back to my life. I could connect with my family and friends and my support system and in some ways heal. On those other shows, their lives become the show. Where do those things stop and start?Are they making choices for themselves, or are they making choices for the show? Do they always know the difference?
Where would you put Love Is Blind on that spectrum of isolation to “the show is your life?” The first part is very much in a bubble in the pods. Then they go back to their lives, all while filming a TV show. It makes it one of the best shows on TV. There’s no higher stakes than Love Is Blind. It’s one thing to get engaged on television. It’s quite another to get married. To get married to someone in such a short period of time and really immerse yourself in that experience, all while still being able to get feedback from family and friends — it’s wild to me.
Your show has three different formats. There’s reality recap, the advice episodes, and the interview episodes. How did you come up with that hybrid model? When I started my show, it was really important to be known as more than just a Bachelor recap show. We certainly talked about The Bachelor from time to time, but I wanted it to be more relationship-based and about social interactions.
Almost to my detriment, I think, I would sometimes try to get away from my origins. As I got more comfortable with what I was doing and the show started getting recognition for being more than just a recap show, I felt more comfortable leaning into it. On TheBach, I was involved in some dramatic situations. Knowing what it was like allowed me to empathize and connect with a lot of my guests. Certainly ones who have gotten caught up in — for lack of a better word — scandal. Most scandals aren’t a Scandoval type of thing, sometimes they’re just silly Bachelor drama, but I think that’s allowed me to have certain conversations.
I try to be very adaptable. That’s one thing I’ve learned from the people who make reality TV. I’ve always been really impressed with how they adapt to different situations and how they’ve been nimble and willing to change course if something wasn’t working.
Why do you think Scandoval hit the public consciousness in a way that “silly little Bachelor dramas” don’t? Infidelity is a very common thing in relationships these days. I think unfortunately we live in a kind of disposable society — fast fashion, fast food and fast relationships. We have this perception of infinite choices when it comes to dating apps, even though we’re often discouraged with our choices. We’re always an app away from finding new matches, and that has led to relationships that have poor communication. All of those things have led to more infidelity. The people who feel wronged by infidelity often feel like there isn’t accountability. Tom was an opportunity to see accountability. He got caught and his friends came at him, and to see someone actually pay the consequences — or at least look like they were paying the consequences — really resonated with people who had been victims of infidelity. And I think that’s why it became larger than Bachelor Nation.
Now that you’ve had day-to-day interactions with Sandoval on Special Forces, how do you balance Tom the reality TV character and the Tom you shared physical space with? The person you see on television is the person I got to know. He is … he’s different. I guess this is the nicest way to put it. I’m not a big fan of buzzwords and oversimplifying people’s personalities or diagnosing people from the internet. Calling people a narcissist, things like that. The Tom I got to know seemed like a guy who can be selfish and in his own world. I was honest with him about that. I don’t think he’s an evil person.
People act like reality TV is “fake” and everyday interactions are “real,” but who’s to say people don’t play roles in real life, too? There’s some truth to that. There’s a lot of disingenuous people in this world and you don’t have to be on reality TV to come across as fake. That being said, it depends on the person.
For example, a lot of criticism I’ve heard lately and agree with is that people who get cast on The Bachelor right now don’t seem very authentic. Those shows have been around so long and social media has been around long enough that it’s become a career opportunity. Back in the day when I went on, certainly we were aware of the opportunities presented by going on the show. But it was far more unclear — I wasn’t sure what those opportunities would be. It was easier for me to just go into that experience and be present and see where that experience would take me. Now it’s harder for people who go on The Bachelor to disconnect and focus on what they’re doing in that world versus being self-conscious of every little thing they say and do and how it’s gonna affect their brand and how many followers they might get. It’s pretty transparent. Which is why I think people fell in love with The Golden Bachelor and the ladies on it. Everyone came across as authentic and there for the experience. Compared to Bachelor in Paradise right after, where it took a nosedive.
Do you think this supporting economy of recap podcasts has something to do with that feeling of inauthenticity? The stars feel like they have a clear line of next steps, so they don’t have to take the first part as seriously. Viewers are now getting so much behind-the-scenes tea it’s changing their experience, too. It keeps the story line going. The experience they go on doesn’t always end when the show itself ends. And then it becomes more like this universe rather than a singular opportunity. And media itself has changed, especially in the podcast arena. In the past, what’s popular on TV would dictate what people talked about on podcasts. In the past year or two, there’s been a bit of a change: If we’re not talking about it, they’re not watching it. It’s like people are consuming far more short-term content, like TikToks and clips from podcasts. If people aren’t excited about that, if there’s not a lot of discourse to come from any particular topic, there tends to not be a lot of people watching.
On the pod, you’ve been critical of the interview Howie Mandel did with Tom Sandoval and the one Bethenny Frankel did with Rachel Leviss. What do you feel you owe to guests who are coming on your show? I owe it to them to do my research. I was less critical of Howie. Howie got some good stuff, even though he wasn’t prepared. Tom definitely talked and … it was a fascinating conversation. I felt differently about the Bethenny one. For all her comments about how these production companies and networks use reality TV stars, it very much felt like Bethenny was doing the same thing to Rachel that she was accusing other people of doing.
Every reality-TV person feels that they get siloed, that they get put into a box, but that there’s far more to them. So I always tell them, “This is your opportunity. The floor is yours.” My goal for every guest is when someone gets done listening to an episode, the guest feels more relatable and more connected. Or if nothing else, the listener is more empathetic to what they’ve gone through. Especially people who have been caught up in a scandal, just to hear the other side and get into the details of it. Reality TV is notorious for not involving nuance. It’s been a lot of fun to offer that to the people who come on my show.
What is your weekly viewing diet to keep up with all of these shows? It’s a lot. Thankfully, my fiancée and I are homebodies, and we like a lot of the same content. We tend to watch a few hours of reality TV every night. I don’t get to watch everything. For example, I’ve recently had the pleasure of interviewing Lindsay Hubbard from Summer House and Olivia from Southern Charm — both shows that I have seen but haven’t been a regular viewer of. We just have to do our research. I’ll go back and watch the relevant episodes. The reunions are always super helpful for context. I want to make sure we’re asking the questions our audience wants to hear. I always want to be an expert in the things I’m discussing on my show.
Journalist to journalist, how do you decide on which question to ask when? I always like to be prepared, but also I’m not overly prepared. I never list out questions. I like to be an active listener and adapt to what they say. And I really try to create an environment where it’s friend to friend. I’ve had so many conversations in my personal life about hard breakups. I was the guy who, when I was sad about relationships, would want to talk to my friends often. I always remember that setting and mood when I’m having these types of conversations. We are always talking about some type of relationship, either romantic or friendship. I want it to come across as two friends sharing their stories. And I want to be the friend, when it’s appropriate, to challenge a friend who might be passionate about a feeling but isn’t seeing things clearly. It’s like, “Yeah, I know you feel this way. But have you considered the other person’s point? Do you see what they have to say?”
Do you have a dream guest? So many. Obviously if there’s a scandal in reality TV, my show seems to be the place where people want to go to share their stories. I take great pride in that.
With our reality recaps, where I just have celebrities and public figures on to talk about our favorite culture and reality TV topics, I would love to get the Jennifer Anistons or Taylor Swifts of the world, who have talked about their love of reality TV from time to time.
J. Law. Jennifer Lawrence, Margot Robbie, Jon Hamm as well. It’s so fun to be a fan of someone and have a shared interest. It makes all those celebrities even more relatable.
Did you have a favorite reality-TV moment of the past? Something you couldn’t stop talking about? The Bethenny “reality reckoning” has been interesting. I am someone who had some very challenging experiences during my time on reality TV. I had a lot of difficult mental-health situations, I had frustrations with the people I interacted with. But I also had some really positive experiences.
I try to focus on things I can control. And despite my frustration sometimes, the way I look at it is, I, as an adult, chose to go on these shows. Certainly, not knowing exactly what I was signing up for, but with an awareness that I was taking a risk that things might not work out the way I want. I was aware of the fact that I was putting myself in a position to be manipulated or misled or misrepresented. There’s been a cost to that, but I’ve been able to turn it into an incredible opportunity. Everything I’m doing today is a direct result of my time on The Bachelor. I find it to be more beneficial to hold myself accountable for the choices I made. I find it frustrating when I hear people who have gone on the show and their gripes usually don’t come until their star dims. It always seemed to be a very similar pattern. I don’t agree with it.
There’s a lot of people who don’t agree with me. I always tell my team, ”Listen. I like to be liked, and certainly I like it when people agree with my takes, but that’s not the most important thing. It’s that people care what we’re saying.” I appreciate the people who disagree with the household’s take as much as I appreciate the people who agree. Because at the end of the day, they care what we have to say.
This interview has been edited for content and clarity.
By submitting your email, you agree to our
Terms and Privacy Notice
and to receive email correspondence from us. This site is protected by reCAPTCHA and the Google
Privacy Policy and
Terms of Service apply.
or
Already a subscriber?
What is your email?
This email will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
Password must be at least 8 characters and contain:
Lower case letters (a-z)
Upper case letters (A-Z)
Numbers (0-9)
Special Characters (!@#$%^&*)
This password will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
You’re in!
As part of your account, you’ll receive occasional updates and offers from New York, which you can opt out of anytime.
or
Already a subscriber?
What is your email?
This email will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
Password must be at least 8 characters and contain:
Lower case letters (a-z)
Upper case letters (A-Z)
Numbers (0-9)
Special Characters (!@#$%^&*)
This password will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
You’re in!
As part of your account, you’ll receive occasional updates and offers from New York, which you can opt out of anytime.
Already a subscriber?
Already a subscriber?
`;
// integrate Sub(x) scripts and elements
if (hostname !== 'subs.nymag.com') { // do not integrate on this subdomain
document.head.appendChild(trackingScript);
document.body.insertAdjacentHTML('beforeend', subXAnimationElements);
}
There was an error processing the request. Please try again later."}).catch(e=>console.error("Error verifying email: ",e)))(r.querySelector(".content"),o.bannerCTAVerification)})):(l.remove(),s.remove()),o.dismissable||n.remove(),o.useAlertIcon||a.remove(),r.classList.add("show"),n.addEventListener("click",()=>{u(),r.classList.remove("show")})}else r.remove()}});
}, {"1":1,"6":6,"12":12,"35":35,"40":40}];
window.modules["global-nav.client"] = [function(require,module,exports){"use strict";const dom=require(4),auth=require(12),signInButton=dom.find(".user-signin"),signOutButton=dom.find(".user-signout"),globalNav=dom.find('[class^="global-nav"]'),body=dom.find("body"),dropdownItems=dom.findAll(".dropdown-wrap"),gtm=require(1),appendLandingPageParams=require(135),pageUri=require(124).getPageUri(),subscriptionPromoLinks=dom.findAll(".persist-params"),searchString=window.location.search||"";function closeDropdowns(e){let n=globalNav.querySelectorAll(".dropdown.open");dropdownItems.forEach(function(t){let o=t.querySelector(".dropdown");!n||t.contains(e.target)&&27!==e.keyCode||o.classList.remove("open")})}function gtmSendReport(e,n,t){let o={eventCategory:"ecommerce",eventAction:"componentClick",brand:e,dimension23:"global-nav",list:pageUri,pageZone:"header",variant:"nav-link"};"global-nav-link"===t&&(o.eventLabel=n.href),gtm.reportNow(o)}function updateElementTargetUrlsIfQueryStrings(e){if(searchString){const n=new URLSearchParams(searchString);let t=e.href;if(t.includes("?")){const o=t.split("?"),i=new URLSearchParams(o[1]);for(let e of n.entries())i.set(e[0],e[1]);t=`${o[0]}?${i.toString()}`,e.href=t}else e.href=`${t}?${n.toString()}`}}function init(e){const n=e.querySelectorAll(".to-landing-page");window.addEventListener("auth:init",()=>{signInButton.addEventListener("click",function(e){e.preventDefault(),auth.showEmbeddedLoginFlow("top navigation")}),signOutButton.addEventListener("click",function(e){e.preventDefault(),gtmSendReport("Sign Out",e.target,"user-info-link"),auth.logout()}),auth.isAuthenticated()&&e.classList.add("signed-in"),auth.isSubscriber()&&e.classList.add("subscribed"),e.querySelectorAll(".user-link").forEach(e=>{e.classList.add("active")}),subscriptionPromoLinks.forEach(e=>{updateElementTargetUrlsIfQueryStrings(e)}),appendLandingPageParams(n)})}dropdownItems.forEach(function(e){e.addEventListener("click",function(){e.querySelector(".dropdown").classList.toggle("open")})}),body.addEventListener("click",closeDropdowns),document.addEventListener("keydown",closeDropdowns),globalNav.addEventListener("click",function(e){let n=e.target;n.classList.contains("global-nav-track")&>mSendReport(n.text,n,"global-nav-link")}),module.exports=init;
}, {"1":1,"4":4,"12":12,"124":124,"135":135}];
window.modules["aaa-module-mounting.legacy"] = [function(require,module,exports){"use strict";const _pickBy=require(221),_each=require(406),Fingerprint2=require(408),DS=require(407),Eventify=require(246);function registerGlobals(){window.DS=DS,window.Eventify=Eventify,window.Fingerprint2=Fingerprint2,DS.value("Eventify",Eventify),DS.value("Fingerprint2",Fingerprint2),DS.value("$document",window.document),DS.value("$window",window)}function mountDollarSliceComponents(){DS.service("components",["$document","$module",function(e,n){var o=_pickBy(n.definitions,e=>e.providerStrategy===n.providers.controller),r=Object.keys(o);function t(e){return o=>{try{n.get(e,o)}catch(e){logMountError(o,e)}}}_each(r,n=>{var o=e.querySelectorAll('[data-uri*="/_components/'+n+'/"]'),r=e.querySelectorAll('[data-uri$="/_components/'+n+'"]');_each(o,t(n)),_each(r,t(n))}),this.components=r}]),DS.get("components")}function logMountError(e,n){const o=e.outerHTML.slice(0,e.outerHTML.indexOf(e.innerHTML));console.error("Error attaching controller to "+o,n)}registerGlobals(),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{mountDollarSliceComponents()}):mountDollarSliceComponents();
}, {"221":221,"246":246,"406":406,"407":407,"408":408}];
window.modules["ads.legacy"] = [function(require,module,exports){"use strict";const _map=require(118),_forEach=require(107),_isString=require(268),_intersectionWith=require(409),_isEqual=require(274),_each=require(406),_debounce=require(182),_sortBy=require(205),page=require(124),visit=require(114);DS.service("adService",["Eventify","$cid","$document","$window",function(e,t,a,i){var o,n,s,r,d,c,u,l,g={},p=this,h=[],f=visit.getQueryParamsObject(["utm_campaign"]),m=document.querySelector('script[data-type="ad-a9"]'),b=[],w=!1,v=[],y=document.querySelector('script[data-name="ad-doubleverify"]');document.querySelector('script[data-name="concert-ads"]')||(i.NYM={},i.NYM.analytics={},i.NYM.analytics.adStartTime=i.performance.now(),i.googletag=i.googletag||{},i.googletag.cmd=i.googletag.cmd||[],u=i.googletag,(m||y)&&(i.googletag.cmd=i.googletag.cmd||[],i.googletag.cmd.push(function(){i.googletag.pubads().disableInitialLoad()})),m&&(l=i.setInterval(function(){void 0!==window.apstag&&void 0!==window.apstag.timeout&&(i.clearInterval(l),window.apstag.cleared=!0,l=null)},10),setTimeout(function(){l&&(i.clearInterval(l),i.googletag.pubads().refresh(),window.apstag||console.log("MESSAGE: Timeout for A9 load exceeded, aborting"))},500)),y&&(b.push(new Promise(function(e){w?e():v.push(e)})),c=i.setTimeout(T,2500)),o=function(e){var t,a,o=e.data,n=[];return o.loaded?e:(o.loaded=!0,t=null,(t=o.sizes?u.defineSlot(o.name,o.sizes,o.id).addService(u.pubads()):u.defineOutOfPageSlot(o.name,o.id).addService(u.pubads())).setTargeting("adid",o.id),f.hasOwnProperty("utm_campaign")&&t.setTargeting("utmcamp",f.utm_campaign),a=p.getAdCount(o.label),t.setTargeting("label",o.label+"_"+o.site+"-"+a),u.display(o.id),u.pubads().addEventListener("slotOnload",function(){i.NYM.analytics.firstAdLoadTime||(i.NYM.analytics.firstAdLoadTime=i.performance.now(),i.NYM.analytics.firstAdLoadLabel=e.data.label)}),n=_(o),Promise.all(b).then(function(){n?window.apstag&&window.apstag.cleared?window.apstag.fetchBids({slots:[n],timeout:window.apstag.timeout},function(){u.cmd.push(function(){window.apstag.setDisplayBids(),u.pubads().refresh([t],{changeCorrelator:!1})})}):y&&u.pubads().refresh([t],{changeCorrelator:!1}):u.pubads().refresh([t],{changeCorrelator:!1})}),e.slot=t,e)},n=function(e){var a,i,o,n=t(),s=e.getAttribute("data-name"),r=e.getAttribute("data-sizes"),d=e.getAttribute("data-label"),c=e.getAttribute("data-site");n=e.id,r&&r.length?(r=r.split(","),a=[],_map(r,function(e){e=e.split("x"),i=parseInt(e[0]),o=parseInt(e[1]),a.push([i,o])})):(e.classList.add("oop"),a=!1),this.data={id:n,name:s,sizes:a,loaded:!1,label:d,site:c},g[n]=this},r=function(e){u.cmd.push(function(){var t=o(e);g[e.data.id]=t})},s=function(e){var t=[];e.slot?(t=_(e))&&window.apstag&&window.apstag.cleared&&window.apstag.fetchBids({slots:[t],timeout:window.apstag.timeout},function(){u.cmd.push(function(){window.apstag.setDisplayBids(),u.pubads().refresh([e.slot],{changeCorrelator:!1})})}):e&&r(e)},u.cmd.push(function(){var e,t,o,n=page.getMeta("article:tag"),s=page.getMeta("author"),r=i.location.href,d=(e=a.head.querySelector(".head-gtm"),t=a.body.querySelector(".gtm"),e&&"top"===e.getAttribute("data-gtm")?"gtmtop":t&&"bottom"===t.getAttribute("data-gtm")?"gtmbottom":"");o=[],_forEach([n,s,d],function(e){_forEach(e.split(","),function(e){(e=e.trim().toLowerCase().replace(/\s/g,"-").replace(/\'|\’/g,"")).length&&o.push(e)})}),u.pubads().setTargeting("kw",o),u.pubads().setTargeting("entry_group",o),r=r.slice(r.lastIndexOf("/")+1),u.pubads().setTargeting("pn",r),u.companionAds().setRefreshUnfilledSlots(!0),u.pubads().enableAsyncRendering(),u.enableServices()}),this.load=r,this.create=function(e){return new n(e)},this.refresh=function(e){var t;_isString(e)?(t=this.getById(e),s(t)):s(e)},this.remove=function(e){var t=e.data.id;a.getElementById(t).innerHTML=""},this.getAdCount=function(e){var t,a=0,i=Object.keys(g);return _each(i,function(i){(t=g[i]).data.loaded&&t.data.label===e&&a++}),a},this.getById=function(e){return g[e]},d=_debounce(function(){var e={TopLeaderboard:1,RightColTopMPU:2,outOfPage:99,"homepageTakeover/TopLeaderboard":1},t=_sortBy(h,function(t){return e[t.data.label]||10});_forEach(t,function(e){return e.data.sizes?r(e):i.setTimeout(function(){r(e)},2e3)}),y&&window.PQ.cmd.push(()=>{try{window.PQ.loadSignals(["ids","bsc","vlp"],T)}catch(e){T(),console.error(`There has been an error loading Double Verify signals: ${e}`)}}),h=[]},10),this.addToPageLoadQueue=function(e){h.push(e),d()});function _(e){var t,a=e.sizes;return a=_intersectionWith(a,[[970,250],[970,90],[728,90],[300,600],[300,250],[320,100],[320,50]],_isEqual),e.sizes&&e.sizes.length&&(t={slotID:e.id,sizes:a,slotName:e.label}),t}function T(){i.clearTimeout(c),w=!0,_forEach(v,function(e){e()})}}]);
}, {"107":107,"114":114,"118":118,"124":124,"182":182,"205":205,"268":268,"274":274,"406":406,"409":409}];
window.modules["cid.legacy"] = [function(require,module,exports){"use strict";DS.service("$cid",function(){var r=Math.floor(100*Math.random());return function(){return"cid-"+ ++r}});
}, {}];
window.modules["client.legacy"] = [function(require,module,exports){"use strict";require("cid.legacy"),require("ads.legacy"),require("facebook.legacy"),require("aaa-module-mounting.legacy");
}, {"cid.legacy":"cid.legacy","ads.legacy":"ads.legacy","facebook.legacy":"facebook.legacy","aaa-module-mounting.legacy":"aaa-module-mounting.legacy"}];
window.modules["facebook.legacy"] = [function(require,module,exports){"use strict";DS.service("facebook",[function(){this.fb=function(i){window.FB&&window.FB[i].apply(this,Array.prototype.slice.call(arguments,1))}}]);
}, {}];
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o typeof key === 'string' && key.match(/\.legacy$/)).forEach(key => window.require(key));
}
function tryToMount(fn, el, name) {
try {
fn(el); // init the controller
} catch (e) {
const elementTag = el.outerHTML.slice(0, el.outerHTML.indexOf(el.innerHTML));
console.error(`Error initializing controller for "${name}" on "${elementTag}"`, e);
}
}
/**
* mount client.js component controllers
*/
function mountComponentModules() {
Object.keys(window.modules).filter(key => typeof key === 'string' && key.match(/\.client$/)).forEach(key => {
let controllerFn = window.require(key);
if (typeof controllerFn === 'function') {
const name = key.replace('.client', ''),
instancesSelector = `[data-uri*="_components/${name}/"]`,
defaultSelector = `[data-uri$="_components${name}"]`,
instances = document.querySelectorAll(instancesSelector),
defaults = document.querySelectorAll(defaultSelector);
for (let el of instances) {
tryToMount(controllerFn, el, name);
}
for (let el of defaults) {
tryToMount(controllerFn, el, name);
}
}
});
}
// Make sure that a `window.process.env.NODE_ENV` is available in the client for any dependencies,
// services, or components that could require it
// note: the `` value is swapped for the actual environment variable in /lib/cmd/compile/scripts.js
window.process = window.process || {};
window.process.env = window.process.env || {};
if (!window.process.env.NODE_ENV) {
window.process.env.NODE_ENV = '';
}
// note: legacy controllers that require legacy services (e.g. dollar-slice) must
// wait for DOMContentLoaded to initialize themselves, as the files themselves must be mounted first
mountLegacyServices();
mountComponentModules();
// ]]