MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / buildStart

Function buildStart

packages/tooling/src/vite.plugin.emit-dts.ts:119–226  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

117 return {
118 name: 'alphatab:emit-dts',
119 async buildStart() {
120 if (emitCache.get(cacheKey)) {
121 return;
122 }
123
124 const configFile = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
125 if (configFile.error) {
126 this.error(ts.flattenDiagnosticMessageText(configFile.error.messageText, '\n'));
127 }
128
129 const srcDir = path.resolve(options.projectDir, 'src');
130 const parsed = ts.parseJsonConfigFileContent(
131 configFile.config,
132 ts.sys,
133 path.dirname(tsconfigPath),
134 {
135 declaration: true,
136 emitDeclarationOnly: true,
137 declarationDir,
138 noEmit: false,
139 declarationMap: false,
140 // root the emit at src/ so paths mirror the source tree
141 // (src/Foo.ts -> dist/types/Foo.d.ts).
142 rootDir: srcDir
143 },
144 tsconfigPath
145 );
146
147 if (parsed.errors.length > 0) {
148 for (const diagnostic of parsed.errors) {
149 this.warn(ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'));
150 }
151 }
152
153 const program = ts.createProgram({
154 rootNames: parsed.fileNames,
155 options: parsed.options,
156 projectReferences: parsed.projectReferences
157 });
158
159 const transformers: ts.TransformerFactory<ts.SourceFile | ts.Bundle>[] = [
160 ...(options.afterDeclarations ?? []),
161 dtsPathsTransformer()
162 ];
163
164 // confine emit to `declarationDir`; TS would otherwise also write
165 // `.d.ts` next to any source outside `rootDir` (cross-package
166 // imports in monorepos).
167 const declarationDirPrefix = declarationDir + path.sep;
168 const filteredWriteFile: ts.WriteFileCallback = (
169 fileName,
170 content,
171 writeByteOrderMark,
172 onError,
173 sourceFiles,
174 data
175 ) => {
176 const normalized = path.resolve(fileName);

Callers

nothing calls this directly

Calls 8

hasMethod · 0.95
dtsPathsTransformerFunction · 0.85
warnMethod · 0.80
emitMethod · 0.80
getMethod · 0.65
errorMethod · 0.65
resolveMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected