diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-10-14 23:57:31 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-15 03:57:31 +0000 |
commit | ae6a2b23bae83795bd973414216a89c839dd8fda (patch) | |
tree | 648bc0f65e9fa41de5f75188f87473d37912f291 | |
parent | 7f3747f2ef7cc9e1d45aa33360afdfe62cd20c56 (diff) |
fix: do not panic running remote cjs module (#26259)
Instead error.
-rw-r--r-- | cli/worker.rs | 3 | ||||
-rw-r--r-- | tests/specs/run/remote_cjs_main/__test__.jsonc | 5 | ||||
-rw-r--r-- | tests/specs/run/remote_cjs_main/output.out | 3 | ||||
-rw-r--r-- | tests/testdata/run/add.cjs | 3 |
4 files changed, 13 insertions, 1 deletions
diff --git a/cli/worker.rs b/cli/worker.rs index 489b2dd93..e230197d2 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -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) }; diff --git a/tests/specs/run/remote_cjs_main/__test__.jsonc b/tests/specs/run/remote_cjs_main/__test__.jsonc new file mode 100644 index 000000000..f45d09406 --- /dev/null +++ b/tests/specs/run/remote_cjs_main/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run http://localhost:4545/run/add.cjs", + "output": "output.out", + "exitCode": 1 +} diff --git a/tests/specs/run/remote_cjs_main/output.out b/tests/specs/run/remote_cjs_main/output.out new file mode 100644 index 000000000..f75c33907 --- /dev/null +++ b/tests/specs/run/remote_cjs_main/output.out @@ -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 diff --git a/tests/testdata/run/add.cjs b/tests/testdata/run/add.cjs new file mode 100644 index 000000000..2a886fbc1 --- /dev/null +++ b/tests/testdata/run/add.cjs @@ -0,0 +1,3 @@ +module.exports.add = function (a, b) { + return a + b; +}; |