hydrogen icon indicating copy to clipboard operation
hydrogen copied to clipboard

cli-hydrogen overwrites vite customLogger

Open nik0kin opened this issue 1 year ago • 0 comments

What is the location of your example repository?

n/a

Which package or tool is having this issue?

CLI

What version of that package or tool are you using?

8.1.1

What version of Remix are you using?

2.9.2

Steps to Reproduce

  1. Add
const logger = createLogger();
const loggerWarn = logger.warn;

logger.warn = (msg, options) => {
  console.log('customLogger.warn has been run')

  if (msg.includes('message I want to ignore')) return;
  loggerWarn(msg, options);
};

to vite.config.ts

  1. Introduce code that vite would warn about

Expected Behavior

customLogger.warn has been run is outputted to console

I expect vite customLogger to work as described on vite docs

Actual Behavior

customLogger.warn has been run never is outputted


This occurs because this line overwrites the customLogger that was defined in vite.config.ts.

I suggest only defining customLogger parameter for vite.createServer() if process.env.SHOPIFY_UNIT_TEST is true, so a non customized logger is not passed otherwise

nik0kin avatar Jul 10 '24 19:07 nik0kin