Skip to content

Commit

Permalink
Fix dep import url of cjs module (close #592)
Browse files Browse the repository at this point in the history
  • Loading branch information
ije committed Apr 17, 2023
1 parent aacd8f1 commit a546b8b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,11 @@ rebuild:
}
// if the dep is an es6 module
if !marked && depNpm.Module != "" {
cjsImportNames.Add("*?")
if depESM.HasExportDefault && len(depESM.NamedExports) == 1 {
cjsImportNames.Add("default")
} else {
cjsImportNames.Add("*?")
}
marked = true
}
if !marked && includes(depESM.NamedExports, "__esModule") && depESM.HasExportDefault {
Expand Down
7 changes: 7 additions & 0 deletions test/issue-592/issue-592.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";

import { createConnection } from "http://localhost:8080/[email protected]";

Deno.test("issue #592", async () => {
assertEquals(typeof createConnection, "function");
});

0 comments on commit a546b8b

Please sign in to comment.