Skip to content

Issue with ESM directory imports #2

@irinanazarova

Description

@irinanazarova

Bug: The published ESM package uses bare directory imports (export { broadcaster } from './broadcast') in dist/index.js. Node.js ESM requires explicit file extensions — these should be './broadcast/index.js'.

Root cause: tsconfig.json has "moduleResolution": "node" + "module": "ESNext". TypeScript resolves './rpc' → ./rpc/index.ts during compilation but doesn't rewrite the specifier in the output. Node.js ESM then fails with ERR_UNSUPPORTED_DIR_IMPORT.

Fix: Change to "moduleResolution": "nodenext" and add .js extensions to all relative imports in the source, or use a bundler like tsup to produce a single-file ESM output.

Reproduction: Import @anycable/serverless-js in any "type": "module" project and run it with Node.js (not bundled) — e.g., Netlify Functions, AWS Lambda ESM, or plain node --experimental-vm-modules.

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