|
1 | 1 | import type MagicString from 'magic-string'; |
2 | 2 | import type { NormalizedTreeshakingOptions } from '../../rollup/types'; |
3 | 3 | import { BLANK } from '../../utils/blank'; |
4 | | -import { |
5 | | - findFirstOccurrenceOutsideComment, |
6 | | - type NodeRenderOptions, |
7 | | - type RenderOptions |
8 | | -} from '../../utils/renderHelpers'; |
| 4 | +import { renderCallArguments } from '../../utils/renderCallArguments'; |
| 5 | +import { type NodeRenderOptions, type RenderOptions } from '../../utils/renderHelpers'; |
9 | 6 | import type { DeoptimizableEntity } from '../DeoptimizableEntity'; |
10 | 7 | import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; |
11 | 8 | import { EVENT_CALLED } from '../NodeEvents'; |
@@ -116,36 +113,7 @@ export default class CallExpression extends CallExpressionBase implements Deopti |
116 | 113 | isCalleeOfRenderedParent: true, |
117 | 114 | renderedSurroundingElement |
118 | 115 | }); |
119 | | - if (this.arguments.length > 0) { |
120 | | - if (this.arguments[this.arguments.length - 1].included) { |
121 | | - for (const arg of this.arguments) { |
122 | | - arg.render(code, options); |
123 | | - } |
124 | | - } else { |
125 | | - let lastIncludedIndex = this.arguments.length - 2; |
126 | | - while (lastIncludedIndex >= 0 && !this.arguments[lastIncludedIndex].included) { |
127 | | - lastIncludedIndex--; |
128 | | - } |
129 | | - if (lastIncludedIndex >= 0) { |
130 | | - for (let index = 0; index <= lastIncludedIndex; index++) { |
131 | | - this.arguments[index].render(code, options); |
132 | | - } |
133 | | - code.remove( |
134 | | - findFirstOccurrenceOutsideComment( |
135 | | - code.original, |
136 | | - ',', |
137 | | - this.arguments[lastIncludedIndex].end |
138 | | - ), |
139 | | - this.end - 1 |
140 | | - ); |
141 | | - } else { |
142 | | - code.remove( |
143 | | - findFirstOccurrenceOutsideComment(code.original, '(', this.callee.end) + 1, |
144 | | - this.end - 1 |
145 | | - ); |
146 | | - } |
147 | | - } |
148 | | - } |
| 116 | + renderCallArguments(code, options, this); |
149 | 117 | } |
150 | 118 |
|
151 | 119 | protected applyDeoptimizations(): void { |
|
0 commit comments