Photo-Illustration: Maya Robinson/Vulture and Photo by Marvel Studios
Photo-Illustration: Maya Robinson/Vulture and Photo by Marvel Studios
Some year, we will reach Peak Superhero. This year was not that year. The cape-and-cowl genre continues to be the dominant mode in American popular fiction, and although much of what it produces is disposable garbage, there are more than a few Lycra-clad diamonds in the rough. We here at Vulture believe there’s value in evaluating this type of storytelling as a whole entity, so for the second year in a row, we’ve assembled a list of the ten best superhero stories across various mediums. If you don’t read it, the supervillains win.
10. X-Men: Grand Design — Second Genesis (Comics) It’s remarkable how successful the X-Men saga has been over the past 40-odd years, given how utterly baffling it can be. The ins and outs of Marvel’s merry mutant mélange are hopelessly confusing unless you’re willing to read hundreds upon hundreds of individual comics, and even then, it’s easy to get lost. So how lucky we are to have Ed Piskor’s X-Men: Grand Design series. In the past year, the celebrated indie cartoonist has reimagined the X-mythos as a streamlined epic narrative — well, mostly streamlined. It’s still a dense pill to swallow, but the clear passion that Piskor has for the franchise propels the reader along his decades-spanning chronicle. In this second volume, he tackles Chris Claremont and John Byrne’s fabled Dark Phoenix saga in his own idiosyncratic way, and the results are as majestic as they are thrilling. Here’s hoping Marvel has the balls to take more risks like this in the future.
9. Titans,Season One(TV Show) When DC Entertainment dropped the first trailer for Titans at this year’s San Diego Comic-Con, there was one particular moment that was roundly mocked. Dick Grayson (Brenton Thwaites), the erstwhile sidekick of Batman, beats the shit out of a bunch of criminals and declares, “Fuck Batman.” The unprecedented cussing, combined with the dim lighting and vicious bloodletting, made the whole enterprise seem like it’d be yet another grim-and-gritty DC slog in the vein of Batman v Superman: Dawn of Justice. As it turns out, it is grim and gritty, but it’s anything but a slog, and that “Fuck Batman” line works astoundingly well in context. This streaming-only flagship series for the online DC Universe platform is exceedingly fun in its darkness, striding across the iPhone screen with a brash, youthful swagger and a commitment to cutting through the usual televised superhero bullshit. Plus, it’s the rare piece of filmed superhero fiction where the characters get to actually have sex, and folks, I’m somewhat ashamed to say how hot that ends up being. Fuck Batman, indeed.
8. Eternity Girl(Comics) It’s becoming increasingly trendy to talk about depression in superhero comics. This is a welcome development, as is any other attempt to destigmatize mental illness, but the stories sometimes feel more like PSAs than, well, stories. Not so with Magdalene Visaggio and Sonny Liew’s Eternity Girl. This eminently trippy journey into misery chronicles what is essentially one big, cosmic suicide attempt on the part of an elemental superhero who’s been taken off the job and has spiraled into instability. The book occasionally borders on being incomprehensible, but hey, ailments of the mind have a habit of making life hard to understand, so it feels entirely appropriate. What’s more, Eternity Girl also functions as a commentary on the torture we put our fictional superhero characters through in the name of entertainment, booting and rebooting them over and over in an attempt to wring out their remaining droplets of pulpy blood. Sure, you can argue that they don’t exist and thus that we shouldn’t feel sorry for them, but what does it say about us that we can’t let them go when they’ve served their purpose? No wonder comics are so expensive these days: We’re paying for therapy bills.
7. Mister Miracle No. 12 (Comic) It’s one of the all-time weird comics coincidences that Mister Miracle No. 12 came out the week Stan Lee died. Just days after the mighty Marvel maven passed from our midst, readers were given, in the form of the conclusion to one of the best superhero mini-series of the present century, one of the most incisive commentaries on the comics world that Lee helped build. Mister Miracle was a story about many things — trauma, children, war, blended families, suicide — but the final chapter revealed that it had secretly also been about the ways in which the comics industry both liberates and traps creators. (Appropriate enough for a saga about a super-escape-artist.) In this dreamlike coda, our protagonist, Scott Free, converses with a Lee pastiche named Funky Flashman and a former mentor named Oberon, who stands in for Lee’s estranged collaborator Jack Kirby. The former is charming, but useless; but the latter offers meaningful advice about how to survive the superhero hustle: to the best of your ability, build your own life on your own terms, free from the bonds of shared-universe continuity and corporate obligation. It’s surprising to see that kind of message coming from a superhero brand, but throughout its 12 chapters of existence, Mister Miracle was nothing if not full of surprises.
6. Legion, “Chapter 14” (TV Episode) Legion isn’t a perfect show, but when it’s good, it’s approximately 8,000 percent better than any other superhero enterprise currently on television, and it was at its all-time best in this stunningly sad stand-alone episode. In it, we’re offered a tapestry of alternate timelines of protagonist David Haller’s life, branching off to impossible wealth and humiliating destitution, medicated dullness and meth-head irritation, unspeakable joy and abject misery. All are portrayed with gripping precision by actor Dan Stevens and meditative engagement by director John Cameron. Readers of sci-fi and superhero comics have long gravitated to stories of parallel universes because they offer us the illusion that, somewhere in the snowflake of the cosmos, there’s a version of us that did everything right and was never hurt. Here, Legion hauntingly reminds us that, if such a version exists, it will never ever be found.
5. Marvel’s Spider-Man (Video Game) For as long as there have been video games, people have longed to play ones that allow them to step into the spandex of their favorite superpowered crusaders. They usually fail (Superman 64, I’m looking at you), but occasionally, a champion emerges to provide us with the virtual thrill of saving the day with powers and abilities far beyond those of the average mortal. Now, I’ve never actually done any costumed crime-fighting in my real life, but I have a feeling that, if I did, it would feel a whole lot like playing Marvel’s Spider-Man on the PS4. I’ll confess that I’m not really a gamer, much less a game reviewer, but I can tell you that swinging through an expansive, intricately designed Manhattan as the friendly neighborhood wall-crawler gave me delights I didn’t know I was capable of getting from a vibrating controller and a screen. The story hits you right in your Spidey sweet spot (although I have my issues with its decision to make the protagonist a deputized ally of the NYPD) while never quite aping any existing Spider-story. And honestly, the paranoid podcasts of J. Jonah Jameson that play while you soar are nearly worth the price of admission on their own.
4. The Immortal Hulk No. 1 (Comic) As the year of our lord two thousand eighteen dawned, it sure seemed like there wasn’t much gas left in the tank for the Incredible Hulk. Terrific creators in film and comics have been trying to make Marvel’s not-so-jolly green giant sparkle in recent years, but even the best efforts have felt like warmed-over versions of the same old Hulk stories we’ve experienced a thousand times before. Then, along came writer Al Ewing and artists Joe Bennett, Ruy José, and Paul Mounts. For the first issue of The Immortal Hulk, they turned to the panic of Stan Lee and Jack Kirby’s 1960s outings with the character, but wisely drew as much, if not more, from the EC Comics horror anthologies of the ’50s. This stand-alone morality play rattles the reader to their core, conjuring up agonizing moral quandaries and outright despair in a brief tale about a handful of people bound together by fate, folly, and the presence of a jade monster. It ends on a single, extremely challenging question, given what we’ve just read: “What do you think?” In a genre typically defined by easy answers, the fact that this comic elides them is cause for the highest esteem.
3. Peter Parker: The Spectacular Spider-Man No. 310 (Comic) Don’t tell him — it’ll go to his head and he’ll be insufferable on Twitter — but Chip Zdarsky is a national treasure. Over the past decade, the writer and artist has emerged as one of the premier creators in mainstream comics, and he’s never been better than he was with the self-contained final issue of his run on Peter Parker: The Spectacular Spider-Man. Zdarsky had been expertly writing the series for a good long while, but in this stunning conclusion, he also picked up his stylus to draw the web-slinger and the world in which he swings. And to be sure, this was a story about the world Spider-Man makes and that, in turn, makes him. I won’t spoil the bittersweet details, but suffice it to say that this short story about everyday civilians’ interactions with Spidey was one of the best possible distillations of what makes the character so valuable and durable. So, too, did it showcase what makes Zdarsky such a vital comics creator, with some all-time great Spider-Man quips interspersed with devastating and carefully observed emotional wallops. By the end, all it takes to turn a longtime Spider-obsessive into a weepy mess is a hug and a few words from an out-of-costume Peter Parker. This brief little issue is, in short, a tour de force.
2. Spider-Man: Into the Spider-Verse(Movie) It’s been a good year to be a Spider-fan. As evidenced elsewhere on this list, 2018 has been peppered with tales of wall-crawling and web-slinging that are among the best the Marvel brand has ever featured. But geeks had to wait until the final weeks of this annus mirabilis to get the crown jewel. Spider-Man: Into the Spider-Verse is animated and fun, but shouldn’t be written off as B-tier material. It is, as it turns out, the best Spider-Man movie to date. It works so well as a story because it not only captures the humor and pathos of the Spidey archetype, but also takes the risk of embracing one of the most complicated motifs in the superhero genre. We’re offered not one, not two, but seven versions of Spidey from various versions of Earth, including three Peter Parkers. One would expect that kind of comic-bookish storytelling to make for a convoluted head-scratcher, but the filmmakers somehow manage to make everything not only smooth, but deeply thrilling and emotionally engaging. Oh, and it’s hilarious. In a world where most superhero pictures are filled with half-chuckle gags and zingers that feel shoehorned in during the punch-up process, Into the Spider-Verse stands out for its razor-sharp, lightning-fast wit, which all too many Spider-Man movies have lacked. Every element clicks in this streamlined saga, leading to a master class in superhero cinema.
1. Black Panther(Movie) There’s so, so much to dig into when it comes to Ryan Coogler’s Black Panther, which is easily the best Marvel Cinematic Universe movie and one of the best pictures the superhero genre has ever had to offer. But one thing that I keep coming back to is the paradox of Wakanda. The fictional East African nation has been embraced by people of color as a vision of an unconquered black utopia (just look at the sheer number of times poor Chadwick Boseman has been implored to do the “Wakanda forever” salute in public), and justifiably so. And yet, what takes the movie from good to great is the fact that it is unsparing in its indictment of the country and its leadership. They stood idly by during their continent’s various apocalypses, most notably the Atlantic slave trade, and for that, they can never be forgiven. A less-bold film would have simply celebrated Wakanda as a land of sunshine and heroes, but Black Panther is nothing if not bold. Superhero fiction is, ultimately, about the responsibilities of power, and this lusciously envisioned and performed story doesn’t let any of its core cast off easy: No matter how well-intentioned they are, everyone has screwed people over in one way or another, particularly black people. The question of how black liberation can be achieved on a global scale is the central concern of the narrative, and Jesus, did you ever imagine a Disney movie would dare to get in the weeds on something like that? If other superhero movies had even a third of the political ambition Black Panther has, we Cineplex-goers would all be a lot less dumb.
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();
// ]]