File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import {
1010 type ModuleNameWithoutNodePrefix ,
1111 type TransformHook ,
1212 compareModuleNames ,
13+ globalShimBanners ,
1314 isEnabled ,
1415 isNodeProtocolImport ,
1516 toRegExp ,
@@ -92,21 +93,6 @@ export type PolyfillOptionsResolved = {
9293 protocolImports : boolean ,
9394}
9495
95- const globalShimBanners = {
96- buffer : [
97- `import __buffer_polyfill from 'vite-plugin-node-polyfills/shims/buffer'` ,
98- `globalThis.Buffer = globalThis.Buffer || __buffer_polyfill` ,
99- ] ,
100- global : [
101- `import __global_polyfill from 'vite-plugin-node-polyfills/shims/global'` ,
102- `globalThis.global = globalThis.global || __global_polyfill` ,
103- ] ,
104- process : [
105- `import __process_polyfill from 'vite-plugin-node-polyfills/shims/process'` ,
106- `globalThis.process = globalThis.process || __process_polyfill` ,
107- ] ,
108- }
109-
11096/**
11197 * Returns a Vite plugin to polyfill Node's Core Modules for browser environments. Supports `node:` protocol imports.
11298 *
Original file line number Diff line number Diff line change @@ -11,6 +11,21 @@ export const compareModuleNames = (moduleA: ModuleName, moduleB: ModuleName) =>
1111 return withoutNodeProtocol ( moduleA ) === withoutNodeProtocol ( moduleB )
1212}
1313
14+ export const globalShimBanners = {
15+ buffer : [
16+ `import __buffer_polyfill from 'vite-plugin-node-polyfills/shims/buffer'` ,
17+ `globalThis.Buffer = globalThis.Buffer || __buffer_polyfill` ,
18+ ] ,
19+ global : [
20+ `import __global_polyfill from 'vite-plugin-node-polyfills/shims/global'` ,
21+ `globalThis.global = globalThis.global || __global_polyfill` ,
22+ ] ,
23+ process : [
24+ `import __process_polyfill from 'vite-plugin-node-polyfills/shims/process'` ,
25+ `globalThis.process = globalThis.process || __process_polyfill` ,
26+ ] ,
27+ }
28+
1429export const isEnabled = ( value : BooleanOrBuildTarget , target : BuildTarget ) => {
1530 if ( ! value ) return false
1631 if ( value === true ) return true
You can’t perform that action at this time.
0 commit comments