Skip to content

Commit

Permalink
ix(dev): exclude node:-prefixed built-ins from the browser build
Browse files Browse the repository at this point in the history
  • Loading branch information
pcattori committed Jan 23, 2023
1 parent 3267cc7 commit 5c83a37
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/remix-dev/compiler/compileBrowser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from "path";
import * as fse from "fs-extra";
import { builtinModules as nodeBuiltins } from "module";
import { builtinModules } from "module";
import * as esbuild from "esbuild";
import { NodeModulesPolyfillPlugin } from "@esbuild-plugins/node-modules-polyfill";
import postcss from "postcss";
Expand Down Expand Up @@ -35,6 +35,11 @@ export type BrowserCompiler = {
dispose: () => void;
};

// Node v14 compat: include `node:`-prefixed built-ins like `"node:fs"`
let nodeBuiltins = Array.from(
new Set(builtinModules.flatMap((mod) => [mod, `node:${mod}`]))
);

const getExternals = (remixConfig: RemixConfig): string[] => {
// For the browser build, exclude node built-ins that don't have a
// browser-safe alternative installed in node_modules. Nothing should
Expand Down

0 comments on commit 5c83a37

Please sign in to comment.