@@ -108,8 +108,14 @@ export class PluginRunner {
108
108
} ) ;
109
109
}
110
110
111
+ const preprocessorPlugins = plugins . filter ( ( p ) => p . options . preprocessor ) ;
112
+ const otherPlugins = plugins . filter ( ( p ) => ! p . options . preprocessor ) ;
113
+
111
114
// 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
+ ) ;
113
119
const allPlugins = [ ...corePlugins , ...userPlugins ] ;
114
120
115
121
// check dependencies
@@ -139,6 +145,28 @@ export class PluginRunner {
139
145
let prismaClientDtsPath : string | undefined = undefined ;
140
146
141
147
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
+
142
170
for ( const { name, description, run, options : pluginOptions } of corePlugins ) {
143
171
const options = { ...pluginOptions , prismaClientPath } ;
144
172
const r = await this . runPlugin (
@@ -175,21 +203,7 @@ export class PluginRunner {
175
203
await compileProject ( project , runnerOptions ) ;
176
204
177
205
// 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 ) ;
193
207
194
208
console . log ( colors . green ( colors . bold ( '\n👻 All plugins completed successfully!' ) ) ) ;
195
209
warnings . forEach ( ( w ) => console . warn ( colors . yellow ( w ) ) ) ;
0 commit comments