Skip to content

compiled-package instance methods not callable (dayjs.format, chalk.green) — prototype-method dispatch gap #838

Description

@proggeramlug

Surfaced by the #805 npm sweep harness (tier1 list, two distinct packages hit the same shape).

Repro 1 — dayjs

```ts
import dayjs from "dayjs";
const d = dayjs("2024-01-02");
console.log("d:", typeof d); // object ✓
console.log("d.format:", typeof (d as any).format); // undefined ✗ (Node: function)
```

Repro 2 — chalk

```ts
import chalk from "chalk";
console.log("chalk:", typeof chalk); // function (Node: object/proxy)
console.log("chalk.green:", typeof (chalk as any).green); // throws "value is not a function"
```

Both packages succeed at compile + link under `perry.compilePackages` but the instance / static surface that's assigned via JS-classic patterns (`Dayjs.prototype.format = ...`, chalk's Proxy-wrapped function instance) is empty at runtime.

Why this matters

This blocks a whole class of npm packages — anything that:

  • assigns methods to a class prototype outside the `class { ... }` syntax (the JS-classic pattern), or
  • exports a callable that also has properties (chalk, express, ms-as-function-with-props, …)

The `Dayjs.prototype.format = function(){...}` pattern is the obvious test case. Once that lands, chalk's shape (`Function & { green, red, ... }`) is the harder follow-up — it likely needs Proxy/callable-object support in the compiled-package codegen.

Status against existing trackers

Probably the same family as #618 (IIFE-namespace function-static properties) but the call site is now "npm-installed package, not user code," so the surface is much larger. Not a duplicate — keeping this open so the sweep CSV has a single ticket to point at when dayjs/chalk move from `run-fail` to `pass`.

Part of #793 + #805 + #115. Surfaced by the #805 sweep.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed defect or regressionparityCompatibility gap with Node.js, ECMAScript, or the supported ecosystem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions