From 6c86dba0391aec9240341d3f9a6f168fe36078fc Mon Sep 17 00:00:00 2001 From: shiftj18 Date: Wed, 16 Aug 2023 20:07:12 +0800 Subject: [PATCH] fix(rax-app): debug() run as needed and optimizing stringify (#1029) * fix(rax-app): debug() run as needed and replace JSON.stringify with util.inspect for circular * docs(rax-app): change version, readme and comment --- packages/plugin-rax-app/CHANGELOG.md | 3 +++ packages/plugin-rax-app/package.json | 2 +- .../plugin-rax-app/src/utils/logWebpackConfig.ts | 16 ++++++---------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/plugin-rax-app/CHANGELOG.md b/packages/plugin-rax-app/CHANGELOG.md index b2ec0e32b..23efe29e9 100644 --- a/packages/plugin-rax-app/CHANGELOG.md +++ b/packages/plugin-rax-app/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 7.0.14 +- Fix: change `debug(JSON.stringify(configs, ...))` to run only in debug mode, and modify the implement of `stringify` that will cause Node16 Crash when `configs` has many circular reference in `logWebpackConfig.js` + ## 7.0.12 - Feat: breaking change for `rax-webpack-config` to update `postcss-loader` diff --git a/packages/plugin-rax-app/package.json b/packages/plugin-rax-app/package.json index ed3908c4d..e0890e9b3 100644 --- a/packages/plugin-rax-app/package.json +++ b/packages/plugin-rax-app/package.json @@ -1,6 +1,6 @@ { "name": "build-plugin-rax-app", - "version": "7.0.13", + "version": "7.0.14", "description": "The basic webpack configuration for rax project", "author": "Rax Team", "main": "lib/index.js", diff --git a/packages/plugin-rax-app/src/utils/logWebpackConfig.ts b/packages/plugin-rax-app/src/utils/logWebpackConfig.ts index 87378bf38..94d6b6625 100644 --- a/packages/plugin-rax-app/src/utils/logWebpackConfig.ts +++ b/packages/plugin-rax-app/src/utils/logWebpackConfig.ts @@ -1,19 +1,15 @@ import debugCore from 'debug'; +import { inspect } from 'util'; const debug = debugCore('rax-app'); export default (configs) => { try { - const tmp = []; - debug(JSON.stringify(configs, (key, val) => { - if (val != null && typeof val === 'object') { - if (tmp.indexOf(val) >= 0) { - return; - } - tmp.push(val); - } - return val; - }, 2)); + // Only executed when the debug mode is turned on + if (debug.enabled) { + // Print webpack configs for easy debugging + debug(inspect(configs, { depth: 10, colors: true })); + } } catch (error) { // ignore error }