Skip to content

Commit

Permalink
review findings
Browse files Browse the repository at this point in the history
  • Loading branch information
dygabo committed May 26, 2024
1 parent 7b99eee commit 3b4caab
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions lib/internal/modules/esm/get_format.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,7 @@ function underNodeModules(url) {
*/
function detectModuleFormat(source, url) {
try {
let realSource = source ?? readFileSync(url, 'utf8');
if (Buffer.isBuffer(realSource)) {
// `containsModuleSyntax` requires source to be passed in as string
realSource = realSource.toString();
}
return containsModuleSyntax(realSource, fileURLToPath(url), url) ? 'module' : 'commonjs';
return containsModuleSyntax(source ?? readFileSync(url, 'utf8'), fileURLToPath(url), url) ? 'module' : 'commonjs';
} catch {
return 'commonjs';
}
Expand Down

0 comments on commit 3b4caab

Please sign in to comment.