compiler-ssr.cjs.js 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var compilerDom = require('@vue/compiler-dom');
  4. var shared = require('@vue/shared');
  5. const SSR_INTERPOLATE = Symbol(`ssrInterpolate`);
  6. const SSR_RENDER_VNODE = Symbol(`ssrRenderVNode`);
  7. const SSR_RENDER_COMPONENT = Symbol(`ssrRenderComponent`);
  8. const SSR_RENDER_SLOT = Symbol(`ssrRenderSlot`);
  9. const SSR_RENDER_SLOT_INNER = Symbol(`ssrRenderSlotInner`);
  10. const SSR_RENDER_CLASS = Symbol(`ssrRenderClass`);
  11. const SSR_RENDER_STYLE = Symbol(`ssrRenderStyle`);
  12. const SSR_RENDER_ATTRS = Symbol(`ssrRenderAttrs`);
  13. const SSR_RENDER_ATTR = Symbol(`ssrRenderAttr`);
  14. const SSR_RENDER_DYNAMIC_ATTR = Symbol(`ssrRenderDynamicAttr`);
  15. const SSR_RENDER_LIST = Symbol(`ssrRenderList`);
  16. const SSR_INCLUDE_BOOLEAN_ATTR = Symbol(`ssrIncludeBooleanAttr`);
  17. const SSR_LOOSE_EQUAL = Symbol(`ssrLooseEqual`);
  18. const SSR_LOOSE_CONTAIN = Symbol(`ssrLooseContain`);
  19. const SSR_RENDER_DYNAMIC_MODEL = Symbol(`ssrRenderDynamicModel`);
  20. const SSR_GET_DYNAMIC_MODEL_PROPS = Symbol(`ssrGetDynamicModelProps`);
  21. const SSR_RENDER_TELEPORT = Symbol(`ssrRenderTeleport`);
  22. const SSR_RENDER_SUSPENSE = Symbol(`ssrRenderSuspense`);
  23. const SSR_GET_DIRECTIVE_PROPS = Symbol(`ssrGetDirectiveProps`);
  24. const ssrHelpers = {
  25. [SSR_INTERPOLATE]: `ssrInterpolate`,
  26. [SSR_RENDER_VNODE]: `ssrRenderVNode`,
  27. [SSR_RENDER_COMPONENT]: `ssrRenderComponent`,
  28. [SSR_RENDER_SLOT]: `ssrRenderSlot`,
  29. [SSR_RENDER_SLOT_INNER]: `ssrRenderSlotInner`,
  30. [SSR_RENDER_CLASS]: `ssrRenderClass`,
  31. [SSR_RENDER_STYLE]: `ssrRenderStyle`,
  32. [SSR_RENDER_ATTRS]: `ssrRenderAttrs`,
  33. [SSR_RENDER_ATTR]: `ssrRenderAttr`,
  34. [SSR_RENDER_DYNAMIC_ATTR]: `ssrRenderDynamicAttr`,
  35. [SSR_RENDER_LIST]: `ssrRenderList`,
  36. [SSR_INCLUDE_BOOLEAN_ATTR]: `ssrIncludeBooleanAttr`,
  37. [SSR_LOOSE_EQUAL]: `ssrLooseEqual`,
  38. [SSR_LOOSE_CONTAIN]: `ssrLooseContain`,
  39. [SSR_RENDER_DYNAMIC_MODEL]: `ssrRenderDynamicModel`,
  40. [SSR_GET_DYNAMIC_MODEL_PROPS]: `ssrGetDynamicModelProps`,
  41. [SSR_RENDER_TELEPORT]: `ssrRenderTeleport`,
  42. [SSR_RENDER_SUSPENSE]: `ssrRenderSuspense`,
  43. [SSR_GET_DIRECTIVE_PROPS]: `ssrGetDirectiveProps`
  44. };
  45. compilerDom.registerRuntimeHelpers(ssrHelpers);
  46. const ssrTransformIf = compilerDom.createStructuralDirectiveTransform(
  47. /^(if|else|else-if)$/,
  48. compilerDom.processIf
  49. );
  50. function ssrProcessIf(node, context, disableNestedFragments = false) {
  51. const [rootBranch] = node.branches;
  52. const ifStatement = compilerDom.createIfStatement(
  53. rootBranch.condition,
  54. processIfBranch(rootBranch, context, disableNestedFragments)
  55. );
  56. context.pushStatement(ifStatement);
  57. let currentIf = ifStatement;
  58. for (let i = 1; i < node.branches.length; i++) {
  59. const branch = node.branches[i];
  60. const branchBlockStatement = processIfBranch(
  61. branch,
  62. context,
  63. disableNestedFragments
  64. );
  65. if (branch.condition) {
  66. currentIf = currentIf.alternate = compilerDom.createIfStatement(
  67. branch.condition,
  68. branchBlockStatement
  69. );
  70. } else {
  71. currentIf.alternate = branchBlockStatement;
  72. }
  73. }
  74. if (!currentIf.alternate) {
  75. currentIf.alternate = compilerDom.createBlockStatement([
  76. compilerDom.createCallExpression(`_push`, ["`<!---->`"])
  77. ]);
  78. }
  79. }
  80. function processIfBranch(branch, context, disableNestedFragments = false) {
  81. const { children } = branch;
  82. const needFragmentWrapper = !disableNestedFragments && (children.length !== 1 || children[0].type !== 1) && // optimize away nested fragments when the only child is a ForNode
  83. !(children.length === 1 && children[0].type === 11);
  84. return processChildrenAsStatement(branch, context, needFragmentWrapper);
  85. }
  86. const ssrTransformFor = compilerDom.createStructuralDirectiveTransform(
  87. "for",
  88. compilerDom.processFor
  89. );
  90. function ssrProcessFor(node, context, disableNestedFragments = false) {
  91. const needFragmentWrapper = !disableNestedFragments && (node.children.length !== 1 || node.children[0].type !== 1);
  92. const renderLoop = compilerDom.createFunctionExpression(
  93. compilerDom.createForLoopParams(node.parseResult)
  94. );
  95. renderLoop.body = processChildrenAsStatement(
  96. node,
  97. context,
  98. needFragmentWrapper
  99. );
  100. if (!disableNestedFragments) {
  101. context.pushStringPart(`<!--[-->`);
  102. }
  103. context.pushStatement(
  104. compilerDom.createCallExpression(context.helper(SSR_RENDER_LIST), [
  105. node.source,
  106. renderLoop
  107. ])
  108. );
  109. if (!disableNestedFragments) {
  110. context.pushStringPart(`<!--]-->`);
  111. }
  112. }
  113. const ssrTransformSlotOutlet = (node, context) => {
  114. if (compilerDom.isSlotOutlet(node)) {
  115. const { slotName, slotProps } = compilerDom.processSlotOutlet(node, context);
  116. const args = [
  117. `_ctx.$slots`,
  118. slotName,
  119. slotProps || `{}`,
  120. // fallback content placeholder. will be replaced in the process phase
  121. `null`,
  122. `_push`,
  123. `_parent`
  124. ];
  125. if (context.scopeId && context.slotted !== false) {
  126. args.push(`"${context.scopeId}-s"`);
  127. }
  128. let method = SSR_RENDER_SLOT;
  129. const parent = context.parent;
  130. if (parent && parent.type === 1 && parent.tagType === 1 && compilerDom.resolveComponentType(parent, context, true) === compilerDom.TRANSITION && parent.children.filter((c) => c.type === 1).length === 1) {
  131. method = SSR_RENDER_SLOT_INNER;
  132. if (!(context.scopeId && context.slotted !== false)) {
  133. args.push("null");
  134. }
  135. args.push("true");
  136. }
  137. node.ssrCodegenNode = compilerDom.createCallExpression(context.helper(method), args);
  138. }
  139. };
  140. function ssrProcessSlotOutlet(node, context) {
  141. const renderCall = node.ssrCodegenNode;
  142. if (node.children.length) {
  143. const fallbackRenderFn = compilerDom.createFunctionExpression([]);
  144. fallbackRenderFn.body = processChildrenAsStatement(node, context);
  145. renderCall.arguments[3] = fallbackRenderFn;
  146. }
  147. if (context.withSlotScopeId) {
  148. const slotScopeId = renderCall.arguments[6];
  149. renderCall.arguments[6] = slotScopeId ? `${slotScopeId} + _scopeId` : `_scopeId`;
  150. }
  151. context.pushStatement(node.ssrCodegenNode);
  152. }
  153. function createSSRCompilerError(code, loc) {
  154. return compilerDom.createCompilerError(code, loc, SSRErrorMessages);
  155. }
  156. const SSRErrorMessages = {
  157. [65]: `Unsafe attribute name for SSR.`,
  158. [66]: `Missing the 'to' prop on teleport element.`,
  159. [67]: `Invalid AST node during SSR transform.`
  160. };
  161. function ssrProcessTeleport(node, context) {
  162. const targetProp = compilerDom.findProp(node, "to");
  163. if (!targetProp) {
  164. context.onError(
  165. createSSRCompilerError(66, node.loc)
  166. );
  167. return;
  168. }
  169. let target;
  170. if (targetProp.type === 6) {
  171. target = targetProp.value && compilerDom.createSimpleExpression(targetProp.value.content, true);
  172. } else {
  173. target = targetProp.exp;
  174. }
  175. if (!target) {
  176. context.onError(
  177. createSSRCompilerError(
  178. 66,
  179. targetProp.loc
  180. )
  181. );
  182. return;
  183. }
  184. const disabledProp = compilerDom.findProp(
  185. node,
  186. "disabled",
  187. false,
  188. true
  189. /* allow empty */
  190. );
  191. const disabled = disabledProp ? disabledProp.type === 6 ? `true` : disabledProp.exp || `false` : `false`;
  192. const contentRenderFn = compilerDom.createFunctionExpression(
  193. [`_push`],
  194. void 0,
  195. // Body is added later
  196. true,
  197. // newline
  198. false,
  199. // isSlot
  200. node.loc
  201. );
  202. contentRenderFn.body = processChildrenAsStatement(node, context);
  203. context.pushStatement(
  204. compilerDom.createCallExpression(context.helper(SSR_RENDER_TELEPORT), [
  205. `_push`,
  206. contentRenderFn,
  207. target,
  208. disabled,
  209. `_parent`
  210. ])
  211. );
  212. }
  213. const wipMap$2 = /* @__PURE__ */ new WeakMap();
  214. function ssrTransformSuspense(node, context) {
  215. return () => {
  216. if (node.children.length) {
  217. const wipEntry = {
  218. slotsExp: null,
  219. // to be immediately set
  220. wipSlots: []
  221. };
  222. wipMap$2.set(node, wipEntry);
  223. wipEntry.slotsExp = compilerDom.buildSlots(node, context, (_props, children, loc) => {
  224. const fn = compilerDom.createFunctionExpression(
  225. [],
  226. void 0,
  227. // no return, assign body later
  228. true,
  229. // newline
  230. false,
  231. // suspense slots are not treated as normal slots
  232. loc
  233. );
  234. wipEntry.wipSlots.push({
  235. fn,
  236. children
  237. });
  238. return fn;
  239. }).slots;
  240. }
  241. };
  242. }
  243. function ssrProcessSuspense(node, context) {
  244. const wipEntry = wipMap$2.get(node);
  245. if (!wipEntry) {
  246. return;
  247. }
  248. const { slotsExp, wipSlots } = wipEntry;
  249. for (let i = 0; i < wipSlots.length; i++) {
  250. const slot = wipSlots[i];
  251. slot.fn.body = processChildrenAsStatement(slot, context);
  252. }
  253. context.pushStatement(
  254. compilerDom.createCallExpression(context.helper(SSR_RENDER_SUSPENSE), [
  255. `_push`,
  256. slotsExp
  257. ])
  258. );
  259. }
  260. const rawChildrenMap = /* @__PURE__ */ new WeakMap();
  261. const ssrTransformElement = (node, context) => {
  262. if (node.type !== 1 || node.tagType !== 0) {
  263. return;
  264. }
  265. return function ssrPostTransformElement() {
  266. const openTag = [`<${node.tag}`];
  267. const needTagForRuntime = node.tag === "textarea" || node.tag.indexOf("-") > 0;
  268. const hasDynamicVBind = compilerDom.hasDynamicKeyVBind(node);
  269. const hasCustomDir = node.props.some(
  270. (p) => p.type === 7 && !shared.isBuiltInDirective(p.name)
  271. );
  272. const needMergeProps = hasDynamicVBind || hasCustomDir;
  273. if (needMergeProps) {
  274. const { props, directives } = compilerDom.buildProps(
  275. node,
  276. context,
  277. node.props,
  278. false,
  279. false,
  280. true
  281. /* ssr */
  282. );
  283. if (props || directives.length) {
  284. const mergedProps = buildSSRProps(props, directives, context);
  285. const propsExp = compilerDom.createCallExpression(
  286. context.helper(SSR_RENDER_ATTRS),
  287. [mergedProps]
  288. );
  289. if (node.tag === "textarea") {
  290. const existingText = node.children[0];
  291. if (!existingText || existingText.type !== 5) {
  292. const tempId = `_temp${context.temps++}`;
  293. propsExp.arguments = [
  294. compilerDom.createAssignmentExpression(
  295. compilerDom.createSimpleExpression(tempId, false),
  296. mergedProps
  297. )
  298. ];
  299. rawChildrenMap.set(
  300. node,
  301. compilerDom.createCallExpression(context.helper(SSR_INTERPOLATE), [
  302. compilerDom.createConditionalExpression(
  303. compilerDom.createSimpleExpression(`"value" in ${tempId}`, false),
  304. compilerDom.createSimpleExpression(`${tempId}.value`, false),
  305. compilerDom.createSimpleExpression(
  306. existingText ? existingText.content : ``,
  307. true
  308. ),
  309. false
  310. )
  311. ])
  312. );
  313. }
  314. } else if (node.tag === "input") {
  315. const vModel = findVModel(node);
  316. if (vModel) {
  317. const tempId = `_temp${context.temps++}`;
  318. const tempExp = compilerDom.createSimpleExpression(tempId, false);
  319. propsExp.arguments = [
  320. compilerDom.createSequenceExpression([
  321. compilerDom.createAssignmentExpression(tempExp, mergedProps),
  322. compilerDom.createCallExpression(context.helper(compilerDom.MERGE_PROPS), [
  323. tempExp,
  324. compilerDom.createCallExpression(
  325. context.helper(SSR_GET_DYNAMIC_MODEL_PROPS),
  326. [
  327. tempExp,
  328. // existing props
  329. vModel.exp
  330. // model
  331. ]
  332. )
  333. ])
  334. ])
  335. ];
  336. }
  337. }
  338. if (needTagForRuntime) {
  339. propsExp.arguments.push(`"${node.tag}"`);
  340. }
  341. openTag.push(propsExp);
  342. }
  343. }
  344. let dynamicClassBinding = void 0;
  345. let staticClassBinding = void 0;
  346. let dynamicStyleBinding = void 0;
  347. for (let i = 0; i < node.props.length; i++) {
  348. const prop = node.props[i];
  349. if (node.tag === "input" && isTrueFalseValue(prop)) {
  350. continue;
  351. }
  352. if (prop.type === 7) {
  353. if (prop.name === "html" && prop.exp) {
  354. rawChildrenMap.set(node, prop.exp);
  355. } else if (prop.name === "text" && prop.exp) {
  356. node.children = [compilerDom.createInterpolation(prop.exp, prop.loc)];
  357. } else if (prop.name === "slot") {
  358. context.onError(
  359. compilerDom.createCompilerError(40, prop.loc)
  360. );
  361. } else if (isTextareaWithValue(node, prop) && prop.exp) {
  362. if (!needMergeProps) {
  363. node.children = [compilerDom.createInterpolation(prop.exp, prop.loc)];
  364. }
  365. } else if (!needMergeProps && prop.name !== "on") {
  366. const directiveTransform = context.directiveTransforms[prop.name];
  367. if (directiveTransform) {
  368. const { props, ssrTagParts } = directiveTransform(
  369. prop,
  370. node,
  371. context
  372. );
  373. if (ssrTagParts) {
  374. openTag.push(...ssrTagParts);
  375. }
  376. for (let j = 0; j < props.length; j++) {
  377. const { key, value } = props[j];
  378. if (compilerDom.isStaticExp(key)) {
  379. let attrName = key.content;
  380. if (attrName === "key" || attrName === "ref") {
  381. continue;
  382. }
  383. if (attrName === "class") {
  384. openTag.push(
  385. ` class="`,
  386. dynamicClassBinding = compilerDom.createCallExpression(
  387. context.helper(SSR_RENDER_CLASS),
  388. [value]
  389. ),
  390. `"`
  391. );
  392. } else if (attrName === "style") {
  393. if (dynamicStyleBinding) {
  394. mergeCall(dynamicStyleBinding, value);
  395. } else {
  396. openTag.push(
  397. ` style="`,
  398. dynamicStyleBinding = compilerDom.createCallExpression(
  399. context.helper(SSR_RENDER_STYLE),
  400. [value]
  401. ),
  402. `"`
  403. );
  404. }
  405. } else {
  406. attrName = node.tag.indexOf("-") > 0 ? attrName : shared.propsToAttrMap[attrName] || attrName.toLowerCase();
  407. if (shared.isBooleanAttr(attrName)) {
  408. openTag.push(
  409. compilerDom.createConditionalExpression(
  410. compilerDom.createCallExpression(
  411. context.helper(SSR_INCLUDE_BOOLEAN_ATTR),
  412. [value]
  413. ),
  414. compilerDom.createSimpleExpression(" " + attrName, true),
  415. compilerDom.createSimpleExpression("", true),
  416. false
  417. /* no newline */
  418. )
  419. );
  420. } else if (shared.isSSRSafeAttrName(attrName)) {
  421. openTag.push(
  422. compilerDom.createCallExpression(context.helper(SSR_RENDER_ATTR), [
  423. key,
  424. value
  425. ])
  426. );
  427. } else {
  428. context.onError(
  429. createSSRCompilerError(
  430. 65,
  431. key.loc
  432. )
  433. );
  434. }
  435. }
  436. } else {
  437. const args = [key, value];
  438. if (needTagForRuntime) {
  439. args.push(`"${node.tag}"`);
  440. }
  441. openTag.push(
  442. compilerDom.createCallExpression(
  443. context.helper(SSR_RENDER_DYNAMIC_ATTR),
  444. args
  445. )
  446. );
  447. }
  448. }
  449. }
  450. }
  451. } else {
  452. if (node.tag === "textarea" && prop.name === "value" && prop.value) {
  453. rawChildrenMap.set(node, shared.escapeHtml(prop.value.content));
  454. } else if (!needMergeProps) {
  455. if (prop.name === "key" || prop.name === "ref") {
  456. continue;
  457. }
  458. if (prop.name === "class" && prop.value) {
  459. staticClassBinding = JSON.stringify(prop.value.content);
  460. }
  461. openTag.push(
  462. ` ${prop.name}` + (prop.value ? `="${shared.escapeHtml(prop.value.content)}"` : ``)
  463. );
  464. }
  465. }
  466. }
  467. if (dynamicClassBinding && staticClassBinding) {
  468. mergeCall(dynamicClassBinding, staticClassBinding);
  469. removeStaticBinding(openTag, "class");
  470. }
  471. if (context.scopeId) {
  472. openTag.push(` ${context.scopeId}`);
  473. }
  474. node.ssrCodegenNode = compilerDom.createTemplateLiteral(openTag);
  475. };
  476. };
  477. function buildSSRProps(props, directives, context) {
  478. let mergePropsArgs = [];
  479. if (props) {
  480. if (props.type === 14) {
  481. mergePropsArgs = props.arguments;
  482. } else {
  483. mergePropsArgs.push(props);
  484. }
  485. }
  486. if (directives.length) {
  487. for (const dir of directives) {
  488. mergePropsArgs.push(
  489. compilerDom.createCallExpression(context.helper(SSR_GET_DIRECTIVE_PROPS), [
  490. `_ctx`,
  491. ...compilerDom.buildDirectiveArgs(dir, context).elements
  492. ])
  493. );
  494. }
  495. }
  496. return mergePropsArgs.length > 1 ? compilerDom.createCallExpression(context.helper(compilerDom.MERGE_PROPS), mergePropsArgs) : mergePropsArgs[0];
  497. }
  498. function isTrueFalseValue(prop) {
  499. if (prop.type === 7) {
  500. return prop.name === "bind" && prop.arg && compilerDom.isStaticExp(prop.arg) && (prop.arg.content === "true-value" || prop.arg.content === "false-value");
  501. } else {
  502. return prop.name === "true-value" || prop.name === "false-value";
  503. }
  504. }
  505. function isTextareaWithValue(node, prop) {
  506. return !!(node.tag === "textarea" && prop.name === "bind" && compilerDom.isStaticArgOf(prop.arg, "value"));
  507. }
  508. function mergeCall(call, arg) {
  509. const existing = call.arguments[0];
  510. if (existing.type === 17) {
  511. existing.elements.push(arg);
  512. } else {
  513. call.arguments[0] = compilerDom.createArrayExpression([existing, arg]);
  514. }
  515. }
  516. function removeStaticBinding(tag, binding) {
  517. const regExp = new RegExp(`^ ${binding}=".+"$`);
  518. const i = tag.findIndex((e) => typeof e === "string" && regExp.test(e));
  519. if (i > -1) {
  520. tag.splice(i, 1);
  521. }
  522. }
  523. function findVModel(node) {
  524. return node.props.find(
  525. (p) => p.type === 7 && p.name === "model" && p.exp
  526. );
  527. }
  528. function ssrProcessElement(node, context) {
  529. const isVoidTag = context.options.isVoidTag || shared.NO;
  530. const elementsToAdd = node.ssrCodegenNode.elements;
  531. for (let j = 0; j < elementsToAdd.length; j++) {
  532. context.pushStringPart(elementsToAdd[j]);
  533. }
  534. if (context.withSlotScopeId) {
  535. context.pushStringPart(compilerDom.createSimpleExpression(`_scopeId`, false));
  536. }
  537. context.pushStringPart(`>`);
  538. const rawChildren = rawChildrenMap.get(node);
  539. if (rawChildren) {
  540. context.pushStringPart(rawChildren);
  541. } else if (node.children.length) {
  542. processChildren(node, context);
  543. }
  544. if (!isVoidTag(node.tag)) {
  545. context.pushStringPart(`</${node.tag}>`);
  546. }
  547. }
  548. const wipMap$1 = /* @__PURE__ */ new WeakMap();
  549. function ssrTransformTransitionGroup(node, context) {
  550. return () => {
  551. const tag = compilerDom.findProp(node, "tag");
  552. if (tag) {
  553. const otherProps = node.props.filter((p) => p !== tag);
  554. const { props, directives } = compilerDom.buildProps(
  555. node,
  556. context,
  557. otherProps,
  558. true,
  559. false,
  560. true
  561. /* ssr (skip event listeners) */
  562. );
  563. let propsExp = null;
  564. if (props || directives.length) {
  565. propsExp = compilerDom.createCallExpression(context.helper(SSR_RENDER_ATTRS), [
  566. buildSSRProps(props, directives, context)
  567. ]);
  568. }
  569. wipMap$1.set(node, {
  570. tag,
  571. propsExp
  572. });
  573. }
  574. };
  575. }
  576. function ssrProcessTransitionGroup(node, context) {
  577. const entry = wipMap$1.get(node);
  578. if (entry) {
  579. const { tag, propsExp } = entry;
  580. if (tag.type === 7) {
  581. context.pushStringPart(`<`);
  582. context.pushStringPart(tag.exp);
  583. if (propsExp) {
  584. context.pushStringPart(propsExp);
  585. }
  586. context.pushStringPart(`>`);
  587. processChildren(
  588. node,
  589. context,
  590. false,
  591. /**
  592. * TransitionGroup has the special runtime behavior of flattening and
  593. * concatenating all children into a single fragment (in order for them to
  594. * be patched using the same key map) so we need to account for that here
  595. * by disabling nested fragment wrappers from being generated.
  596. */
  597. true
  598. );
  599. context.pushStringPart(`</`);
  600. context.pushStringPart(tag.exp);
  601. context.pushStringPart(`>`);
  602. } else {
  603. context.pushStringPart(`<${tag.value.content}`);
  604. if (propsExp) {
  605. context.pushStringPart(propsExp);
  606. }
  607. context.pushStringPart(`>`);
  608. processChildren(node, context, false, true);
  609. context.pushStringPart(`</${tag.value.content}>`);
  610. }
  611. } else {
  612. processChildren(node, context, true, true);
  613. }
  614. }
  615. const wipMap = /* @__PURE__ */ new WeakMap();
  616. const WIP_SLOT = Symbol();
  617. const componentTypeMap = /* @__PURE__ */ new WeakMap();
  618. const ssrTransformComponent = (node, context) => {
  619. if (node.type !== 1 || node.tagType !== 1) {
  620. return;
  621. }
  622. const component = compilerDom.resolveComponentType(
  623. node,
  624. context,
  625. true
  626. /* ssr */
  627. );
  628. const isDynamicComponent = shared.isObject(component) && component.callee === compilerDom.RESOLVE_DYNAMIC_COMPONENT;
  629. componentTypeMap.set(node, component);
  630. if (shared.isSymbol(component)) {
  631. if (component === compilerDom.SUSPENSE) {
  632. return ssrTransformSuspense(node, context);
  633. }
  634. if (component === compilerDom.TRANSITION_GROUP) {
  635. return ssrTransformTransitionGroup(node, context);
  636. }
  637. return;
  638. }
  639. const vnodeBranches = [];
  640. const clonedNode = clone(node);
  641. return function ssrPostTransformComponent() {
  642. if (clonedNode.children.length) {
  643. compilerDom.buildSlots(clonedNode, context, (props, children) => {
  644. vnodeBranches.push(createVNodeSlotBranch(props, children, context));
  645. return compilerDom.createFunctionExpression(void 0);
  646. });
  647. }
  648. let propsExp = `null`;
  649. if (node.props.length) {
  650. const { props, directives } = compilerDom.buildProps(
  651. node,
  652. context,
  653. void 0,
  654. true,
  655. isDynamicComponent
  656. );
  657. if (props || directives.length) {
  658. propsExp = buildSSRProps(props, directives, context);
  659. }
  660. }
  661. const wipEntries = [];
  662. wipMap.set(node, wipEntries);
  663. const buildSSRSlotFn = (props, children, loc) => {
  664. const param0 = props && compilerDom.stringifyExpression(props) || `_`;
  665. const fn = compilerDom.createFunctionExpression(
  666. [param0, `_push`, `_parent`, `_scopeId`],
  667. void 0,
  668. // no return, assign body later
  669. true,
  670. // newline
  671. true,
  672. // isSlot
  673. loc
  674. );
  675. wipEntries.push({
  676. type: WIP_SLOT,
  677. fn,
  678. children,
  679. // also collect the corresponding vnode branch built earlier
  680. vnodeBranch: vnodeBranches[wipEntries.length]
  681. });
  682. return fn;
  683. };
  684. const slots = node.children.length ? compilerDom.buildSlots(node, context, buildSSRSlotFn).slots : `null`;
  685. if (typeof component !== "string") {
  686. node.ssrCodegenNode = compilerDom.createCallExpression(
  687. context.helper(SSR_RENDER_VNODE),
  688. [
  689. `_push`,
  690. compilerDom.createCallExpression(context.helper(compilerDom.CREATE_VNODE), [
  691. component,
  692. propsExp,
  693. slots
  694. ]),
  695. `_parent`
  696. ]
  697. );
  698. } else {
  699. node.ssrCodegenNode = compilerDom.createCallExpression(
  700. context.helper(SSR_RENDER_COMPONENT),
  701. [component, propsExp, slots, `_parent`]
  702. );
  703. }
  704. };
  705. };
  706. function ssrProcessComponent(node, context, parent) {
  707. const component = componentTypeMap.get(node);
  708. if (!node.ssrCodegenNode) {
  709. if (component === compilerDom.TELEPORT) {
  710. return ssrProcessTeleport(node, context);
  711. } else if (component === compilerDom.SUSPENSE) {
  712. return ssrProcessSuspense(node, context);
  713. } else if (component === compilerDom.TRANSITION_GROUP) {
  714. return ssrProcessTransitionGroup(node, context);
  715. } else {
  716. if (parent.type === WIP_SLOT) {
  717. context.pushStringPart(``);
  718. }
  719. if (component === compilerDom.TRANSITION) {
  720. node.children = node.children.filter((c) => c.type !== 3);
  721. }
  722. processChildren(node, context);
  723. }
  724. } else {
  725. const wipEntries = wipMap.get(node) || [];
  726. for (let i = 0; i < wipEntries.length; i++) {
  727. const { fn, vnodeBranch } = wipEntries[i];
  728. fn.body = compilerDom.createIfStatement(
  729. compilerDom.createSimpleExpression(`_push`, false),
  730. processChildrenAsStatement(
  731. wipEntries[i],
  732. context,
  733. false,
  734. true
  735. /* withSlotScopeId */
  736. ),
  737. vnodeBranch
  738. );
  739. }
  740. if (context.withSlotScopeId) {
  741. node.ssrCodegenNode.arguments.push(`_scopeId`);
  742. }
  743. if (typeof component === "string") {
  744. context.pushStatement(
  745. compilerDom.createCallExpression(`_push`, [node.ssrCodegenNode])
  746. );
  747. } else {
  748. context.pushStatement(node.ssrCodegenNode);
  749. }
  750. }
  751. }
  752. const rawOptionsMap = /* @__PURE__ */ new WeakMap();
  753. const [baseNodeTransforms, baseDirectiveTransforms] = compilerDom.getBaseTransformPreset(true);
  754. const vnodeNodeTransforms = [...baseNodeTransforms, ...compilerDom.DOMNodeTransforms];
  755. const vnodeDirectiveTransforms = {
  756. ...baseDirectiveTransforms,
  757. ...compilerDom.DOMDirectiveTransforms
  758. };
  759. function createVNodeSlotBranch(props, children, parentContext) {
  760. const rawOptions = rawOptionsMap.get(parentContext.root);
  761. const subOptions = {
  762. ...rawOptions,
  763. // overwrite with vnode-based transforms
  764. nodeTransforms: [
  765. ...vnodeNodeTransforms,
  766. ...rawOptions.nodeTransforms || []
  767. ],
  768. directiveTransforms: {
  769. ...vnodeDirectiveTransforms,
  770. ...rawOptions.directiveTransforms || {}
  771. }
  772. };
  773. const wrapperNode = {
  774. type: 1,
  775. ns: 0,
  776. tag: "template",
  777. tagType: 3,
  778. isSelfClosing: false,
  779. // important: provide v-slot="props" on the wrapper for proper
  780. // scope analysis
  781. props: [
  782. {
  783. type: 7,
  784. name: "slot",
  785. exp: props,
  786. arg: void 0,
  787. modifiers: [],
  788. loc: compilerDom.locStub
  789. }
  790. ],
  791. children,
  792. loc: compilerDom.locStub,
  793. codegenNode: void 0
  794. };
  795. subTransform(wrapperNode, subOptions, parentContext);
  796. return compilerDom.createReturnStatement(children);
  797. }
  798. function subTransform(node, options, parentContext) {
  799. const childRoot = compilerDom.createRoot([node]);
  800. const childContext = compilerDom.createTransformContext(childRoot, options);
  801. childContext.ssr = false;
  802. childContext.scopes = { ...parentContext.scopes };
  803. childContext.identifiers = { ...parentContext.identifiers };
  804. childContext.imports = parentContext.imports;
  805. compilerDom.traverseNode(childRoot, childContext);
  806. ["helpers", "components", "directives"].forEach((key) => {
  807. childContext[key].forEach((value, helperKey) => {
  808. if (key === "helpers") {
  809. const parentCount = parentContext.helpers.get(helperKey);
  810. if (parentCount === void 0) {
  811. parentContext.helpers.set(helperKey, value);
  812. } else {
  813. parentContext.helpers.set(helperKey, value + parentCount);
  814. }
  815. } else {
  816. parentContext[key].add(value);
  817. }
  818. });
  819. });
  820. }
  821. function clone(v) {
  822. if (shared.isArray(v)) {
  823. return v.map(clone);
  824. } else if (shared.isObject(v)) {
  825. const res = {};
  826. for (const key in v) {
  827. res[key] = clone(v[key]);
  828. }
  829. return res;
  830. } else {
  831. return v;
  832. }
  833. }
  834. function ssrCodegenTransform(ast, options) {
  835. const context = createSSRTransformContext(ast, options);
  836. if (options.ssrCssVars) {
  837. const cssContext = compilerDom.createTransformContext(compilerDom.createRoot([]), options);
  838. const varsExp = compilerDom.processExpression(
  839. compilerDom.createSimpleExpression(options.ssrCssVars, false),
  840. cssContext
  841. );
  842. context.body.push(
  843. compilerDom.createCompoundExpression([`const _cssVars = { style: `, varsExp, `}`])
  844. );
  845. Array.from(cssContext.helpers.keys()).forEach((helper) => {
  846. ast.helpers.add(helper);
  847. });
  848. }
  849. const isFragment = ast.children.length > 1 && ast.children.some((c) => !compilerDom.isText(c));
  850. processChildren(ast, context, isFragment);
  851. ast.codegenNode = compilerDom.createBlockStatement(context.body);
  852. ast.ssrHelpers = Array.from(
  853. /* @__PURE__ */ new Set([
  854. ...Array.from(ast.helpers).filter((h) => h in ssrHelpers),
  855. ...context.helpers
  856. ])
  857. );
  858. ast.helpers = new Set(Array.from(ast.helpers).filter((h) => !(h in ssrHelpers)));
  859. }
  860. function createSSRTransformContext(root, options, helpers = /* @__PURE__ */ new Set(), withSlotScopeId = false) {
  861. const body = [];
  862. let currentString = null;
  863. return {
  864. root,
  865. options,
  866. body,
  867. helpers,
  868. withSlotScopeId,
  869. onError: options.onError || ((e) => {
  870. throw e;
  871. }),
  872. helper(name) {
  873. helpers.add(name);
  874. return name;
  875. },
  876. pushStringPart(part) {
  877. if (!currentString) {
  878. const currentCall = compilerDom.createCallExpression(`_push`);
  879. body.push(currentCall);
  880. currentString = compilerDom.createTemplateLiteral([]);
  881. currentCall.arguments.push(currentString);
  882. }
  883. const bufferedElements = currentString.elements;
  884. const lastItem = bufferedElements[bufferedElements.length - 1];
  885. if (shared.isString(part) && shared.isString(lastItem)) {
  886. bufferedElements[bufferedElements.length - 1] += part;
  887. } else {
  888. bufferedElements.push(part);
  889. }
  890. },
  891. pushStatement(statement) {
  892. currentString = null;
  893. body.push(statement);
  894. }
  895. };
  896. }
  897. function createChildContext(parent, withSlotScopeId = parent.withSlotScopeId) {
  898. return createSSRTransformContext(
  899. parent.root,
  900. parent.options,
  901. parent.helpers,
  902. withSlotScopeId
  903. );
  904. }
  905. function processChildren(parent, context, asFragment = false, disableNestedFragments = false) {
  906. if (asFragment) {
  907. context.pushStringPart(`<!--[-->`);
  908. }
  909. const { children } = parent;
  910. for (let i = 0; i < children.length; i++) {
  911. const child = children[i];
  912. switch (child.type) {
  913. case 1:
  914. switch (child.tagType) {
  915. case 0:
  916. ssrProcessElement(child, context);
  917. break;
  918. case 1:
  919. ssrProcessComponent(child, context, parent);
  920. break;
  921. case 2:
  922. ssrProcessSlotOutlet(child, context);
  923. break;
  924. case 3:
  925. break;
  926. default:
  927. context.onError(
  928. createSSRCompilerError(
  929. 67,
  930. child.loc
  931. )
  932. );
  933. const exhaustiveCheck2 = child;
  934. return exhaustiveCheck2;
  935. }
  936. break;
  937. case 2:
  938. context.pushStringPart(shared.escapeHtml(child.content));
  939. break;
  940. case 3:
  941. context.pushStringPart(`<!--${child.content}-->`);
  942. break;
  943. case 5:
  944. context.pushStringPart(
  945. compilerDom.createCallExpression(context.helper(SSR_INTERPOLATE), [child.content])
  946. );
  947. break;
  948. case 9:
  949. ssrProcessIf(child, context, disableNestedFragments);
  950. break;
  951. case 11:
  952. ssrProcessFor(child, context, disableNestedFragments);
  953. break;
  954. case 10:
  955. break;
  956. case 12:
  957. case 8:
  958. break;
  959. default:
  960. context.onError(
  961. createSSRCompilerError(
  962. 67,
  963. child.loc
  964. )
  965. );
  966. const exhaustiveCheck = child;
  967. return exhaustiveCheck;
  968. }
  969. }
  970. if (asFragment) {
  971. context.pushStringPart(`<!--]-->`);
  972. }
  973. }
  974. function processChildrenAsStatement(parent, parentContext, asFragment = false, withSlotScopeId = parentContext.withSlotScopeId) {
  975. const childContext = createChildContext(parentContext, withSlotScopeId);
  976. processChildren(parent, childContext, asFragment);
  977. return compilerDom.createBlockStatement(childContext.body);
  978. }
  979. const ssrTransformModel = (dir, node, context) => {
  980. const model = dir.exp;
  981. function checkDuplicatedValue() {
  982. const value = compilerDom.findProp(node, "value");
  983. if (value) {
  984. context.onError(
  985. compilerDom.createDOMCompilerError(
  986. 60,
  987. value.loc
  988. )
  989. );
  990. }
  991. }
  992. if (node.tagType === 0) {
  993. const res = { props: [] };
  994. const defaultProps = [
  995. // default value binding for text type inputs
  996. compilerDom.createObjectProperty(`value`, model)
  997. ];
  998. if (node.tag === "input") {
  999. const type = compilerDom.findProp(node, "type");
  1000. if (type) {
  1001. const value = findValueBinding(node);
  1002. if (type.type === 7) {
  1003. res.ssrTagParts = [
  1004. compilerDom.createCallExpression(context.helper(SSR_RENDER_DYNAMIC_MODEL), [
  1005. type.exp,
  1006. model,
  1007. value
  1008. ])
  1009. ];
  1010. } else if (type.value) {
  1011. switch (type.value.content) {
  1012. case "radio":
  1013. res.props = [
  1014. compilerDom.createObjectProperty(
  1015. `checked`,
  1016. compilerDom.createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
  1017. model,
  1018. value
  1019. ])
  1020. )
  1021. ];
  1022. break;
  1023. case "checkbox":
  1024. const trueValueBinding = compilerDom.findProp(node, "true-value");
  1025. if (trueValueBinding) {
  1026. const trueValue = trueValueBinding.type === 6 ? JSON.stringify(trueValueBinding.value.content) : trueValueBinding.exp;
  1027. res.props = [
  1028. compilerDom.createObjectProperty(
  1029. `checked`,
  1030. compilerDom.createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
  1031. model,
  1032. trueValue
  1033. ])
  1034. )
  1035. ];
  1036. } else {
  1037. res.props = [
  1038. compilerDom.createObjectProperty(
  1039. `checked`,
  1040. compilerDom.createConditionalExpression(
  1041. compilerDom.createCallExpression(`Array.isArray`, [model]),
  1042. compilerDom.createCallExpression(context.helper(SSR_LOOSE_CONTAIN), [
  1043. model,
  1044. value
  1045. ]),
  1046. model
  1047. )
  1048. )
  1049. ];
  1050. }
  1051. break;
  1052. case "file":
  1053. context.onError(
  1054. compilerDom.createDOMCompilerError(
  1055. 59,
  1056. dir.loc
  1057. )
  1058. );
  1059. break;
  1060. default:
  1061. checkDuplicatedValue();
  1062. res.props = defaultProps;
  1063. break;
  1064. }
  1065. }
  1066. } else if (compilerDom.hasDynamicKeyVBind(node)) ; else {
  1067. checkDuplicatedValue();
  1068. res.props = defaultProps;
  1069. }
  1070. } else if (node.tag === "textarea") {
  1071. checkDuplicatedValue();
  1072. node.children = [compilerDom.createInterpolation(model, model.loc)];
  1073. } else if (node.tag === "select") ; else {
  1074. context.onError(
  1075. compilerDom.createDOMCompilerError(
  1076. 57,
  1077. dir.loc
  1078. )
  1079. );
  1080. }
  1081. return res;
  1082. } else {
  1083. return compilerDom.transformModel(dir, node, context);
  1084. }
  1085. };
  1086. function findValueBinding(node) {
  1087. const valueBinding = compilerDom.findProp(node, "value");
  1088. return valueBinding ? valueBinding.type === 7 ? valueBinding.exp : compilerDom.createSimpleExpression(valueBinding.value.content, true) : compilerDom.createSimpleExpression(`null`, false);
  1089. }
  1090. const ssrTransformShow = (dir, node, context) => {
  1091. if (!dir.exp) {
  1092. context.onError(
  1093. compilerDom.createDOMCompilerError(61)
  1094. );
  1095. }
  1096. return {
  1097. props: [
  1098. compilerDom.createObjectProperty(
  1099. `style`,
  1100. compilerDom.createConditionalExpression(
  1101. dir.exp,
  1102. compilerDom.createSimpleExpression(`null`, false),
  1103. compilerDom.createObjectExpression([
  1104. compilerDom.createObjectProperty(
  1105. `display`,
  1106. compilerDom.createSimpleExpression(`none`, true)
  1107. )
  1108. ]),
  1109. false
  1110. /* no newline */
  1111. )
  1112. )
  1113. ]
  1114. };
  1115. };
  1116. const filterChild = (node) => node.children.filter((n) => n.type !== 3);
  1117. const hasSingleChild = (node) => filterChild(node).length === 1;
  1118. const ssrInjectFallthroughAttrs = (node, context) => {
  1119. if (node.type === 0) {
  1120. context.identifiers._attrs = 1;
  1121. }
  1122. if (node.type === 1 && node.tagType === 1 && (compilerDom.isBuiltInType(node.tag, "Transition") || compilerDom.isBuiltInType(node.tag, "KeepAlive"))) {
  1123. const rootChildren = filterChild(context.root);
  1124. if (rootChildren.length === 1 && rootChildren[0] === node) {
  1125. if (hasSingleChild(node)) {
  1126. injectFallthroughAttrs(node.children[0]);
  1127. }
  1128. return;
  1129. }
  1130. }
  1131. const parent = context.parent;
  1132. if (!parent || parent.type !== 0) {
  1133. return;
  1134. }
  1135. if (node.type === 10 && hasSingleChild(node)) {
  1136. let hasEncounteredIf = false;
  1137. for (const c of filterChild(parent)) {
  1138. if (c.type === 9 || c.type === 1 && compilerDom.findDir(c, "if")) {
  1139. if (hasEncounteredIf)
  1140. return;
  1141. hasEncounteredIf = true;
  1142. } else if (
  1143. // node before v-if
  1144. !hasEncounteredIf || // non else nodes
  1145. !(c.type === 1 && compilerDom.findDir(c, /else/, true))
  1146. ) {
  1147. return;
  1148. }
  1149. }
  1150. injectFallthroughAttrs(node.children[0]);
  1151. } else if (hasSingleChild(parent)) {
  1152. injectFallthroughAttrs(node);
  1153. }
  1154. };
  1155. function injectFallthroughAttrs(node) {
  1156. if (node.type === 1 && (node.tagType === 0 || node.tagType === 1) && !compilerDom.findDir(node, "for")) {
  1157. node.props.push({
  1158. type: 7,
  1159. name: "bind",
  1160. arg: void 0,
  1161. exp: compilerDom.createSimpleExpression(`_attrs`, false),
  1162. modifiers: [],
  1163. loc: compilerDom.locStub
  1164. });
  1165. }
  1166. }
  1167. const ssrInjectCssVars = (node, context) => {
  1168. if (!context.ssrCssVars) {
  1169. return;
  1170. }
  1171. if (node.type === 0) {
  1172. context.identifiers._cssVars = 1;
  1173. }
  1174. const parent = context.parent;
  1175. if (!parent || parent.type !== 0) {
  1176. return;
  1177. }
  1178. if (node.type === 10) {
  1179. for (const child of node.children) {
  1180. injectCssVars(child);
  1181. }
  1182. } else {
  1183. injectCssVars(node);
  1184. }
  1185. };
  1186. function injectCssVars(node) {
  1187. if (node.type === 1 && (node.tagType === 0 || node.tagType === 1) && !compilerDom.findDir(node, "for")) {
  1188. if (compilerDom.isBuiltInType(node.tag, "Suspense")) {
  1189. for (const child of node.children) {
  1190. if (child.type === 1 && child.tagType === 3) {
  1191. child.children.forEach(injectCssVars);
  1192. } else {
  1193. injectCssVars(child);
  1194. }
  1195. }
  1196. } else {
  1197. node.props.push({
  1198. type: 7,
  1199. name: "bind",
  1200. arg: void 0,
  1201. exp: compilerDom.createSimpleExpression(`_cssVars`, false),
  1202. modifiers: [],
  1203. loc: compilerDom.locStub
  1204. });
  1205. }
  1206. }
  1207. }
  1208. function compile(template, options = {}) {
  1209. options = {
  1210. ...options,
  1211. // apply DOM-specific parsing options
  1212. ...compilerDom.parserOptions,
  1213. ssr: true,
  1214. inSSR: true,
  1215. scopeId: options.mode === "function" ? null : options.scopeId,
  1216. // always prefix since compiler-ssr doesn't have size concern
  1217. prefixIdentifiers: true,
  1218. // disable optimizations that are unnecessary for ssr
  1219. cacheHandlers: false,
  1220. hoistStatic: false
  1221. };
  1222. const ast = compilerDom.baseParse(template, options);
  1223. rawOptionsMap.set(ast, options);
  1224. compilerDom.transform(ast, {
  1225. ...options,
  1226. hoistStatic: false,
  1227. nodeTransforms: [
  1228. ssrTransformIf,
  1229. ssrTransformFor,
  1230. compilerDom.trackVForSlotScopes,
  1231. compilerDom.transformExpression,
  1232. ssrTransformSlotOutlet,
  1233. ssrInjectFallthroughAttrs,
  1234. ssrInjectCssVars,
  1235. ssrTransformElement,
  1236. ssrTransformComponent,
  1237. compilerDom.trackSlotScopes,
  1238. compilerDom.transformStyle,
  1239. ...options.nodeTransforms || []
  1240. // user transforms
  1241. ],
  1242. directiveTransforms: {
  1243. // reusing core v-bind
  1244. bind: compilerDom.transformBind,
  1245. on: compilerDom.transformOn,
  1246. // model and show has dedicated SSR handling
  1247. model: ssrTransformModel,
  1248. show: ssrTransformShow,
  1249. // the following are ignored during SSR
  1250. // on: noopDirectiveTransform,
  1251. cloak: compilerDom.noopDirectiveTransform,
  1252. once: compilerDom.noopDirectiveTransform,
  1253. memo: compilerDom.noopDirectiveTransform,
  1254. ...options.directiveTransforms || {}
  1255. // user transforms
  1256. }
  1257. });
  1258. ssrCodegenTransform(ast, options);
  1259. return compilerDom.generate(ast, options);
  1260. }
  1261. exports.compile = compile;