MCPcopy Index your code
hub / github.com/QwikDev/qwik / generateServerReferenceModules

Function generateServerReferenceModules

scripts/api.ts:276–327  ·  view source on GitHub ↗
(config: BuildConfig)

Source from the content-addressed store, hash-verified

274}
275
276function generateServerReferenceModules(config: BuildConfig) {
277 // server-modules.d.ts
278 const referenceDts = `/// <reference types="./server" />
279declare module '@qwik-client-manifest' {
280 const manifest: import('./optimizer').QwikManifest;
281 export { manifest };
282}
283// MD
284declare module '*.md' {
285 const node: import('./core').FunctionComponent;
286 export const frontmatter: Record<string, any>;
287 export default node;
288}
289// MDX
290declare module '*.mdx' {
291 const node: import('./core').FunctionComponent;
292 export const frontmatter: Record<string, any>;
293 export default node;
294}
295// SVG ?jsx
296declare module '*.svg?jsx' {
297 const Cmp: import('./core').FunctionComponent<import('./core').QwikIntrinsicElements['svg']>
298 export default Cmp;
299}
300// Image ?jsx
301declare module '*?jsx' {
302 const Cmp: import('./core').FunctionComponent<Omit<import('./core').QwikIntrinsicElements['img'], 'src' | 'width' | 'height' | 'srcSet'>>
303 export default Cmp;
304 export const width: number;
305 export const height: number;
306 export const srcSet: string;
307}
308// Image &jsx
309declare module '*&jsx' {
310 const Cmp: import('./core').FunctionComponent<Omit<import('./core').QwikIntrinsicElements['img'], 'src' | 'width' | 'height' | 'srcSet'>>
311 export default Cmp;
312 export const width: number;
313 export const height: number;
314 export const srcSet: string;
315}
316`;
317
318 const destServerModulesPath = join(config.distQwikPkgDir, 'server-modules.d.ts');
319 writeFileSync(destServerModulesPath, referenceDts);
320
321 // manually prepend the ts reference since api extractor removes it
322 const prependReferenceDts = `/// <reference path="./server-modules.d.ts" />\n\n`;
323 const distServerPath = join(config.distQwikPkgDir, 'server.d.ts');
324 let serverDts = readFileSync(distServerPath, 'utf-8');
325 serverDts = prependReferenceDts + serverDts;
326 writeFileSync(distServerPath, serverDts);
327}
328
329/**
330 * Fix up the generated dts content, and ensure it's using a relative path to find the core.d.ts

Callers 1

apiExtractorQwikFunction · 0.85

Calls 1

joinFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…