esm: synchronise default path of ModuleLoader.load#57390
esm: synchronise default path of ModuleLoader.load#57390JakobJingleheimer wants to merge 2 commits intomainfrom
ModuleLoader.load#57390Conversation
|
Review requested:
|
| if (format == null) { | ||
| // Now that we have the source for the module, run `defaultGetFormat` to detect its format. | ||
| format = await defaultGetFormat(urlInstance, context); | ||
| format = defaultGetFormat(urlInstance, context); |
There was a problem hiding this comment.
defaultGetFormat is already sync
ModuleLoaderModuleLoader.load
ModuleLoader.loadModuleLoader.load
| if (protocol === 'file:') { | ||
| const { readFile: readFileAsync } = require('internal/fs/promises').exports; | ||
| source = await readFileAsync(url); | ||
| source = readFileSync(url); |
There was a problem hiding this comment.
This converts to a blocking op, but I'm not sure if that matters.
There was a problem hiding this comment.
The CommonJS loadSource uses readFileSync:
node/lib/internal/modules/cjs/loader.js
Line 1128 in fbe37d5
though CommonJS is fundamentally sync. I think it should be fine to use the same in ESM; @joyeecheung or anyone else, do you have any concerns?
There was a problem hiding this comment.
Blocking fs is generally not problematic when your fs is fast enough (and not taking on the async overhead might make it faster, as nodejs/performance#151 shows).
GeoffreyBooth
left a comment
There was a problem hiding this comment.
+1 to the effort. Tracking issue: #55782
We should also find some benchmarks that measure the performance impact of the overall syncification effort. Perhaps the existing ESM benchmarks are sufficient?
| if (protocol === 'file:') { | ||
| const { readFile: readFileAsync } = require('internal/fs/promises').exports; | ||
| source = await readFileAsync(url); | ||
| source = readFileSync(url); |
There was a problem hiding this comment.
The CommonJS loadSource uses readFileSync:
node/lib/internal/modules/cjs/loader.js
Line 1128 in fbe37d5
though CommonJS is fundamentally sync. I think it should be fine to use the same in ESM; @joyeecheung or anyone else, do you have any concerns?
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #57390 +/- ##
==========================================
- Coverage 90.23% 90.11% -0.12%
==========================================
Files 630 630
Lines 185200 185193 -7
Branches 36233 36165 -68
==========================================
- Hits 167108 166882 -226
- Misses 11056 11239 +183
- Partials 7036 7072 +36
🚀 New features to boost your workflow:
|
|
This PR got created wrong, so I had to create a new one to update it: #57419 Apologies for the noise 😞 |
No description provided.