Skip to content

compilePackages: commander throws TypeError: undefined is not a constructor #5137

@proggeramlug

Description

@proggeramlug

Perry: origin/main @ a674b6e (v0.5.1167) · macOS arm64
Setup: package compiled natively via perry.compilePackages (perry.allow.compilePackages: ["*"])
Build/run: perry repro.ts -o out && ./out

(Found via an internal real-package stress run — importing the real package and exercising it.)

Bug

Importing commander and constructing/using new Command() throws TypeError: undefined is not a constructor.

Repro

import { Command } from 'commander';

const program = new Command();
program.name('demo').option('-v, --verbose').argument('<file>');
program.parse(['node', 'x', 'in.txt', '-v']);
console.log(program.args[0], JSON.stringify(program.opts()));

Expected (Node)

in.txt {"verbose":true}

Actual (Perry)

TypeError: undefined is not a constructor

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingparityNode.js compatibility / parity gaps

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions