11import * as fs from "node:fs" ;
22import * as path from "node:path" ;
3- import NodeGlobalsPolyfills from "@esbuild-plugins/node-globals-polyfill" ;
4- import NodeModulesPolyfills from "@esbuild-plugins/node-modules-polyfill" ;
53import chalk from "chalk" ;
64import * as esbuild from "esbuild" ;
75import {
@@ -18,12 +16,9 @@ import {
1816} from "./build-failures" ;
1917import { dedupeModulesByName } from "./dedupe-modules" ;
2018import { getEntryPointFromMetafile } from "./entry-point-from-metafile" ;
21- import { asyncLocalStoragePlugin } from "./esbuild-plugins/als-external" ;
2219import { cloudflareInternalPlugin } from "./esbuild-plugins/cloudflare-internal" ;
2320import { configProviderPlugin } from "./esbuild-plugins/config-provider" ;
24- import { nodejsHybridPlugin } from "./esbuild-plugins/hybrid-nodejs-compat" ;
25- import { nodejsCompatPlugin } from "./esbuild-plugins/nodejs-compat" ;
26- import { standardURLPlugin } from "./esbuild-plugins/standard-url" ;
21+ import { getNodeJSCompatPlugins } from "./esbuild-plugins/nodejs-plugins" ;
2722import { writeAdditionalModules } from "./find-additional-modules" ;
2823import { noopModuleCollector } from "./module-collection" ;
2924import type { Config } from "../config" ;
@@ -440,20 +435,7 @@ export async function bundleWorker(
440435 plugins : [
441436 aliasPlugin ,
442437 moduleCollector . plugin ,
443- ...( nodejsCompatMode === "als" ? [ asyncLocalStoragePlugin ] : [ ] ) ,
444- ...( nodejsCompatMode === "legacy"
445- ? [
446- NodeGlobalsPolyfills ( { buffer : true } ) ,
447- standardURLPlugin ( ) ,
448- NodeModulesPolyfills ( ) ,
449- ]
450- : [ ] ) ,
451- // Runtime Node.js compatibility (will warn if not using nodejs compat flag and are trying to import from a Node.js builtin).
452- ...( nodejsCompatMode === "v1" || nodejsCompatMode !== "v2"
453- ? [ nodejsCompatPlugin ( nodejsCompatMode === "v1" ) ]
454- : [ ] ) ,
455- // Hybrid Node.js compatibility
456- ...( nodejsCompatMode === "v2" ? [ nodejsHybridPlugin ( ) ] : [ ] ) ,
438+ ...getNodeJSCompatPlugins ( nodejsCompatMode ?? null ) ,
457439 cloudflareInternalPlugin ,
458440 buildResultPlugin ,
459441 ...( plugins || [ ] ) ,
0 commit comments