Skip to content

Support v20.x as an external loader #344

@legendecas

Description

@legendecas

When use node --import=amaro/strip index.ts in Node.js v20.x, it still reports that .ts extension is not supported.

It will be great that if amaro can be used in v20.x as an external loader to support type stripping.

node:internal/modules/run_main:123
    triggerUncaughtException(
    ^
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /workspace/nodejs/node-api-cts/implementors/node/run-tests.ts
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:189:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:232:36)
    at defaultLoad (node:internal/modules/esm/load:145:22)
    at async nextLoad (node:internal/modules/esm/hooks:864:22)
    at async nextLoad (node:internal/modules/esm/hooks:864:22)
    at async Hooks.load (node:internal/modules/esm/hooks:451:20)
    at async MessagePort.handleMessage (node:internal/modules/esm/worker:196:18) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

I have to add a bridge loader to achieve this: https://github.com/nodejs/node-api-cts/blob/main/tools/loader.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions