23
23
* });
24
24
* ```
25
25
*/
26
- import path from 'node:path' ;
27
26
import type { VitePlugin } from '../types.js' ;
28
27
29
28
export interface OverrideComponentsOptions {
@@ -55,13 +54,8 @@ const virtualModuleId = 'tutorialkit:override-components';
55
54
const resolvedId = `\0${ virtualModuleId } ` ;
56
55
57
56
export function overrideComponents ( { components, defaultRoutes } : Options ) : VitePlugin {
58
- let root = '' ;
59
-
60
57
return {
61
58
name : 'tutorialkit-override-components-plugin' ,
62
- configResolved ( resolvedConfig ) {
63
- root = resolvedConfig . root ;
64
- } ,
65
59
resolveId ( id ) {
66
60
if ( id === virtualModuleId ) {
67
61
return resolvedId ;
@@ -71,7 +65,10 @@ export function overrideComponents({ components, defaultRoutes }: Options): Vite
71
65
} ,
72
66
async load ( id ) {
73
67
if ( id === resolvedId ) {
74
- const topBar = components ?. TopBar || resolveDefaultTopBar ( defaultRoutes , root ) ;
68
+ const topBar = components ?. TopBar || resolveDefaultTopBar ( defaultRoutes ) ;
69
+
70
+ // TODO Remove, debug windows CI
71
+ console . log ( { topBar, defaultRoutes } ) ;
75
72
76
73
return `
77
74
export { default as TopBar } from '${ topBar } ';
@@ -83,11 +80,11 @@ export function overrideComponents({ components, defaultRoutes }: Options): Vite
83
80
} ;
84
81
}
85
82
86
- function resolveDefaultTopBar ( defaultRoutes : boolean , root : string ) {
83
+ function resolveDefaultTopBar ( defaultRoutes : boolean ) {
87
84
if ( defaultRoutes ) {
88
85
return '@tutorialkit/astro/default/components/TopBar.astro' ;
89
86
}
90
87
91
88
// default `TopBar` is used from local file when `defaultRoutes` is disabled
92
- return path . resolve ( root , ' src/components/TopBar.astro') ;
89
+ return './ src/components/TopBar.astro';
93
90
}
0 commit comments