@@ -4,7 +4,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
44import { dataToEsm } from '@rollup/pluginutils' ;
55import pLimit from 'p-limit' ;
66import { glob } from 'tinyglobby' ;
7- import { isRunnableDevEnvironment , normalizePath , type Plugin , type ViteDevServer } from 'vite' ;
7+ import { normalizePath , type Plugin , type ViteDevServer } from 'vite' ;
88import { AstroError , AstroErrorData } from '../core/errors/index.js' ;
99import { getRunnableEnvironment } from '../core/module-loader/index.js' ;
1010import { rootRelativePath } from '../core/viteUtils.js' ;
@@ -80,10 +80,8 @@ export function astroContentVirtualModPlugin({
8080 if ( devServer ) {
8181 // We defer adding the data store file to the watcher until the server is ready
8282 devServer . watcher . add ( fileURLToPath ( dataStoreFile ) ) ;
83- }
84- if ( isRunnableDevEnvironment ( this . environment ) ) {
8583 // Manually invalidate the data store to avoid a race condition in file watching
86- invalidateDataStore ( this . environment ) ;
84+ invalidateDataStore ( devServer ) ;
8785 }
8886 } ,
8987 async resolveId ( id , importer ) {
@@ -201,16 +199,14 @@ export function astroContentVirtualModPlugin({
201199 // If the datastore file changes, invalidate the virtual module
202200
203201 server . watcher . on ( 'add' , ( addedPath ) => {
204- const environment = getRunnableEnvironment ( server ) ;
205202 if ( addedPath === dataStorePath ) {
206- invalidateDataStore ( environment ) ;
203+ invalidateDataStore ( server ) ;
207204 }
208205 } ) ;
209206
210207 server . watcher . on ( 'change' , ( changedPath ) => {
211208 if ( changedPath === dataStorePath ) {
212- const environment = getRunnableEnvironment ( server ) ;
213- invalidateDataStore ( environment ) ;
209+ invalidateDataStore ( server ) ;
214210 }
215211 } ) ;
216212 } ,
0 commit comments