Skip to content

Commit

Permalink
fixup! refactor: use esbuild-plugins-node-modules-polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
petebacondarwin committed Mar 13, 2024
1 parent ec4dec7 commit abd6eee
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/wrangler/src/deployment-bundle/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as fs from "node:fs";
import { builtinModules } from "node:module";
import * as path from "node:path";
import * as esbuild from "esbuild";
import { nodeModulesPolyfillPlugin } from "esbuild-plugins-node-modules-polyfill";
Expand Down Expand Up @@ -33,6 +34,11 @@ export const COMMON_ESBUILD_OPTIONS = {
// build conditions used by esbuild, and when resolving custom `import` calls
export const BUILD_CONDITIONS = ["workerd", "worker", "browser"];

const modulesToPolyfill: Record<string, boolean | "empty"> = Object.fromEntries(
builtinModules.map((m) => [m, true])
);
modulesToPolyfill.net = "empty";

/**
* Information about Wrangler's bundling process that needs passed through
* for DevTools sourcemap transformation
Expand Down Expand Up @@ -344,6 +350,7 @@ export async function bundleWorker(
? [
nodeModulesPolyfillPlugin({
globals: { process: true, Buffer: true },
modules: modulesToPolyfill,
}),
]
: []),
Expand Down

0 comments on commit abd6eee

Please sign in to comment.