{"version":3,"file":"index.cjs","sources":["../src/modules.ts","../src/utils.ts","../src/globals.ts","../src/regex.ts","../src/plugins.ts","../src/index.ts"],"sourcesContent":["export type ModuleName = typeof modules[number]\nexport type ModuleNameWithNodePrefix = `node:${ModuleName}`\n\nexport const modules = [\n  '_stream_duplex',\n  '_stream_passthrough',\n  '_stream_readable',\n  '_stream_transform',\n  '_stream_writable',\n  'assert',\n  'buffer',\n  'child_process',\n  'cluster',\n  'console',\n  'constants',\n  'crypto',\n  'dgram',\n  'dns',\n  'domain',\n  'events',\n  'fs',\n  'http',\n  'http2',\n  'https',\n  'module',\n  'net',\n  'os',\n  'path',\n  'process',\n  'punycode',\n  'querystring',\n  'readline',\n  'repl',\n  'stream',\n  'string_decoder',\n  'sys',\n  'timers',\n  'timers/promises',\n  'tls',\n  'tty',\n  'url',\n  'util',\n  'vm',\n  'zlib',\n] as const\n\nexport const getModulesToPolyfill = ({\n  modulesToExclude,\n  modulesToInclude,\n}: {\n  modulesToExclude: ModuleName[],\n  modulesToInclude: ModuleName[],\n}): ModuleName[] => {\n  return modules.filter((module) => {\n    if (modulesToInclude.length > 0) {\n      return modulesToInclude.includes(module)\n    }\n\n    return !modulesToExclude.includes(module)\n  })\n}\n\nexport const isModuleName = (name: string): name is ModuleName => {\n  return modules.includes(name as ModuleName)\n}\n","import stdLibBrowser from 'node-stdlib-browser'\nimport { type Plugin } from 'vite'\n\nexport type BuildTarget = 'build' | 'dev'\nexport type BooleanOrBuildTarget = boolean | BuildTarget\nexport type ModuleName = keyof typeof stdLibBrowser\nexport type ModuleNameWithoutNodePrefix<T = ModuleName> = T extends `node:${infer P}` ? P : never\nexport type TransformHook = Extract<Plugin['transform'], Function>\n\nexport const compareModuleNames = (moduleA: ModuleName, moduleB: ModuleName) => {\n  return withoutNodeProtocol(moduleA) === withoutNodeProtocol(moduleB)\n}\n\nexport const globalShimBanners = {\n  buffer: [\n    `import __buffer_polyfill from 'vite-plugin-node-polyfills/shims/buffer'`,\n    `globalThis.Buffer = globalThis.Buffer || __buffer_polyfill`,\n  ],\n  global: [\n    `import __global_polyfill from 'vite-plugin-node-polyfills/shims/global'`,\n    `globalThis.global = globalThis.global || __global_polyfill`,\n  ],\n  process: [\n    `import __process_polyfill from 'vite-plugin-node-polyfills/shims/process'`,\n    `globalThis.process = globalThis.process || __process_polyfill`,\n  ],\n}\n\nexport const isEnabled = (value: BooleanOrBuildTarget, target: BuildTarget) => {\n  if (!value) return false\n  if (value === true) return true\n\n  return value === target\n}\n\nexport const isModuleName = (name: string): name is ModuleName => {\n  return name in stdLibBrowser\n}\n\nexport const isNodeProtocolImport = (name: string) => {\n  return name.startsWith('node:')\n}\n\nexport const toRegExp = (text: string) => {\n  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping\n  const escapedText = text.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n\n  return new RegExp(`^${escapedText}$`)\n}\n\nexport const withoutNodeProtocol = (name: ModuleName): ModuleNameWithoutNodePrefix => {\n  return name.replace(/^node:/, '') as ModuleNameWithoutNodePrefix\n}\n","import {\n  type BooleanOrBuildTarget,\n  type BuildTarget,\n  isEnabled,\n} from './utils'\n\nexport type GlobalName = typeof globals[number]\n\nexport const globals = [\n  'buffer',\n  'global',\n  'process',\n] as const\n\nexport const getGlobalsToHandle = (options: {\n  globals: { [Name in GlobalName]: BooleanOrBuildTarget },\n  target: BuildTarget,\n}): GlobalName[] => {\n  return globals.filter((global) => {\n    const value = options.globals[global]\n\n    return isEnabled(value, options.target)\n  })\n}\n","export const any = (patterns: readonly string[]) => {\n  return group(patterns.join('|'))\n}\n\nexport const compose = (patterns: readonly string[]) => {\n  const pattern = patterns.join('')\n\n  return new RegExp(`^${pattern}$`)\n}\n\nexport const group = (pattern: string) => {\n  return `(?:${pattern})`\n}\n\nexport const join = (patterns: readonly string[]) => {\n  return patterns.join('')\n}\n\nexport const optional = (pattern: string) => {\n  return `${group(pattern)}?`\n}\n\nexport const when = (condition: boolean, pattern: string, fallback = '') => {\n  if (condition) {\n    return pattern\n  }\n\n  return fallback\n}\n","import { type Plugin } from 'vite'\nimport { globals } from './globals'\nimport { type ModuleName } from './modules'\nimport * as regex from './regex'\n\nexport const buildTrailingSlashNormalizer = ({\n  modules,\n  protocolImports,\n}: {\n  modules: ModuleName[],\n  protocolImports: boolean,\n}): Plugin[] => {\n  const trailingSlashNormalizerRegex = regex.compose([\n    regex.any([\n      regex.join([\n        regex.when(\n          protocolImports,\n          regex.optional('node:'),\n        ),\n        regex.any(modules),\n      ]),\n      regex.join([\n        'vite-plugin-node-polyfills/shims/',\n        regex.any(globals),\n      ]),\n    ]),\n    '/',\n  ])\n\n  return [\n    {\n      // Vite v8.0.0+ does not support trailing slashes on package subpaths.\n      name: 'vite-plugin-node-polyfills:trailing-slash-normalizer',\n      enforce: 'pre',\n      resolveId: {\n        // @ts-expect-error This property is only supported in Vite v6.3.0+, so\n        // we must run the check inside the handler to maintain compatibility\n        // with older Vite versions.\n        filter: { id: trailingSlashNormalizerRegex },\n        async handler(source, importer, options) {\n          if (!trailingSlashNormalizerRegex.test(source)) {\n            return\n          }\n\n          const sourceWithoutTrailingSlash = source.replace(/\\/$/, '')\n\n          return this.resolve(sourceWithoutTrailingSlash, importer, {\n            ...options,\n            skipSelf: true,\n          })\n        },\n      },\n    },\n  ]\n}\n","import { createRequire } from 'node:module'\nimport inject from '@rollup/plugin-inject'\nimport stdLibBrowser from 'node-stdlib-browser'\nimport { handleCircularDependancyWarning } from 'node-stdlib-browser/helpers/rollup/plugin'\nimport esbuildPlugin from 'node-stdlib-browser/helpers/esbuild/plugin'\nimport type { Plugin } from 'vite'\nimport { getModulesToPolyfill } from './modules'\nimport { buildTrailingSlashNormalizer } from './plugins'\nimport {\n  type BooleanOrBuildTarget,\n  type ModuleName,\n  type ModuleNameWithoutNodePrefix,\n  type TransformHook,\n  compareModuleNames,\n  globalShimBanners,\n  isEnabled,\n  isNodeProtocolImport,\n  toRegExp,\n  withoutNodeProtocol,\n} from './utils'\n\nexport type PolyfillOptions = {\n  /**\n   * Includes specific modules. If empty, includes all modules\n   * @example\n   *\n   * ```ts\n   * nodePolyfills({\n   *   include: ['fs', 'path'],\n   * })\n   * ```\n  */\n  include?: ModuleNameWithoutNodePrefix[],\n  /**\n   * @example\n   *\n   * ```ts\n   * nodePolyfills({\n   *   exclude: ['fs', 'path'],\n   * })\n   * ```\n   */\n  exclude?: ModuleNameWithoutNodePrefix[],\n  /**\n   * Specify whether specific globals should be polyfilled.\n   *\n   * @example\n   *\n   * ```ts\n   * nodePolyfills({\n   *   globals: {\n   *     Buffer: false,\n   *     global: true,\n   *     process: 'build',\n   *   },\n   * })\n   * ```\n   */\n  globals?: {\n    Buffer?: BooleanOrBuildTarget,\n    global?: BooleanOrBuildTarget,\n    process?: BooleanOrBuildTarget,\n  },\n  /**\n   * Specify alternative modules to use in place of the default polyfills.\n   *\n   * @example\n   *\n   * ```ts\n   * nodePolyfills({\n   *   overrides: {\n   *     fs: 'memfs',\n   *   },\n   * })\n   * ```\n   */\n  overrides?: { [Key in ModuleNameWithoutNodePrefix]?: string },\n  /**\n   * Specify whether the Node protocol version of an import (e.g. `node:buffer`) should be polyfilled too.\n   *\n   * @default true\n   */\n  protocolImports?: boolean,\n}\n\nexport type PolyfillOptionsResolved = {\n  include: ModuleNameWithoutNodePrefix[],\n  exclude: ModuleNameWithoutNodePrefix[],\n  globals: {\n    Buffer: BooleanOrBuildTarget,\n    global: BooleanOrBuildTarget,\n    process: BooleanOrBuildTarget,\n  },\n  overrides: { [Key in ModuleNameWithoutNodePrefix]?: string },\n  protocolImports: boolean,\n}\n\n/**\n * Returns a Vite plugin to polyfill Node's Core Modules for browser environments. Supports `node:` protocol imports.\n *\n * @example\n *\n * ```ts\n * // vite.config.ts\n * import { defineConfig } from 'vite'\n * import { nodePolyfills } from 'vite-plugin-node-polyfills'\n *\n * export default defineConfig({\n *   plugins: [\n *     nodePolyfills({\n *       // Specific modules that should not be polyfilled.\n *       exclude: [],\n *       // Whether to polyfill specific globals.\n *       globals: {\n *         Buffer: true, // can also be 'build', 'dev', or false\n *         global: true,\n *         process: true,\n *       },\n *       // Whether to polyfill `node:` protocol imports.\n *       protocolImports: true,\n *     }),\n *   ],\n * })\n * ```\n */\nexport const nodePolyfills = (options: PolyfillOptions = {}): Plugin[] => {\n  const optionsResolved: PolyfillOptionsResolved = {\n    include: [],\n    exclude: [],\n    overrides: {},\n    protocolImports: true,\n    ...options,\n    globals: {\n      Buffer: true,\n      global: true,\n      process: true,\n      ...options.globals,\n    },\n  }\n\n  const modulesToPolyfill = getModulesToPolyfill({\n    modulesToExclude: optionsResolved.exclude,\n    modulesToInclude: optionsResolved.include,\n  })\n\n  const trailingSlashNormalizer = buildTrailingSlashNormalizer({\n    modules: modulesToPolyfill,\n    protocolImports: optionsResolved.protocolImports,\n  })\n\n  const isExcluded = (moduleName: ModuleName) => {\n    if (optionsResolved.include.length > 0) {\n      return !optionsResolved.include.some((includedName) => compareModuleNames(moduleName, includedName))\n    }\n\n    return optionsResolved.exclude.some((excludedName) => compareModuleNames(moduleName, excludedName))\n  }\n\n  const toOverride = (name: ModuleNameWithoutNodePrefix): string | void => {\n    if (isEnabled(optionsResolved.globals.Buffer, 'dev') && /^buffer$/.test(name)) {\n      return 'vite-plugin-node-polyfills/shims/buffer'\n    }\n\n    if (isEnabled(optionsResolved.globals.global, 'dev') && /^global$/.test(name)) {\n      return 'vite-plugin-node-polyfills/shims/global'\n    }\n\n    if (isEnabled(optionsResolved.globals.process, 'dev') && /^process$/.test(name)) {\n      return 'vite-plugin-node-polyfills/shims/process'\n    }\n\n    if (name in optionsResolved.overrides) {\n      return optionsResolved.overrides[name]\n    }\n  }\n\n  const polyfills = (Object.entries(stdLibBrowser) as Array<[ModuleName, string]>).reduce<Record<ModuleName, string>>((included, [name, value]) => {\n    if (!optionsResolved.protocolImports) {\n      if (isNodeProtocolImport(name)) {\n        return included\n      }\n    }\n\n    if (!isExcluded(name)) {\n      included[name] = toOverride(withoutNodeProtocol(name)) || value\n    }\n\n    return included\n  }, {} as Record<ModuleName, string>)\n\n  const require = createRequire(import.meta.url)\n  const globalShimPaths = [\n    ...((isEnabled(optionsResolved.globals.Buffer, 'dev')) ? [require.resolve('vite-plugin-node-polyfills/shims/buffer')] : []),\n    ...((isEnabled(optionsResolved.globals.global, 'dev')) ? [require.resolve('vite-plugin-node-polyfills/shims/global')] : []),\n    ...((isEnabled(optionsResolved.globals.process, 'dev')) ? [require.resolve('vite-plugin-node-polyfills/shims/process')] : []),\n  ]\n\n  const globalShimsBanner = [\n    ...((isEnabled(optionsResolved.globals.Buffer, 'dev')) ? globalShimBanners.buffer : []),\n    ...((isEnabled(optionsResolved.globals.global, 'dev')) ? globalShimBanners.global : []),\n    ...((isEnabled(optionsResolved.globals.process, 'dev')) ? globalShimBanners.process : []),\n    ``,\n  ].join('\\n')\n\n  let rawInjectPlugin: Plugin | false | undefined\n  function transform(this: ThisParameterType<TransformHook>, code: string, id: string, opts: Parameters<TransformHook>[2]) {\n    if (rawInjectPlugin === undefined) {\n      throw new Error('transform called before inject plugin initialization')\n    }\n    if (rawInjectPlugin === false) {\n      return\n    }\n    return (rawInjectPlugin.transform as TransformHook).call(this, code, id, opts)\n  }\n  const injectPlugin: Plugin = {\n    name: 'vite-plugin-node-polyfills:inject',\n    enforce: 'post',\n    transform,\n  }\n\n  const plugin: Plugin = {\n    name: 'vite-plugin-node-polyfills',\n    config(config, env) {\n      const isBuild = env.command === 'build'\n      const isDev = env.command === 'serve'\n      // @ts-expect-error - this.meta.rolldownVersion only exists with rolldown-vite 7+\n      const isRolldownVite = !!this?.meta?.rolldownVersion\n      const isNativeInjectAvailable = isBuild && isRolldownVite\n\n      // https://github.com/niksy/node-stdlib-browser/blob/3e7cd7f3d115ac5c4593b550e7d8c4a82a0d4ac4/README.md?plain=1#L203-L209\n      const defines = {\n        ...((isDev && isEnabled(optionsResolved.globals.Buffer, 'dev')) ? { Buffer: 'Buffer' } : {}),\n        ...((isDev && isEnabled(optionsResolved.globals.global, 'dev')) ? { global: 'global' } : {}),\n        ...((isDev && isEnabled(optionsResolved.globals.process, 'dev')) ? { process: 'process' } : {}),\n      }\n\n      const shimsToInject = {\n        // https://github.com/niksy/node-stdlib-browser/blob/3e7cd7f3d115ac5c4593b550e7d8c4a82a0d4ac4/README.md#vite\n        ...(isEnabled(optionsResolved.globals.Buffer, 'build') ? { Buffer: 'vite-plugin-node-polyfills/shims/buffer' } : {}),\n        ...(isEnabled(optionsResolved.globals.global, 'build') ? { global: 'vite-plugin-node-polyfills/shims/global' } : {}),\n        ...(isEnabled(optionsResolved.globals.process, 'build') ? { process: 'vite-plugin-node-polyfills/shims/process' } : {}),\n      }\n\n      rawInjectPlugin = (Object.keys(shimsToInject).length > 0 && !isNativeInjectAvailable) ? inject(shimsToInject) as Plugin : false\n      if (rawInjectPlugin === false) {\n        delete injectPlugin.transform\n      } else {\n        // hook filters are only supported in Vite 6.3.0+\n        (transform as any).filter = {\n          code: new RegExp(Object.keys(shimsToInject).join('|')),\n        }\n      }\n\n      return {\n        build: {\n          rollupOptions: {\n            onwarn: (warning, rollupWarn) => {\n              handleCircularDependancyWarning(warning, () => {\n                if (config.build?.rollupOptions?.onwarn) {\n                  return config.build.rollupOptions.onwarn(warning, rollupWarn)\n                }\n\n                rollupWarn(warning)\n              })\n            },\n            ...(Object.keys(shimsToInject).length > 0 && isRolldownVite)\n              ? { transform: { inject: shimsToInject } }\n              : {},\n          },\n        },\n        optimizeDeps: {\n          exclude: [\n            ...globalShimPaths,\n          ],\n          ...isRolldownVite\n            ? {\n                rolldownOptions: {\n                  resolve: {\n                    // https://github.com/niksy/node-stdlib-browser/blob/3e7cd7f3d115ac5c4593b550e7d8c4a82a0d4ac4/README.md?plain=1#L150\n                    alias: {\n                      ...polyfills,\n                    },\n                  },\n                  transform: {\n                    define: defines,\n                  },\n                  plugins: [\n                    trailingSlashNormalizer,\n                    {\n                      name: 'vite-plugin-node-polyfills:optimizer',\n                      banner: isDev ? globalShimsBanner : undefined,\n                    },\n                  ],\n                },\n              }\n            : {\n                esbuildOptions: {\n                  banner: isDev ? { js: globalShimsBanner } : undefined,\n                  define: defines,\n                  inject: [\n                    ...globalShimPaths,\n                  ],\n                  plugins: [\n                    esbuildPlugin(polyfills),\n                    // Supress the 'injected path \"...\" cannot be marked as external' error in Vite 4 (emitted by esbuild).\n                    // https://github.com/evanw/esbuild/blob/edede3c49ad6adddc6ea5b3c78c6ea7507e03020/internal/bundler/bundler.go#L1469\n                    {\n                      name: 'vite-plugin-node-polyfills-shims-resolver',\n                      setup(build) {\n                        for (const globalShimPath of globalShimPaths) {\n                          const globalShimsFilter = toRegExp(globalShimPath)\n\n                          // https://esbuild.github.io/plugins/#on-resolve\n                          build.onResolve({ filter: globalShimsFilter }, () => {\n                            return {\n                              // https://github.com/evanw/esbuild/blob/edede3c49ad6adddc6ea5b3c78c6ea7507e03020/internal/bundler/bundler.go#L1468\n                              external: false,\n                              path: globalShimPath,\n                            }\n                          })\n                        }\n                      },\n                    },\n                  ],\n                },\n              },\n        },\n        resolve: {\n          // https://github.com/niksy/node-stdlib-browser/blob/3e7cd7f3d115ac5c4593b550e7d8c4a82a0d4ac4/README.md?plain=1#L150\n          alias: {\n            ...polyfills,\n          },\n        },\n      }\n    },\n  }\n\n  return [\n    trailingSlashNormalizer,\n    injectPlugin,\n    plugin,\n  ].flat()\n}\n"],"names":["modules","getModulesToPolyfill","modulesToExclude","modulesToInclude","module","compareModuleNames","moduleA","moduleB","withoutNodeProtocol","globalShimBanners","isEnabled","value","target","isNodeProtocolImport","name","toRegExp","text","escapedText","globals","any","patterns","group","compose","pattern","join","optional","when","condition","fallback","buildTrailingSlashNormalizer","protocolImports","trailingSlashNormalizerRegex","regex.compose","regex.any","regex.join","regex.when","regex.optional","source","importer","options","sourceWithoutTrailingSlash","nodePolyfills","optionsResolved","modulesToPolyfill","trailingSlashNormalizer","isExcluded","moduleName","includedName","excludedName","toOverride","polyfills","stdLibBrowser","included","require","createRequire","_documentCurrentScript","globalShimPaths","globalShimsBanner","rawInjectPlugin","transform","code","id","opts","injectPlugin","config","env","isBuild","isDev","isRolldownVite","isNativeInjectAvailable","defines","shimsToInject","inject","warning","rollupWarn","handleCircularDependancyWarning","esbuildPlugin","build","globalShimPath","globalShimsFilter"],"mappings":"sZAGaA,EAAU,CACrB,iBACA,sBACA,mBACA,oBACA,mBACA,SACA,SACA,gBACA,UACA,UACA,YACA,SACA,QACA,MACA,SACA,SACA,KACA,OACA,QACA,QACA,SACA,MACA,KACA,OACA,UACA,WACA,cACA,WACA,OACA,SACA,iBACA,MACA,SACA,kBACA,MACA,MACA,MACA,OACA,KACA,MACF,EAEaC,EAAuB,CAAC,CACnC,iBAAAC,EACA,iBAAAC,CACF,IAISH,EAAQ,OAAQI,GACjBD,EAAiB,OAAS,EACrBA,EAAiB,SAASC,CAAM,EAGlC,CAACF,EAAiB,SAASE,CAAM,CACzC,EClDUC,EAAqB,CAACC,EAAqBC,IAC/CC,EAAoBF,CAAO,IAAME,EAAoBD,CAAO,EAGxDE,EAAoB,CAC/B,OAAQ,CACN,0EACA,4DACF,EACA,OAAQ,CACN,0EACA,4DACF,EACA,QAAS,CACP,4EACA,+DACF,CACF,EAEaC,EAAY,CAACC,EAA6BC,IAChDD,EACDA,IAAU,GAAa,GAEpBA,IAAUC,EAHE,GAURC,EAAwBC,GAC5BA,EAAK,WAAW,OAAO,EAGnBC,EAAYC,GAAiB,CAExC,MAAMC,EAAcD,EAAK,QAAQ,sBAAuB,MAAM,EAE9D,OAAO,IAAI,OAAO,IAAIC,CAAW,GAAG,CACtC,EAEaT,EAAuBM,GAC3BA,EAAK,QAAQ,SAAU,EAAE,EC3CrBI,EAAU,CACrB,SACA,SACA,SACF,ECZaC,EAAOC,GACXC,EAAMD,EAAS,KAAK,GAAG,CAAC,EAGpBE,EAAWF,GAAgC,CAChD,MAAAG,EAAUH,EAAS,KAAK,EAAE,EAEhC,OAAO,IAAI,OAAO,IAAIG,C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