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

Function ensureBundlingPlugin

packages/tooling/src/vite.ts:201–227  ·  view source on GitHub ↗
(o: OutputOptions)

Source from the content-addressed store, hash-verified

199
200 const output = config.build!.rollupOptions!.output as OutputOptions[];
201 const ensureBundlingPlugin = (o: OutputOptions) => {
202 o.plugins ??= [];
203 (o.plugins as OutputPlugin[]).push({
204 name: 'alphatab:bundle-dts',
205 async writeBundle(opts, bundle) {
206 for (const fileName of Object.keys(bundle)) {
207 const chunk = bundle[fileName];
208 if (
209 chunk.type !== 'chunk' ||
210 !chunk.isEntry ||
211 !fileName.endsWith('.mjs') ||
212 !shouldEmitForChunk(chunk)
213 ) {
214 continue;
215 }
216 // intermediates mirror the entry's path relative to src/ (rootDir).
217 const relative = path.parse(path.relative(srcDir, chunk.facadeModuleId!));
218 const intermediate = path.join(declarationDir, relative.dir, `${relative.name}.d.ts`);
219 if (!fs.existsSync(intermediate)) {
220 this.error(`Could not find intermediate d.ts at ${intermediate}`);
221 }
222 const outFile = path.resolve(opts.dir!, fileName.replace(/\.mjs$/, '.d.ts'));
223 generateDts(projectDir, intermediate, outFile, externals);
224 }
225 }
226 });
227 };
228
229 for (const o of output) {
230 if (o.format === 'es' || o.format === 'esm') {

Callers 1

addDtsFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected