Skip to content

Commit db42c50

Browse files
committed
Support sub mjs module (close #691)
1 parent 74f292f commit db42c50

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

server/build_helpers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ func (task *BuildTask) analyze(forceCjsOnly bool) (esm *ESMBuild, npm NpmPackage
219219
npm.Types = pkg.Submodule + ".d.ts"
220220
}
221221
} else {
222-
if npm.Type == "module" || npm.Module != "" {
222+
asMjs := path.Join(wd, "node_modules", npm.Name, pkg.Submodule+".mjs")
223+
if npm.Type == "module" || npm.Module != "" || fileExists(asMjs) {
223224
// follow main module type
224225
npm.Module = pkg.Submodule
225226
} else {

test/issue-691/issue-691.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.180.0/testing/asserts.ts";
2+
3+
import extractFiles from "http://localhost:8080/extract-files@12.0.0/extractFiles.mjs";
4+
5+
Deno.test("issue #691", () => {
6+
assertEquals(typeof extractFiles, "function");
7+
});

0 commit comments

Comments
 (0)