File tree 1 file changed +8
-10
lines changed
1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -204,6 +204,13 @@ export const nodePolyfills = (options: PolyfillOptions = {}): Plugin => {
204
204
config : ( config , env ) => {
205
205
const isDev = env . command === 'serve'
206
206
207
+ const shimsToInject = {
208
+ // https://github.com/niksy/node-stdlib-browser/blob/3e7cd7f3d115ac5c4593b550e7d8c4a82a0d4ac4/README.md#vite
209
+ ...( isEnabled ( optionsResolved . globals . Buffer , 'build' ) ? { Buffer : 'vite-plugin-node-polyfills/shims/buffer' } : { } ) ,
210
+ ...( isEnabled ( optionsResolved . globals . global , 'build' ) ? { global : 'vite-plugin-node-polyfills/shims/global' } : { } ) ,
211
+ ...( isEnabled ( optionsResolved . globals . process , 'build' ) ? { process : 'vite-plugin-node-polyfills/shims/process' } : { } ) ,
212
+ }
213
+
207
214
return {
208
215
build : {
209
216
rollupOptions : {
@@ -216,16 +223,7 @@ export const nodePolyfills = (options: PolyfillOptions = {}): Plugin => {
216
223
rollupWarn ( warning )
217
224
} )
218
225
} ,
219
- plugins : [
220
- {
221
- ...inject ( {
222
- // https://github.com/niksy/node-stdlib-browser/blob/3e7cd7f3d115ac5c4593b550e7d8c4a82a0d4ac4/README.md#vite
223
- ...( isEnabled ( optionsResolved . globals . Buffer , 'build' ) ? { Buffer : 'vite-plugin-node-polyfills/shims/buffer' } : { } ) ,
224
- ...( isEnabled ( optionsResolved . globals . global , 'build' ) ? { global : 'vite-plugin-node-polyfills/shims/global' } : { } ) ,
225
- ...( isEnabled ( optionsResolved . globals . process , 'build' ) ? { process : 'vite-plugin-node-polyfills/shims/process' } : { } ) ,
226
- } ) ,
227
- } ,
228
- ] ,
226
+ plugins : Object . keys ( shimsToInject ) . length > 0 ? [ inject ( shimsToInject ) ] : [ ] ,
229
227
} ,
230
228
} ,
231
229
esbuild : {
You can’t perform that action at this time.
0 commit comments