File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -95,21 +95,29 @@ does not add or remove exported names from the [ES Modules][].
9595
9696` ` ` js
9797const fs = require (' fs' );
98+ const assert = require (' assert' );
9899const { syncBuiltinESMExports } = require (' module' );
99100
100- fs .readFile = null ;
101+ fs .readFile = newAPI ;
101102
102103delete fs .readFileSync ;
103104
104- fs . newAPI = function newAPI () {
105+ function newAPI () {
105106 // ...
106- };
107+ }
108+
109+ fs .newAPI = newAPI;
107110
108111syncBuiltinESMExports ();
109112
110113import (' fs' ).then ((esmFS ) => {
111- assert .strictEqual (esmFS .readFile , null );
112- assert .strictEqual (' readFileSync' in fs, true );
114+ // It syncs the existing readFile property with the new value
115+ assert .strictEqual (esmFS .readFile , newAPI);
116+ // readFileSync has been deleted from the required fs
117+ assert .strictEqual (' readFileSync' in fs, false );
118+ // syncBuiltinESMExports() does not remove readFileSync from esmFS
119+ assert .strictEqual (' readFileSync' in esmFS, true );
120+ // syncBuiltinESMExports() does not add names
113121 assert .strictEqual (esmFS .newAPI , undefined );
114122});
115123` ` `
You can’t perform that action at this time.
0 commit comments