/
ExportNamedDeclaration.ts
44 lines (38 loc) · 1.48 KB
/
ExportNamedDeclaration.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import MagicString from 'magic-string';
import { BLANK } from '../../utils/blank';
import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers';
import { ExecutionPathOptions } from '../ExecutionPathOptions';
import ClassDeclaration from './ClassDeclaration';
import ExportSpecifier from './ExportSpecifier';
import FunctionDeclaration from './FunctionDeclaration';
import Literal from './Literal';
import * as NodeType from './NodeType';
import { Node, NodeBase } from './shared/Node';
import VariableDeclaration from './VariableDeclaration';
export default class ExportNamedDeclaration extends NodeBase {
declaration: FunctionDeclaration | ClassDeclaration | VariableDeclaration | null;
needsBoundaries: true;
source: Literal<string> | null;
specifiers: ExportSpecifier[];
type: NodeType.tExportNamedDeclaration;
bind() {
// Do not bind specifiers
if (this.declaration !== null) this.declaration.bind();
}
hasEffects(options: ExecutionPathOptions) {
return this.declaration !== null && this.declaration.hasEffects(options);
}
initialise() {
this.included = false;
this.context.addExport(this);
}
render(code: MagicString, options: RenderOptions, { start, end }: NodeRenderOptions = BLANK) {
if (this.declaration === null) {
code.remove(start as number, end as number);
} else {
code.remove(this.start, this.declaration.start);
(this.declaration as Node).render(code, options, { start, end });
}
}
}
ExportNamedDeclaration.prototype.needsBoundaries = true;