File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed
Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -84,16 +84,13 @@ function underNodeModules(url) {
8484
8585/**
8686 * Determine whether the given source contains CJS or ESM module syntax.
87- * @param {string } source
87+ * @param {string | Buffer | undefined } source
8888 * @param {URL } url
8989 */
9090function detectModuleFormat ( source , url ) {
91- try {
92- return containsModuleSyntax ( source , fileURLToPath ( url ) , url ) ? 'module' : 'commonjs' ;
93- } catch {
94- // containsModuleSyntax throws if source is undefined and the passed filename cannot be read
95- // Return undefined so that the load hook can determine the format
96- }
91+ const moduleSource = source ? `${ source } ` : undefined ;
92+ const modulePath = fileURLToPath ( url ) ;
93+ return containsModuleSyntax ( moduleSource , modulePath , url ) ? 'module' : 'commonjs'
9794}
9895
9996let typelessPackageJsonFilesWarnedAbout ;
You can’t perform that action at this time.
0 commit comments