From 4c28925783a0dca3bb0f08a80293a4f7cc55e197 Mon Sep 17 00:00:00 2001 From: AgentEnder Date: Wed, 6 Sep 2023 17:25:00 -0400 Subject: [PATCH] fix(core): prettier 3 shouldn't cause errors due to esm + compile cache --- packages/nx/bin/nx.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/nx/bin/nx.ts b/packages/nx/bin/nx.ts index 8755ad02ae3b1a..2569c2aaa16fda 100644 --- a/packages/nx/bin/nx.ts +++ b/packages/nx/bin/nx.ts @@ -51,7 +51,15 @@ function main() { process.env.NX_DAEMON = 'false'; require('nx/src/command-line/nx-commands').commandsObject.argv; } else { - if (workspace && workspace.type === 'nx') { + if ( + workspace && + // Angular CLI uses ESM, which v8-compile-cache doesn't work with. + workspace.type === 'nx' && + // These commands invoke Prettier, which uses ESM and fails with v8-compile-cache + !['format', 'format:check', 'format:write', 'g', 'generate'].some( + (cmd) => process.argv[3] === cmd + ) + ) { require('v8-compile-cache'); } // polyfill rxjs observable to avoid issues with multiple version of Observable installed in node_modules