From e2f5eaabb5599e5f6ba04ffa2e830142f44bd139 Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Tue, 5 Nov 2024 17:13:54 +0800 Subject: [PATCH] cleanup(webpack): migrate to picocolors (#28315) --- packages/webpack/.eslintrc.json | 10 +++++++++- packages/webpack/package.json | 2 +- .../executors/ssr-dev-server/ssr-dev-server.impl.ts | 4 ++-- .../utils/module-federation/get-remotes-for-host.ts | 4 ++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/webpack/.eslintrc.json b/packages/webpack/.eslintrc.json index 4dab6d17bba4d..3ab9b5dd4f79c 100644 --- a/packages/webpack/.eslintrc.json +++ b/packages/webpack/.eslintrc.json @@ -4,7 +4,15 @@ "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} + "rules": { + "no-restricted-imports": [ + "error", + { + "name": "chalk", + "message": "Please use `picocolors` in place of `chalk` for rendering terminal colors" + } + ] + } }, { "files": ["*.ts", "*.tsx"], diff --git a/packages/webpack/package.json b/packages/webpack/package.json index 88adbe2e2a519..4694258232bb5 100644 --- a/packages/webpack/package.json +++ b/packages/webpack/package.json @@ -38,7 +38,7 @@ "autoprefixer": "^10.4.9", "babel-loader": "^9.1.2", "browserslist": "^4.21.4", - "chalk": "^4.1.0", + "picocolors": "^1.1.0", "copy-webpack-plugin": "^10.2.4", "css-loader": "^6.4.0", "css-minimizer-webpack-plugin": "^5.0.0", diff --git a/packages/webpack/src/executors/ssr-dev-server/ssr-dev-server.impl.ts b/packages/webpack/src/executors/ssr-dev-server/ssr-dev-server.impl.ts index fdd484c1d7d6e..2749f131fed3c 100644 --- a/packages/webpack/src/executors/ssr-dev-server/ssr-dev-server.impl.ts +++ b/packages/webpack/src/executors/ssr-dev-server/ssr-dev-server.impl.ts @@ -4,7 +4,7 @@ import { readTargetOptions, runExecutor, } from '@nx/devkit'; -import * as chalk from 'chalk'; +import * as pc from 'picocolors'; import { combineAsyncIterables } from '@nx/devkit/src/utils/async-iterable'; import { WebpackExecutorOptions } from '../webpack/schema'; @@ -62,7 +62,7 @@ export async function* ssrDevServerExecutor( if (nodeStarted && browserBuilt) { await waitUntilServerIsListening(options.port); console.log( - `[ ${chalk.green('ready')} ] on http://localhost:${options.port}` + `[ ${pc.green('ready')} ] on http://localhost:${options.port}` ); yield { ...output, diff --git a/packages/webpack/src/utils/module-federation/get-remotes-for-host.ts b/packages/webpack/src/utils/module-federation/get-remotes-for-host.ts index c2506e49c8973..7e7bb129a7187 100644 --- a/packages/webpack/src/utils/module-federation/get-remotes-for-host.ts +++ b/packages/webpack/src/utils/module-federation/get-remotes-for-host.ts @@ -1,7 +1,7 @@ import { logger, type ProjectGraph } from '@nx/devkit'; import { registerTsProject } from '@nx/js/src/internal'; import { findMatchingProjects } from 'nx/src/utils/find-matching-projects'; -import * as chalk from 'chalk'; +import * as pc from 'picocolors'; import { join } from 'path'; import { existsSync, readFileSync } from 'fs'; import { ModuleFederationConfig } from './models/index'; @@ -107,7 +107,7 @@ export function getRemotes( ); logger.info( - `NX Starting module federation dev-server for ${chalk.bold( + `NX Starting module federation dev-server for ${pc.bold( context.projectName )} with ${[...knownRemotes, ...knownDynamicRemotes].length} remotes` );