@@ -127,7 +127,7 @@ const isString = (str: unknown): str is string =>
127
127
* A Rollup/Vite plugin that automatically declares NodeJS built-in modules,
128
128
* and optionally npm dependencies, as 'external'.
129
129
*/
130
- async function nodeExternals ( options : ExternalsOptions = { } ) : Promise < Plugin > {
130
+ function nodeExternals ( options : ExternalsOptions = { } ) : Plugin {
131
131
132
132
const config : Config = { ...defaults , ...options }
133
133
@@ -138,7 +138,12 @@ async function nodeExternals(options: ExternalsOptions = {}): Promise<Plugin> {
138
138
isExcluded = ( id : string ) => exclude . length > 0 && exclude . some ( rx => rx . test ( id ) )
139
139
140
140
// Determine the root of the git repository, if any.
141
- const gitRepository = await new Promise < string | null > ( resolve => {
141
+ //
142
+ // Note: it looks like Vite doesn't support async plugin factories
143
+ // (see https://github.com/Septh/rollup-plugin-node-externals/issues/37
144
+ // and https://github.com/vitejs/vite/issues/20717), so we don't await
145
+ // the result here but rather inside the buildStart hook.
146
+ const gitTopLevel = new Promise < string | null > ( resolve => {
142
147
cp . execFile ( 'git' , [ 'rev-parse' , '--show-toplevel' ] , ( error , stdout ) => {
143
148
return resolve ( error ? null : path . normalize ( stdout . trim ( ) ) )
144
149
} )
@@ -184,7 +189,7 @@ async function nodeExternals(options: ExternalsOptions = {}): Promise<Plugin> {
184
189
packagePaths . push ( name )
185
190
186
191
// Break early if we are at the root of a git repo.
187
- if ( current === gitRepository )
192
+ if ( current === await gitTopLevel )
188
193
break
189
194
190
195
// Break early is there is a known workspace root file.
0 commit comments