What’s Going on With Alec Baldwin’s Rust Manslaughter Trial?
ByVictoria Bekiempis,
who writes about courts and crime for Vulture and other outlets
Photo: Courtesy CBS
Alec Baldwin’s involuntary manslaughter trial in the Rust set shooting started in earnest on Wednesday, July 10, in Santa Fe, New Mexico, with opening statements. Baldwin, 66, is accused of accidentally killing the production’s cinematographer, Halyna Hutchins, on October 21, 2021, while rehearsing a scene. The prosecution claims that armorer Hannah Gutierrez-Reed provided the gun to Baldwin. The firearm hadn’t been properly checked by Gutierrez-Reed and contained live ammunition, according to the prosecution. Prosecutors claim that Baldwin drew the gun and “pointed the weapon” at Hutchins — in disregard of safety practices — and fired. Hutchins was fatally shot, and director Joel Souza injured, in the incident. Baldwin has pleaded not guilty in the case.
Since Baldwin was first charged in January 2023, the proceedings have been rife with legal twists and turns, with the prosecution officially dropping the case on April 21, 2023, only for an indictment to come down against him in early 2024. The trial is expected to take ten days. Baldwin faces up to 18 months behind bars if convicted. Here’s what to know about the destroyed weapon, jury selection, and opening statements.
Why is Baldwin on trial in the first place if the charge was dropped?
Baldwin’s legal team revealed a major bombshell during a proceeding on March 9, 2023 — attorney Alex Spiro claimed in court that the gun had been “destroyed by the state” during testing in a way that made it impossible for the defense to examine it. Not only had Baldwin previously insisted that he was told the gun was “cold” and not loaded with live bullets, but he also claimed he didn’t pull the trigger. Baldwin has maintained that the gun malfunctioned in some way, or was altered, allowing it to fire without pulling the trigger. In the wake of Baldwin’s defense raising issues about the weapon being destroyed, prosecutors agreed to dismiss the case pending further testing but did so in a way that didn’t prevent them from bringing charges later.
“Predictably, the forensic testing concluded that the trigger of the gun had to be pulled for the gun to have discharged, and the alleged modification of the hammer was simply damage caused when the FBI struck the hammer with the mallet so many times that it finally damaged the hammer and sear,” read an April 5, 2024, filing. After the prosecution’s analysis of the gun ended, prosecutors said they obtained recordings from the Rust set showing that the firearm was in “perfect working condition” every time Baldwin used it. Prosecutors ultimately presented the evidence to a grand jury that returned an involuntary-manslaughter charge against him on January 19, 2024.
Weren’t other people already found guilty in Hutchins’s death?
On March 6, 2024, 27-year-old Gutierrez-Reed was found guilty of involuntary manslaughter. During Gutierrez-Reed’s two-week-long trial, prosecutors insisted that she flouted commonsense gun-safety protocols in a deadly manner. “By failing to make those vital safety checks, the defendant acted negligently and without due caution,” prosecutor Jason Lewis told jurors. “The decisions she made that day ultimately contributed to Ms. Hutchins’s death.” He also alluded to Gutierrez-Reed’s own comments during a police interview following the incident. “She says at the end: ‘I just, I don’t know. I wish I would have checked it,’” Lewis told jurors. “And so do we.”
Gutierrez-Reed, who has maintained her innocence, was sentenced to 18 months in prison on April 15, 2024. David Halls — who previously pleaded no contest to negligent use of a deadly weapon and received a six-month suspended sentence — took the stand at Gutierrez-Reed’s trial and said she handed the gun to Baldwin, despite the actor’s claiming Halls passed the gun to Baldwin.
So how is Baldwin on the hook if Gutierrez-Reed was already found guilty?
The judge decided on July 8, 2024, that prosecutors cannot present evidence about Baldwin’s role as a producer; this is a major boost for the defense, as prosecutors have pushed the theory that his role as a producer made him responsible for set safety or culture, adding still more to his culpability in Hutchins’s death. “I’m having real difficulty with the state’s position that they want to show, as a producer, he didn’t follow guidelines and therefore, as an actor, Mr. Baldwin did all these things wrong, resulting in the death of Halyna Hutchins because as a producer he allowed this all to happen,” Judge Mary Marlowe Sommer said on July 8. Sommer noted how Baldwin wasn’t alone in being a producer, so mentioning his role as producer could unfairly suggest he was the only boss on set. “I’m denying evidence of his status as a producer.” This also appears to mean that prosecution won’t be able to show videos of him rushing cast and crew and controlling the set, so they’ll have to focus on his behavior as an actor on set. Court papers filed in the case provide some insights into prosecutors’ playbook about why they believe he’s culpable even just as an actor. Baldwin, “the most experienced member of all the cast and crew,” arrived on set one week after filming started, missing the first firearms training. Instead, Baldwin had a separate instruction with Gutierrez-Reed. “Mr. Baldwin was inattentive during this training and spent time during the training on the phone with his family and making videos of himself shooting the gun for his family’s enjoyment,” they note.
“The combination of Hannah Gutierrez’s negligence and experience and Alec Baldwin’s complete lack of concern for the safety of those around him would prove deadly for Halyna Hutchins …” prosecutors wrote. “Hutchins was shot and killed by Alec Bladwin who pointed a .45-caliber single-action army revolver at her, cocked the hammer of the gun, and pulled the trigger when a scene was not being filmed and cameras were not rolling.”
Can prosecutors win with multiple theories of why Hutchins died?
For Tre Lovell, a longtime civil trial attorney, the separate theories aren’t a problem for prosecutors. “The real question is: Are the theories incongruous?,” he asked. “Are they incompatible? They or are they not mutually exclusive?” Lovell said. “It is possible to have more than one contributing factor to death.” Gutierrez-Reed was found responsible, because the armorer’s job is to ensure gun safety, which a jury determined she did not do. “What they’re saying with Baldwin is he also contributed, because he was negligent in the use of a firearm,” Lovell said.
Why didn’t Alec Baldwin get a plea deal like David Halls did?
Well, it’s a bit of a long story. Prosecutors gave Baldwin the option of taking “a very favorable plea agreement rather than have the case proceed to grand jury for a possible indictment.” As it turns out, the special counsel appointed to prosecute Baldwin’s case, Erlinda Johnson, is a longtime criminal-defense and civil-rights attorney. Johnson said in court papers that while prosecutors don’t have to treat all defendants in a case the same way, her career has made her focus on issues “related to fundamental fairness.”
Johnson alleges that Baldwin’s behavior following the offer made her think differently. When the prosecution made the offer on October 5, 2023, it was as “confidential and privileged plea negotiations.” Johnson, who gave them an October 27, 2023, deadline, claims she didn’t get a response from Baldwin’s team. About ten days after Johnson extended the offer, she found out that one of Baldwin’s attorneys shared details with NBC News, according to court papers.
The prosecutor also claims that she learned Baldwin and his team were trying to run a public-relations campaign “designed to deflect attention” from any possible pleas and boost his image. She also claims to have learned that Baldwin might accept the offer and then file a complaint against New Mexico authorities “on the same day” as part of that same PR campaign.
Despite this, Johnson says that she didn’t want to withdraw this plea offer just because Baldwin was allegedly trying to use the media in his favor. Johnson said that she then found out Baldwin had commissioned a documentary about Hutchins’s death and “was actively pressuring material witnesses in the case against him to submit to interviews” in this project. “It was at this point that the plea offer was rescinded, and the case was scheduled for the grand jury,” she said. In other words, Baldwin had a chance and blew it, according to the prosecution.
So, Baldwin hasn’t exactly done himself any favors in this case?
Nope! And, according to court documents, this started way before charges were even brought against him. On the same day of Hutchins’s shooting, Baldwin agreed to a formal interview with police. Before the interview started, Baldwin was in the interview room — where cameras with audio were recording — and allegedly made some insensitive comments to his family. Baldwin rang his wife — on speaker phone or FaceTime — as well as an assistant to talk about his family’s planned trip to New Mexico. Baldwin told his family not to cancel their trip despite the incident. “I won’t work and we’ll go and enjoy ourselves. It’s all paid for. They’re not going to give us the money back,” he allegedly said. Then came the interview. He claimed that Gutierrez-Reed handed him the gun — not Halls. He said “on two occasions that he fired/shot the gun” and that Souza told him where to point the weapon, prosecutors claim. He “never” told police that Hutchins gave instructions about where to point the gun. While he did say that the weapon simply “went off,” as he didn’t think there was a live round, “He never stated that he didn’t pull the trigger.”
Then there’s Baldwin’s December 3, 2021, interview with George Stephanopoulos, during which “everything changed,” according to the prosecution. They claimed that Baldwin “lied with impunity and blamed the incident on Ms. Hutchins,” saying that she told him to point the gun at her in the direction of her armpit. “This statement was in direct contradiction to his previous statement … where he clearly explained that Ms. Hutchins was struck in the armpit because she was turned to speak to someone else.” The interview also marked the first time Baldwin claimed he never pulled the trigger. In an interview with state workplace-safety regulators on December 8, 2021, “Baldwin’s story changed again” with him claiming that Halls — not Gutierrez-Reed — handed him the gun. The jury will have to pay close attention to the narratives.
How did jury selection go?
A total of 16 people were picked to serve as jurors in Baldwin’s case; the group is made up of 11 women and five men. Twelve of this group are jurors and four alternates. The public won’t know which people are jurors and which people are alternates until both sides finish presenting their case, according to the Associated Press’s pool report from the courtroom. “Jury selection is important in every case but critically important here,” Neama Rahmani, a former federal prosecutor whose firm, West Coast Trial Lawyers, routinely handles high-profile cases, explained before the trial started. “The parties will want to ask the prospective jurors questions about gun safety and rights as well as their views of celebrities.”
Indeed, that happened during the selection process. Lead defense attorney Alex Spiro, while questioning possible jurors, emphasized the grave nature of this case, noting “Obviously someone lost their life,” and asked those summoned to speak up if they had reservations about fairness and impartiality. He also asked whether anyone had strong views on gun safety. Some possible jurors responded by saying they always handle guns as if they’re loaded, according to the pool report.
Even if Baldwin were convicted, Rahmani doesn’t think he’ll wind up jailed. “I don’t think Baldwin will be remanded if he is convicted. The New Mexico manslaughter statute carries an 18-month maximum sentence, with no minimum,” Rahmani explained. Baldwin’s team, Rahmani noted, can point out that Halls got a no-jail deal if the time comes for them to argue about sentencing before the judge. “Baldwin’s lawyers have a good argument that he is no more culpable than assistant director Dave Halls, who reportedly told Baldwin it was a cold gun without checking it and who received a misdemeanor offer and probation.”
What did the opening statements focus on?
Both the prosecution and defense focused on the concept of real-life versus movie life on movie sets in their opening statements on July 10. Johnson alleged Baldwin didn’t take into account the real-life implications of handling a gun, saying that he “played make-believe with a real gun and violated the cardinal rules of firearm safety.” Spiro countered that Baldwin “committed no crime. He was an actor acting, playing the role of Harland Rust.”
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(3),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(136),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,"3":3,"12":12,"124":124,"136":136}];
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","aaa-module-mounting.legacy":"aaa-module-mounting.legacy","ads.legacy":"ads.legacy","facebook.legacy":"facebook.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();
// ]]