Skip to content

Bug when using tsm with chalk 5.0.0 #31

Closed
@leonsilicon

Description

@leonsilicon

First of all, thanks for this amazing project!

I noticed that tsm fails to import dependencies from chalk 5, giving the following error:

(node:41021) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:41021) DeprecationWarning: Obsolete loader hook(s) supplied and will be ignored: getFormat, transformSource
file:///Users/leonzalion/projects/tsm-bug/node_modules/.pnpm/chalk@5.0.0/node_modules/chalk/source/index.js#supports-color.mts:26
const { stdout: stdoutColor, stderr: stderrColor } = supportsColor;
                ^

TypeError: Cannot destructure property 'stdout' of 'supportsColor' as it is undefined.
    at file:///Users/leonzalion/projects/tsm-bug/node_modules/.pnpm/chalk@5.0.0/node_modules/chalk/source/index.js#supports-color.mts:26:17
    at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:281:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12)

It seems like the chalk supportsColor import is becoming undefined, and I believe it has something to do with how chalk imports its dependencies:

import ansiStyles from '#ansi-styles';
import supportsColor from '#supports-color';

Here is a GitHub repo that reproduces this error: https://github.com/leonzalion/tsm-bug
Node version: 16.13.2

Let me know if this is a tsm bug and/or if there's a workaround to this issue!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions