Skip to content

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

Closed

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.

Activity

  1. added
    bugConfirmed defect or regression
    parityCompatibility gap with Node.js, ECMAScript, or the supported ecosystem
    on May 16, 2026
  2. added 6 commits that reference this issue on May 17, 2026
    f818019
    06faac5
    b9104ba
    fbcf825
    2033e07
    31d4c31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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