Skip to content

Commit 318c14f

Browse files
committed
fix: make paths in watchedFiles absolute as mentioned in the docs
1 parent 777e2ca commit 318c14f

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

__tests__/e2e/dynamic-routes/[id].paths.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default defineRoutes({
66
// console.log('watchedFiles', watchedFiles)
77
return paths
88
},
9-
watch: ['**/data-loading/**/*.json'],
9+
watch: ['../data-loading/**/*.json'],
1010
async transformPageData(pageData) {
1111
// console.log('transformPageData', pageData.filePath)
1212
pageData.title += ' - transformed'

src/node/contentLoader.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ export function createContentLoader<T = ContentData[]>(
9595

9696
async load(files?: string[]) {
9797
// the loader is being called directly, do a fresh glob
98-
files = files ?? (await glob(watch, options.globOptions))
98+
files ??= await glob(watch, {
99+
absolute: true,
100+
...options.globOptions
101+
})
99102

100103
const md = await createMarkdownRenderer(
101104
config.srcDir,

src/node/plugins/dynamicRoutesPlugin.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,10 @@ async function resolveDynamicRoutes(
308308
let pathsData: UserRouteConfig[]
309309

310310
if (typeof loader === 'function') {
311-
const watchedFiles = await glob(watch, options.globOptions)
311+
const watchedFiles = await glob(watch, {
312+
absolute: true,
313+
...options.globOptions
314+
})
312315
pathsData = await loader(watchedFiles)
313316
} else {
314317
pathsData = loader

src/node/plugins/staticDataPlugin.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ export const staticDataPlugin: Plugin = {
9797
}
9898

9999
// load the data
100-
const watchedFiles = await glob(watch, options.globOptions)
100+
const watchedFiles = await glob(watch, {
101+
absolute: true,
102+
...options.globOptions
103+
})
101104
const data = await load(watchedFiles)
102105

103106
// record loader module for HMR

src/node/utils/glob.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { glob as _glob } from 'tinyglobby'
33
import { normalizePath } from 'vite'
44

55
export interface GlobOptions {
6+
absolute?: boolean
67
cwd?: string
78
ignore?: string | string[]
89
dot?: boolean

0 commit comments

Comments
 (0)