-
Notifications
You must be signed in to change notification settings - Fork 217
Expand file tree
/
Copy pathrun-post-bundle-decorators.ts
More file actions
31 lines (27 loc) · 1.09 KB
/
run-post-bundle-decorators.ts
File metadata and controls
31 lines (27 loc) · 1.09 KB
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
import { resolveDocument, type Document, type BaseResolver } from '../resolve.js';
import { type NormalizedNodeType } from '../types/index.js';
import { normalizeVisitors } from '../visitors.js';
import { walkDocument, type WalkContext, type ProblemSeverity } from '../walk.js';
export async function runPostBundleDecorators(opts: {
document: Document;
normalizedTypes: Record<string, NormalizedNodeType>;
postBundleDecorators: { severity: ProblemSeverity; ruleId: string; visitor: any }[];
externalRefResolver: BaseResolver;
ctx: WalkContext;
}): Promise<void> {
const { document, normalizedTypes, postBundleDecorators, externalRefResolver, ctx } = opts;
if (postBundleDecorators.length === 0) return;
const postBundleRefMap = await resolveDocument({
rootDocument: document,
rootType: normalizedTypes.Root,
externalRefResolver,
});
const postBundleVisitors = normalizeVisitors(postBundleDecorators, normalizedTypes);
walkDocument({
document,
rootType: normalizedTypes.Root,
normalizedVisitors: postBundleVisitors,
resolvedRefMap: postBundleRefMap,
ctx,
});
}