Skip to content

Commit a546b8b

Browse files
committed
Fix dep import url of cjs module (close #592)
1 parent aacd8f1 commit a546b8b

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

server/build.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,11 @@ rebuild:
773773
}
774774
// if the dep is an es6 module
775775
if !marked && depNpm.Module != "" {
776-
cjsImportNames.Add("*?")
776+
if depESM.HasExportDefault && len(depESM.NamedExports) == 1 {
777+
cjsImportNames.Add("default")
778+
} else {
779+
cjsImportNames.Add("*?")
780+
}
777781
marked = true
778782
}
779783
if !marked && includes(depESM.NamedExports, "__esModule") && depESM.HasExportDefault {

test/issue-592/issue-592.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { assertEquals } from "https://deno.land/std@0.178.0/testing/asserts.ts";
2+
3+
import { createConnection } from "http://localhost:8080/mysql2@3.2.0";
4+
5+
Deno.test("issue #592", async () => {
6+
assertEquals(typeof createConnection, "function");
7+
});

0 commit comments

Comments
 (0)