Repository: deno
Issue: Panic shoehorn-importing aws-iot-device-sdk-js-v2
Labels: bug,deno_core,node compat

Trying to use the AWS IoT SDK, which is apparently written in TypeScript, and compiled during `npm install`. For Deno, how about importing the main file directly from the repo? There are several extension-less imports, so the import map is bit verbose:

```json
{
    "imports": {
        "@aws-sdk/util-utf8-browser": "npm:@aws-sdk/util-utf8-browser@3.109.0",
        "aws-crt": "npm:aws-crt@1.19.0",
        "aws-iot": "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/index.ts",
        "events": "node:events",
        "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/eventstream_rpc": "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/eventstream_rpc.ts",
        "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/eventstream_rpc_utils": "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/eventstream_rpc_utils.ts",
        "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/greengrass/model": "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/greengrass/model.ts",
        "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/greengrass/discoveryclient": "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/greengrass/discoveryclient.ts",
        "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/greengrasscoreipc":  "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/greengrasscoreipc.ts",
        "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/greengrasscoreipc/client": "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/greengrasscoreipc/client.ts",
        "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/greengrasscoreipc/model": "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/greengrasscoreipc/model.ts",
        "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/greengrasscoreipc/model_utils": "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/greengrasscoreipc/model_utils.ts",
        "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/iotidentity/iotidentityclient": "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/iotidentity/iotidentityclient.ts",
        "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/iotidentity/model": "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/iotidentity/model.ts",
        "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/iotjobs/iotjobsclient": "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/iotjobs/iotjobsclient.ts",
        "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/iotjobs/model":  "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/iotjobs/model.ts",
        "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/iotshadow/iotshadowclient": "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/iotshadow/iotshadowclient.ts",
        "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/iotshadow/model": "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/iotshadow/model.ts",
        "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/service_client_mqtt_adapter": "https://raw.githubusercontent.com/aws/aws-iot-device-sdk-js-v2/v1.17.0/lib/service_client_mqtt_adapter.ts",
        "util": "node:util"
    }
}
```
(Is there an import specifier to hint that the target URL is not strict Deno TypeScript with extensions in their descendant imports?)

Here's the index.js
```js
import { mqtt } from "aws-iot"

console.log('MQTT:', mqtt);
```

Which results in
```
Platform: linux x86_64
Version: 1.38.5
Args: ["deno", "run", "--allow-env", "--allow-read", "--allow-run", "--allow-ffi", "index.js"]

thread 'main' panicked at ext/node/global.rs:273:27:
already mutably borrowed: BorrowError
stack backtrace:
   0: rust_begin_unwind
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:597:5
   1: core::panicking::panic_fmt
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panicking.rs:72:14
   2: core::cell::panic_already_mutably_borrowed
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/cell.rs:770:5
   3: deno_node::global::current_mode
   4: deno_node::global::getter
   5: <extern "C" fn(A0,A1) .> R as v8::support::CFnFrom<F>>::mapping::c_fn
   6: _ZN2v88internal25PropertyCallbackArguments15CallNamedGetterENS0_6HandleINS0_15InterceptorInfoEEENS2_INS0_4NameEEE
             at ./../../../../v8/src/api/api-arguments-inl.h:147:3
   7: _ZN2v88internal12_GLOBAL__N_134GetPropertyWithInterceptorInternalEPNS0_14LookupIteratorENS0_6HandleINS0_15InterceptorInfoEEEPb
             at ./../../../../v8/src/objects/js-objects.cc:1258:19
   8: _ZN2v88internal6Object11GetPropertyEPNS0_14LookupIteratorEb
             at ./../../../../v8/src/objects/objects.cc:1201:9
   9: _ZN2v88internal7Runtime17GetObjectPropertyEPNS0_7IsolateENS0_6HandleINS0_6ObjectEEES6_S6_Pb
             at ./../../../../v8/src/runtime/runtime-object.cc:42:32
  10: _ZN2v86Object3GetENS_5LocalINS_7ContextEEENS1_INS_5ValueEEE
             at ./../../../../v8/src/api/api.cc:4704:8
  11: napi_get_named_property
  12: s_threadsafe_log_create
  13: aws_napi_logger_new
  14: napi_register_module_v1
  15: deno_napi::op_napi_open<NP>::v8_fn_ptr
  16: Builtins_CallApiCallbackGeneric
```

This could be one or more of
- a very specific case of "don't do that"
- a more general case
- the BorrowError should be fixed anyway