From 5c30d1b95ac0d2cf0daeb94d80d3050d3648b10c Mon Sep 17 00:00:00 2001 From: Jack Hsu Date: Thu, 17 Apr 2025 09:08:45 -0400 Subject: [PATCH] chore(repo): remove vite paths plugin from our own Storybook files (#30756) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR fixes an issue that blocks FreeBSD release for some reason. When we use the `@nx/vite/plugins/nx-tsconfig-paths.plugin` plugin and both `CI=1` and `NX_PREFER_TS_NODE=true` are set, then the graph fails to compute. For example, running this will error out: ```shell CI=1 NX_DAEMON=false NX_CACHE_PROJECT_GRAPH=false NX_PREFER_TS_NODE=true nx report ``` The error is like this: ```shell ⚠️ Unable to construct project graph. Failed to process project graph. - graph/migrate/.storybook/main.ts: TypeError: Cannot set property level of [object Object] which has only a getter at Object. (/Users/jack/projects/nx/packages/nx/src/utils/output.ts:38:23) at Module._compile (node:internal/modules/cjs/loader:1554:14) at Module.m._compile (/Users/jack/projects/nx/node_modules/.pnpm/ts-node@10.9.1_@swc+core@1.5.7_@swc+helpers@0.5.11__@types+node@20.16.10_typescript@5.7.3/node_modules/ts-node/src/index.ts:1618:23) at node:internal/modules/cjs/loader:1706:10 at Object.require.extensions. [as .ts] (/Users/jack/projects/nx/node_modules/.pnpm/ts-node@10.9.1_@swc+core@1.5.7_@swc+helpers@0.5.11__@types+node@20.16.10_typescript@5.7.3/node_modules/ts-node/src/index.ts:1621:12) at Module.load (node:internal/modules/cjs/loader:1289:32) at Function._load (node:internal/modules/cjs/loader:1108:12) at TracingChannel.traceSync (node:diagnostics_channel:322:14) at wrapModuleLoad (node:internal/modules/cjs/loader:220:24) at Module.require (node:internal/modules/cjs/loader:1311:12) - graph/ui-code-block/.storybook/main.ts: TypeError: Cannot set property level of [object Object] which has only a getter at Object. (/Users/jack/projects/nx/packages/nx/src/utils/output.ts:38:23) at Module._compile (node:internal/modules/cjs/loader:1554:14) at Module.m._compile (/Users/jack/projects/nx/node_modules/.pnpm/ts-node@10.9.1_@swc+core@1.5.7_@swc+helpers@0.5.11__@types+node@20.16.10_typescript@5.7.3/node_modules/ts-node/src/index.ts:1618:23) at node:internal/modules/cjs/loader:1706:10 at Object.require.extensions. [as .ts] (/Users/jack/projects/nx/node_modules/.pnpm/ts-node@10.9.1_@swc+core@1.5.7_@swc+helpers@0.5.11__@types+node@20.16.10_typescript@5.7.3/node_modules/ts-node/src/index.ts:1621:12) at Module.load (node:internal/modules/cjs/loader:1289:32) at Function._load (node:internal/modules/cjs/loader:1108:12) at TracingChannel.traceSync (node:diagnostics_channel:322:14) at wrapModuleLoad (node:internal/modules/cjs/loader:220:24) at Module.require (node:internal/modules/cjs/loader:1311:12) - graph/ui-project-details/.storybook/main.ts: TypeError: Cannot set property level of [object Object] which has only a getter at Object. (/Users/jack/projects/nx/packages/nx/src/utils/output.ts:38:23) at Module._compile (node:internal/modules/cjs/loader:1554:14) at Module.m._compile (/Users/jack/projects/nx/node_modules/.pnpm/ts-node@10.9.1_@swc+core@1.5.7_@swc+helpers@0.5.11__@types+node@20.16.10_typescript@5.7.3/node_modules/ts-node/src/index.ts:1618:23) at node:internal/modules/cjs/loader:1706:10 at Object.require.extensions. [as .ts] (/Users/jack/projects/nx/node_modules/.pnpm/ts-node@10.9.1_@swc+core@1.5.7_@swc+helpers@0.5.11__@types+node@20.16.10_typescript@5.7.3/node_modules/ts-node/src/index.ts:1621:12) at Module.load (node:internal/modules/cjs/loader:1289:32) at Function._load (node:internal/modules/cjs/loader:1108:12) at TracingChannel.traceSync (node:diagnostics_channel:322:14) at wrapModuleLoad (node:internal/modules/cjs/loader:220:24) at Module.require (node:internal/modules/cjs/loader:1311:12) ``` This is an issue for us only because we are pointing `@nx/vite/plugins/nx-tsconfig-paths.plugin` to source. Normally, this would already be in JS, and not need to go through `ts-node` or SWC. I'm unsure what the exact cause is. There was nothing obvious in how we register `ts-node`, and nothing in `ts-node` to suggest different behavior with `CI=1`. ## Current Behavior FreeBSD release is blocked See: https://github.com/nrwl/nx/actions/runs/14500499978/job/40678818950 ## Expected Behavior FreeBSD release works ## Related Issue(s) Fixes # --- graph/migrate/.storybook/main.ts | 5 +---- graph/ui-code-block/.storybook/main.ts | 4 +--- graph/ui-project-details/.storybook/main.ts | 5 +---- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/graph/migrate/.storybook/main.ts b/graph/migrate/.storybook/main.ts index cfdbf33b53..ce90477479 100644 --- a/graph/migrate/.storybook/main.ts +++ b/graph/migrate/.storybook/main.ts @@ -1,8 +1,5 @@ /* eslint-disable @nx/enforce-module-boundaries */ import type { StorybookConfig } from '@storybook/react-vite'; - -// nx-ignore-next-line -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; import { mergeConfig } from 'vite'; const config: StorybookConfig = { @@ -16,7 +13,7 @@ const config: StorybookConfig = { viteFinal: async (config) => mergeConfig(config, { - plugins: [nxViteTsPaths()], + plugins: [], }), docs: {}, diff --git a/graph/ui-code-block/.storybook/main.ts b/graph/ui-code-block/.storybook/main.ts index 075ebe3211..a4718d529b 100644 --- a/graph/ui-code-block/.storybook/main.ts +++ b/graph/ui-code-block/.storybook/main.ts @@ -1,8 +1,6 @@ /* eslint-disable @nx/enforce-module-boundaries */ import type { StorybookConfig } from '@storybook/react-vite'; import { mergeConfig } from 'vite'; -// nx-ignore-next-line -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; const config: StorybookConfig = { stories: ['../src/lib/**/*.stories.@(js|jsx|ts|tsx|mdx)'], @@ -15,7 +13,7 @@ const config: StorybookConfig = { viteFinal: async (config) => mergeConfig(config, { - plugins: [nxViteTsPaths()], + plugins: [], }), }; diff --git a/graph/ui-project-details/.storybook/main.ts b/graph/ui-project-details/.storybook/main.ts index fc7261d06c..173cdb4d82 100644 --- a/graph/ui-project-details/.storybook/main.ts +++ b/graph/ui-project-details/.storybook/main.ts @@ -1,8 +1,5 @@ /* eslint-disable @nx/enforce-module-boundaries */ import type { StorybookConfig } from '@storybook/react-vite'; - -// nx-ignore-next-line -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; import { mergeConfig } from 'vite'; const config: StorybookConfig = { @@ -16,7 +13,7 @@ const config: StorybookConfig = { viteFinal: async (config) => mergeConfig(config, { - plugins: [nxViteTsPaths()], + plugins: [], }), docs: {},