MCPcopy Index your code
hub / github.com/tinyplex/tinybase / setup

Function setup

test/unit/documentation.test.ts:514–589  ·  view source on GitHub ↗
(build)

Source from the content-addressed store, hash-verified

512 {
513 name: 'docs-virtual',
514 setup(build) {
515 build.onResolve({filter: /.*/}, (args) => {
516 if (args.kind === 'entry-point') {
517 return {namespace: 'docs-virtual', path: args.path};
518 }
519 if (allFiles[args.path] != null) {
520 return {namespace: 'docs-virtual', path: args.path};
521 }
522 if (args.path.startsWith('.')) {
523 const resolvedPath = resolve(dirname(args.importer), args.path);
524 return args.namespace === 'docs-virtual'
525 ? {
526 namespace: 'docs-virtual',
527 path: resolvedPath,
528 }
529 : null;
530 }
531 if (TINYBASE_SOURCE_MODULES[args.path] != null) {
532 return {path: TINYBASE_SOURCE_MODULES[args.path]};
533 }
534 const svelteInternalImport = resolveSvelteInternalImport(args.path);
535 if (svelteInternalImport != null) {
536 return {path: svelteInternalImport};
537 }
538 if (args.path.startsWith('/')) {
539 return {path: args.path};
540 }
541 return {external: true, path: args.path};
542 });
543 build.onLoad({filter: /.*/, namespace: 'docs-virtual'}, (args) => {
544 const file = allFiles[args.path];
545 if (file == null) {
546 throw new Error(`Unknown virtual file: ${args.path}`);
547 }
548 if (extname(args.path) == '.svelte') {
549 const compiled = compileSvelte(file, {
550 filename: args.path,
551 generate: 'client',
552 });
553 return {
554 contents: compiled.js.code,
555 loader: 'js',
556 resolveDir: dirname(args.path),
557 };
558 }
559 if (isSvelteModule(args.path)) {
560 return {
561 contents: compileSvelteModule(file, args.path),
562 loader: 'js',
563 resolveDir: dirname(args.path),
564 };
565 }
566 return {
567 contents: file,
568 loader: extname(args.path).slice(1) as
569 'js' | 'jsx' | 'ts' | 'tsx',
570 resolveDir: dirname(args.path),
571 };

Callers

nothing calls this directly

Calls 3

isSvelteModuleFunction · 0.85
compileSvelteModuleFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…