From 417b4e15cbfaea48d8ce205c30f61646bf127b01 Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Fri, 4 Nov 2022 17:31:38 -0700 Subject: [PATCH] fix: sync fs esm library after patching cjs version --- js/private/node-patches/register.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/private/node-patches/register.js b/js/private/node-patches/register.js index 934d902f7..607afeb37 100644 --- a/js/private/node-patches/register.js +++ b/js/private/node-patches/register.js @@ -35,7 +35,8 @@ if ( JS_BINARY__PATCH_NODE_FS != '0' && JS_BINARY__FS_PATCH_ROOTS ) { - const fs = require('fs') + const fs = require('node:fs') + const module = require('node:module') const roots = JS_BINARY__FS_PATCH_ROOTS.split(':') if (JS_BINARY__LOG_DEBUG) { console.error( @@ -43,4 +44,8 @@ if ( ) } patchfs(fs, roots) + + // Sync the esm modules to use the now patched fs cjs module. + // See: https://nodejs.org/api/esm.html#builtin-modules + module.syncBuiltinESMExports() }