Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug when using tsm with chalk 5.0.0 #31

Closed
leonsilicon opened this issue Jan 15, 2022 · 6 comments
Closed

Bug when using tsm with chalk 5.0.0 #31

leonsilicon opened this issue Jan 15, 2022 · 6 comments

Comments

@leonsilicon
Copy link

leonsilicon commented Jan 15, 2022

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!

@GuilleDF
Copy link

I'm getting the same issue when using https://github.com/sindresorhus/ora since it has chalk as a dependency

@btakita
Copy link

btakita commented May 16, 2022

Also getting this issue. I used a package.json pnpm.override to "chalk": "4.1.2" to work around this problem.

@BasixKOR
Copy link

BasixKOR commented Jun 9, 2022

It seems like tsm doesn't support subpath imports yet?

@azat-io
Copy link

azat-io commented Oct 6, 2022

Same issue

@karlhorky
Copy link

karlhorky commented Nov 21, 2022

Created a Replit for this here:

https://replit.com/@karlhorky/tsm-chalk-5-example#package.json

This confirms that the problem is also present with an updated esbuild@0.14.54, which is the latest version of esbuild matching tsm's semver range:

"esbuild": "^0.14.0"

@azat-io
Copy link

azat-io commented Nov 28, 2022

Same error with tsm v2.3.0

(node:42830) ExperimentalWarning: Custom ESM Loaders is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:42830) DeprecationWarning: Obsolete loader hook(s) supplied and will be ignored: getFormat, transformSource
/Users/user/Developer/azat-io/node_modules/.pnpm/chalk@5.1.2/node_modules/chalk/source/index.js:8
const {stdout: stdoutColor, stderr: stderrColor} = supportsColor;
               ^


TypeError: Cannot destructure property 'stdout' of 'supportsColor' as it is undefined.
    at <anonymous> (/Users/user/Developer/azat-io/node_modules/.pnpm/chalk@5.1.2/node_modules/chalk/source/index.js:8:16)
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v19.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants