1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

fix: do not panic running remote cjs module (#26259)

Instead error.
This commit is contained in:
David Sherret 2024-10-14 23:57:31 -04:00 committed by GitHub
parent 7f3747f2ef
commit ae6a2b23ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13 additions and 1 deletions

View file

@ -552,7 +552,8 @@ impl CliMainWorkerFactory {
.await?;
self.shared.cjs_resolution_store.is_known_cjs(&main_module)
} else {
specifier_has_extension(&main_module, "cjs")
main_module.scheme() == "file"
&& specifier_has_extension(&main_module, "cjs")
};
(main_module, is_cjs)
};

View file

@ -0,0 +1,5 @@
{
"args": "run http://localhost:4545/run/add.cjs",
"output": "output.out",
"exitCode": 1
}

View file

@ -0,0 +1,3 @@
Download http://localhost:4545/run/add.cjs
error: Expected a JavaScript or TypeScript module, but identified a Cjs module. Importing these types of modules is currently not supported.
Specifier: http://localhost:4545/run/add.cjs

3
tests/testdata/run/add.cjs vendored Normal file
View file

@ -0,0 +1,3 @@
module.exports.add = function (a, b) {
return a + b;
};