Spencer director Pablo Larrain is joining us at Vulture Festival to literally put on a film school for us. Join us at the Hollywood Roosevelt in Los Angeles on Sunday November 14 at 11:30am to learn about the five films that have shaped the filmmakers’ approach to his craft. Get your tickets here!
You never know where Pablo Larraín is going next. After making several films in his native Chile, the director gave the biopic genre a much-needed jolt with Jackie and Neruda. The thrillingly unorthodox films, both released in 2016, reinterpreted their subjects’ public images, zeroing in on singular chapters of Jacqueline Kennedy’s and poet Pablo Neruda’s lives to subvert the cradle-to-grave approach that most filmmakers take. This fall, Larraín will release the much-anticipated Spencer, in which Kristen Stewart plays Princess Diana. The film follows her over the course of the 1991 Christmas holiday when she decides to leave Charles. If the haunting close-ups in Jackie and the noirish lyricism of Neruda are any indication, Spencer will be another mood-driven interpretation of its subject (including a score by Phantom Thread’s Jonny Greenwood and cinematography by Portrait of a Lady on Fire’s Claire Mathon). Larraín sees biopics not as historical documents but as fables that can reveal profound insights about human nature.
In the run-up to Spencer, however, Larrain released a non-biopic work — the low-budget DIY odyssey,Ema, now playing in select theaters. Set in his home country, the movie follows a testy choreographer (Gael García Bernal) and a pyromaniacal dancer (Mariana Di Girólamo) who recently gave up the child they’d adopted together and are in the throes of relationship chaos. Larraín, a master of cinematic reinvention, gave his Ema actors only a broad outline to start with. Once production began, he handed them the script pages (developed with writers Guillermo Calderón and Alejandro Moreno) the day before those scenes were to be shot. Along the way, the cast and crew would feel their way through the volcanic story, often taking inspiration from the trippy lighting design and the reggaeton-inflected score. “It’s very different from everything else I’ve ever done, so I keep it in my heart with a lot of love and good memories of the process,” Larraín explains in an interview with Vulture, in which he discusses hiding scripts from his actors, the Hollywood projects he’s been offered, and the moviegoers who will inevitably misunderstand Spencer.
It’s interesting that you chose Ema after Jackie, a movie that was very demanding in terms of production design and your obligation to historical accuracy. You’d re-created an entire White House tour shot for shot. Ema let you go in any direction you wanted. You didn’t even let the actors see full scripts. After Jackie, were you looking for something more stripped-down and open-ended? It’s not really a reaction to a previous work. It’s basically, Where are the possibilities to find the space where you can be as free as possible? What I really try to do is challenge the conventions of “how do you make a movie?” A movie is made with a lot of people, and a movie is made with — as you were saying — preconceptions of whatever you’re going to capture. The bigger the movie, the little that is left for [what happens on] set. There’s a way to do the opposite, which is to really not prepare anything and just have a script that is in development as you shoot. That’s what happened with Ema and another movie I did, The Club. They were both made with the same styles. Actors never knew the script; they never knew what we were going to shoot. They spent more time dancing than talking or rehearsing at all.
What was the structure of the film that you went in with compared to the final product that we now see? We shot three different endings, and we had a very abstract structure that I think is reflected in the movie. But how things happened and how they evolved in the characters is all new. We started shooting with an outline, and then during the process, we were writing. It might sound crazy because movies are made the same way all over the world — you end up with an actor in front of a camera and things can be very simple somehow. But it’s a low-budget film and we didn’t really have to explain the movie to anyone. We didn’t have to go out and try to make a point and present a script and a schedule. No, we just found pieces over time and put them together.
You certainly wouldn’t have been able to make a movie that way in the United States. Were you specifically seeking the freedom that Chile gives you? Yeah, it’s possible that this movie, in the way we did it, would never have been made anywhere else. But also this movie is made in the heart of a city that only exists [in Chile], so it could only happen there. The city [Valparaíso] is a character — that beautiful and strange port that we have on our coast is full of history and our own ways for immigrants. It has a very punk, artistic culture. I think the new movie Gaspar Noé shot, he did it like this. Maybe there are people who are trying to do this. Part of the problem is that it’s so expensive to shoot in the U.S. The system in the U.S. will never allow you to make a movie like this, even for a low budget. Here, we do have unions and you respect them, of course, but there’s a way where people can go and feel that they’re really expressing themselves on a movie and not just moving a light or putting a dolly somewhere. That creates a different energy in the crew and in the cast. They understand that it’s a little journey and it takes a couple of months to do it.
This is the third movie you’ve made with Gael, who has said that he signed on before reading any kind of script whatsoever. There must be a reason that you keep returning to him. What kind of shorthand developed at this point? He’s a very good friend, first. We’re both parents, and I think there’s something in the subject that we cared about. Then there’s something in the character himself, which is the absurd crisis of the artist. I guess he connected with that, too. He’s obviously a great actor and a very handsome person, but he has something that is the essence of cinema, which is that he’s mysterious. You put him in front of a camera and you ask him not to do much and to just give a few indications, and the audience will always wonder what’s going on. It’s that mystery. Maybe people don’t go to the movies and say, “Hey, I love that actor because he’s mysterious,” and even sometimes in the press or in the reviews, they don’t talk about that. But if you talk about great actors, most of them have that. I’m always mesmerized by that.
Much of your work revolves around characters in crisis: the central couple in Ema, the protagonists in No, Jackie, Lisey’s Story. In Spencer, Diana is at Sandringham House, where the royal family spends its holidays, grappling with her disintegrating relationship with Charles. Why do you think you gravitate to that? Isn’t it the key of cinema to have an actor or a character in a crisis? All the dramatic theory orbits around that somehow. There are movies like Jackie or Spencer where you don’t know what the character wants up until the point of the movie. Some characters don’t know what they want, but a situation makes them understand they are in a crisis. And as the movie evolves, they need to really understand it. So it’s a more existentialist type of cinema. It’s really about the structure, but there’s always something that has to make the character explode.
At this point, you’ve worked with a number of famous A-listers: Natalie Portman, Julianne Moore, Clive Owen, Kristen Stewart. As talented as they may be, audiences have preconceived notions of them. What’s the advantage of casting someone like Mariana Di Girólamo, whom audiences can see as a blank slate? I actually just saw a picture of her in a magazine, and then I had a coffee with her and we hired her. She had some experience in television, but not a lot in movies. Gael was very helpful in understanding the logic of how you make a movie with a single camera and how you perform for one camera. But I guess the main thing is that Mariana, as the character, is completely unpredictable. You have no idea what’s going on inside of her, and that makes her quite dangerous, especially when she’s holding a flamethrower. I remember we were testing it, and we were going to have a stand-in who was going to operate the flamethrower. But Mariana wanted to do it. I said, “Mariana, that is not how you do movies. You’re going to have a stand-in. It’s a war weapon.” She really insisted. All of a sudden, I had an actress that I never knew really throwing a loaded flamethrower on the set. We rehearsed it and it was safe, but it was like, Whoa! She built that character from an unknown place. She didn’t know much about the character or the story because I hid the scripts from the actors.
If you hid the scripts from the actors, what did you tell them? I told them the main concept and where it was going. Sometimes it was troubled.
Troubled? Yeah, because some actors would take it well and say, Okay, whatever. But Gael, sometimes I would say, “Do this” or “Say that,” and he was like, Why? I’d say, “Because that is what’s needed.” “Okay, but I need to understand, my friend.” There are many ways to make a movie, but in this case, it’s an exercise in facing the void of life. You have no idea what’s really going to happen to you in the following hours; anything can happen. That’s what I was trying to reach. I wanted actors who were standing there in a void of things that may happen or may not.
The style of dance that we see in Ema makes so much sense in terms of the personalities of the two central characters. The choreography is full of sensual silhouettes, very street-dance-inflected. Tell me about conceptualizing the style of the choreography and what it represented for you. I’m about to turn 45, so reggaeton is something that’s not really my generation. It’s quite strong in Latin America. [Composer] Nicolas Jaar made me think that the only way to do this was through reggaeton. We quickly changed the concept that we had before, which was more of a contemporary dance company, and we turned it into more of a street-type dance. We brought that into the argument of the film, because the choreographer [played by Bernal] does not understand the love and passion for reggaeton. And the dancers who really feel that they want to express themselves want to connect with what’s going on in the streets. They don’t care about this idea of “culture.” That was a very interesting friction. And then I had to embrace reggaeton. It was not easy! It’s a very tough, distinct melody that has roots in Central America, which, even though it’s close to us, is quite different from our culture. It made me understand that we were making a movie about a generation that is different from us.
Our country is changing right now in an incredible and great way because of the new generation. Dance opened my eyes to something that was way deeper that has political meanings and also a cultural perspective that I needed to embrace and understand. That was very beautiful for me. At some point, instead of conducting them so much, especially the female characters, I just let them say what they wanted. Somehow that became very relevant to the heart of the narrative.
Something I admire about your work is the way that each project is stylized in a totally different way. I think back to the film-noir stylings of Neruda, the extreme close-ups in Jackie. Do you feel like you get to reinvent yourself with every movie? I try. I wouldn’t want to repeat myself. I admire a lot of directors who have a very precise style over the years, like Pedro Almodóvar. You know what you’re going to get when you see his movies. But I’m trying to behave in a way that I can feel surprised with the way that we’re shooting. I’m trying to look for something we haven’t done before and to be in a place that is unknown for [the audience]. You don’t always succeed, but I try to stay out of the comfort zone with things that you know will work.
I want to create a mood. For Ema, the mood and the tone of the film are part of the experience for the audience. In this case, having Nicolas’ score before we started shooting really helped me to understand how we were going to move around. What was the speed? What was the tone? Estefania Larrain, our production designer, designed everything with very precise colors, and Sergio Armstrong, our DP, went really weird with certain lighting systems. I hadn’t seen something like that, at least on my sets. Then you embrace it, and that becomes the style of the movie. It’s interesting when you try to do that because also I never see a movie again.
Your own movies, you mean? Yeah, I just don’t look back, because it’s very cruel.
By the time Jackie came out, you’d been making movies for a while. But it really put you on the map with American audiences, and obviously people are going to draw comparisons between it and Spencer. What kind of offers and opportunities did you get from Hollywood in the wake of its success? All kinds of things. I don’t think Hollywood executives could put me on any specific list around any specific type of movie or style. I remember when I started working with an agent at CAA nearly 14 or 15 years ago. I did a movie called Tony Manero that was about a serial killer, and then I got a lot of serial-killer scripts, which was strange. And then over the years I have been invited to different kinds of things. I worked for a while to developScarface, but it didn’t work out. When I was invited to do Lisey’s Story, I thought it was something interesting because it just came out of nowhere. There wasn’t really a logic for why you would be inviting someone like me to do something like that. I had never been in that space before, so I went for it. I love to be hard to classify.
Are you conscious of the fact that, after Jackie, Neruda, and Spencer, people see you as someone who is deconstructing the biopic genre? I’ve never done it consciously. First, I don’t have a plan of doing this or that type of movie. I’m not trying to build my career so people can create any kind of logic or analyze it in any specific way. Also, I don’t think I’ve ever done a biopic. I think Neruda and Jackie and Spencer are movies about people in certain circumstances where everything is about to explode. They’re not really biographical analyzations; it’s not the study of a life of someone. I think some people could misunderstand it. Before they go to see a movie like Spencer, they might say, We’re going to really understand who this person was. No! Wrong number! Wrong movie! We don’t do that! We’re just trying to work with whatever that person was and create a fable out of it. That’s what I’m looking for. We’ll see if it works.
This interview has been condensed and edited for clarity.
Pablo Larraín Isn’t Reinventing the Biopic With Spencerhttps://pyxis.nymag.com/v1/imgs/b4d/94d/3bc7ef035060e544e5ee3371386cff60d5-pablo-larrain-chat-room-silo.png
Things you buy through our links may earn Vox Media a commission.
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,"17":17,"35":35,"40":40}];
window.modules["global-nav.client"] = [function(require,module,exports){"use strict";const dom=require(4),auth=require(17),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 i=t.querySelector(".dropdown");!n||t.contains(e.target)&&27!==e.keyCode||i.classList.remove("open")})}function gtmSendReport(e,n,t){let i={eventCategory:"ecommerce",eventAction:"componentClick",brand:e,dimension23:"global-nav",list:pageUri,pageZone:"header",variant:"nav-link"};"global-nav-link"===t&&(i.eventLabel=n.href),gtm.reportNow(i)}function updateElementTargetUrlsIfQueryStrings(e){if(searchString){const n=new URLSearchParams(searchString);let t=e.href;if(t.includes("?")){const i=t.split("?"),o=new URLSearchParams(i[1]);for(let e of n.entries())o.set(e[0],e[1]);t=`${i[0]}?${o.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()||auth.isMobileAppRequest())&&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,"17":17,"124":124,"135":135}];
window.modules["aaa-module-mounting.legacy"] = [function(require,module,exports){"use strict";const _pickBy=require(221),_each=require(408),Fingerprint2=require(407),DS=require(406),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(408),_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,"408":408,"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();
// ]]