@@ -108,8 +108,14 @@ export class PluginRunner {
108108 } ) ;
109109 }
110110
111+ const preprocessorPlugins = plugins . filter ( ( p ) => p . options . preprocessor ) ;
112+ const otherPlugins = plugins . filter ( ( p ) => ! p . options . preprocessor ) ;
113+
111114 // calculate all plugins (including core plugins implicitly enabled)
112- const { corePlugins, userPlugins } = this . calculateAllPlugins ( runnerOptions , plugins ) ;
115+ const { corePlugins, userPlugins } = this . calculateAllPlugins (
116+ runnerOptions ,
117+ otherPlugins ,
118+ ) ;
113119 const allPlugins = [ ...corePlugins , ...userPlugins ] ;
114120
115121 // check dependencies
@@ -139,6 +145,28 @@ export class PluginRunner {
139145 let prismaClientDtsPath : string | undefined = undefined ;
140146
141147 const project = createProject ( ) ;
148+
149+ const runUserPlugins = async ( plugins : PluginInfo [ ] ) => {
150+ for ( const { name, description, run, options : pluginOptions } of plugins ) {
151+ const options = { ...pluginOptions , prismaClientPath, prismaClientDtsPath } ;
152+ const r = await this . runPlugin (
153+ name ,
154+ description ,
155+ run ,
156+ runnerOptions ,
157+ options as PluginOptions ,
158+ dmmf ,
159+ shortNameMap ,
160+ project ,
161+ false
162+ ) ;
163+ warnings . push ( ...( r ?. warnings ?? [ ] ) ) ; // the null-check is for backward compatibility
164+ }
165+ } ;
166+
167+ // run preprocessor plugins
168+ await runUserPlugins ( preprocessorPlugins ) ;
169+
142170 for ( const { name, description, run, options : pluginOptions } of corePlugins ) {
143171 const options = { ...pluginOptions , prismaClientPath } ;
144172 const r = await this . runPlugin (
@@ -175,21 +203,7 @@ export class PluginRunner {
175203 await compileProject ( project , runnerOptions ) ;
176204
177205 // run user plugins
178- for ( const { name, description, run, options : pluginOptions } of userPlugins ) {
179- const options = { ...pluginOptions , prismaClientPath, prismaClientDtsPath } ;
180- const r = await this . runPlugin (
181- name ,
182- description ,
183- run ,
184- runnerOptions ,
185- options as PluginOptions ,
186- dmmf ,
187- shortNameMap ,
188- project ,
189- false
190- ) ;
191- warnings . push ( ...( r ?. warnings ?? [ ] ) ) ; // the null-check is for backward compatibility
192- }
206+ await runUserPlugins ( userPlugins ) ;
193207
194208 console . log ( colors . green ( colors . bold ( '\n👻 All plugins completed successfully!' ) ) ) ;
195209 warnings . forEach ( ( w ) => console . warn ( colors . yellow ( w ) ) ) ;
0 commit comments