11import { promises as fs } from 'node:fs' ;
22import path from 'node:path' ;
33import { pathToFileURL } from 'node:url' ;
4- import util from 'node:util ' ;
4+ import chalk from 'chalk ' ;
55import { mergeConfig } from 'metro' ;
66import Server from 'metro/src/Server' ;
77import type { OutputOptions , RequestOptions } from 'metro/src/shared/types' ;
@@ -113,7 +113,7 @@ async function bundleFederatedRemote(
113113 const federationConfig = global . __METRO_FEDERATION_CONFIG ;
114114 if ( ! federationConfig ) {
115115 logger . error (
116- `${ util . styleText ( ' red' , 'error' ) } Module Federation configuration is missing.` ,
116+ `${ chalk . red ( 'error' ) } Module Federation configuration is missing.` ,
117117 ) ;
118118 logger . info (
119119 "Import the plugin 'withModuleFederation' " +
@@ -127,7 +127,7 @@ async function bundleFederatedRemote(
127127 const containerEntryFilepath = global . __METRO_FEDERATION_REMOTE_ENTRY_PATH ;
128128 if ( ! containerEntryFilepath ) {
129129 logger . error (
130- `${ util . styleText ( ' red' , 'error' ) } Cannot determine the container entry file path.` ,
130+ `${ chalk . red ( 'error' ) } Cannot determine the container entry file path.` ,
131131 ) ;
132132 logger . info (
133133 'To bundle a container, you need to expose at least one module ' +
@@ -140,21 +140,21 @@ async function bundleFederatedRemote(
140140 const manifestFilepath = global . __METRO_FEDERATION_MANIFEST_PATH ;
141141 if ( ! manifestFilepath ) {
142142 logger . error (
143- `${ util . styleText ( ' red' , 'error' ) } Cannot determine the manifest file path.` ,
143+ `${ chalk . red ( 'error' ) } Cannot determine the manifest file path.` ,
144144 ) ;
145145 throw new CLIError ( 'Bundling failed' ) ;
146146 }
147147
148148 if ( rawConfig . resolver . platforms . indexOf ( args . platform ) === - 1 ) {
149149 logger . error (
150- `${ util . styleText ( ' red' , 'error' ) } : Invalid platform ${
151- args . platform ? `"${ util . styleText ( ' bold' , args . platform ) } " ` : ''
150+ `${ chalk . red ( 'error' ) } : Invalid platform ${
151+ args . platform ? `"${ chalk . bold ( args . platform ) } " ` : ''
152152 } selected.`,
153153 ) ;
154154
155155 logger . info (
156156 `Available platforms are: ${ rawConfig . resolver . platforms
157- . map ( ( x ) => `"${ util . styleText ( ' bold' , x ) } "` )
157+ . map ( ( x ) => `"${ chalk . bold ( x ) } "` )
158158 . join (
159159 ', ' ,
160160 ) } . If you are trying to bundle for an out-of-tree platform, it may not be installed.`,
@@ -314,7 +314,7 @@ async function bundleFederatedRemote(
314314
315315 try {
316316 logger . info (
317- `${ util . styleText ( ' blue' , 'Processing remote container and exposed modules' ) } ` ,
317+ `${ chalk . blue ( 'Processing remote container and exposed modules' ) } ` ,
318318 ) ;
319319
320320 for ( const { requestOpts, saveBundleOpts, targetDir } of requests ) {
@@ -338,11 +338,11 @@ async function bundleFederatedRemote(
338338 // );
339339 }
340340
341- logger . info ( `${ util . styleText ( ' blue' , 'Processing manifest' ) } ` ) ;
341+ logger . info ( `${ chalk . blue ( 'Processing manifest' ) } ` ) ;
342342 const manifestOutputFilepath = path . resolve ( outputDir , 'mf-manifest.json' ) ;
343343 await fs . copyFile ( manifestFilepath , manifestOutputFilepath ) ;
344344 logger . info (
345- `Done writing MF Manifest to:\n${ util . styleText ( ' dim' , manifestOutputFilepath ) } ` ,
345+ `Done writing MF Manifest to:\n${ chalk . dim ( manifestOutputFilepath ) } ` ,
346346 ) ;
347347 } finally {
348348 // incomplete types - this should be awaited
0 commit comments