nx icon indicating copy to clipboard operation
nx copied to clipboard

@nx/rollup/plugin can’t resolve tsconfig.json

Open drwpow opened this issue 1 year ago • 0 comments

Current Behavior

Given the following rollup.config.js in a monorepo (simplified):

// packages/react-color-picker/rollup.config.json

import ts from '@rollup/plugin-typescript';

/** @type {import("rollup").InputOptions} */
export default {
  plugins: [
    ts({
      tsconfig: './tsconfig.build.json',
    }),
  ]
};

Trying to run @nx/rollup/plugin results in the following error:

 NX   Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it. See errors below.

Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.
      An error occurred while processing files for the @nx/rollup/plugin plugin.
    - packages/react-color-picker/rollup.config.js: Could not find specified tsconfig.json at /Users/drew/Sites/terrazzoapp/terrazzo/tsconfig.build.json
      Error: Could not find specified tsconfig.json at /Users/drew/Sites/terrazzoapp/terrazzo/tsconfig.build.json
          at getTsConfigPath (file:///Users/drew/Sites/terrazzoapp/terrazzo/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@rollup/plugin-typescript/dist/es/index.js:244:19)
          at parseTypescriptConfig (file:///Users/drew/Sites/terrazzoapp/terrazzo/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@rollup/plugin-typescript/dist/es/index.js:318:26)
          at typescript (file:///Users/drew/Sites/terrazzoapp/terrazzo/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@rollup/plugin-typescript/dist/es/index.js:754:27)
          at file:///Users/drew/Sites/terrazzoapp/terrazzo/packages/react-color-picker/rollup.config.js?1728965200242:12:5
          at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
          at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:483:26)
          at async getConfigFileExport (/Users/drew/Sites/terrazzoapp/terrazzo/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/shared/loadConfigFile.js:471:17)
          at async loadConfigFile (/Users/drew/Sites/terrazzoapp/terrazzo/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/shared/loadConfigFile.js:430:59)
          at async buildRollupTarget (/Users/drew/Sites/terrazzoapp/terrazzo/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@[email protected]_@[email protected]_ffvo47yijgt2k62ikoudbwsnj4/node_modules/@nx/rollup/src/plugins/plugin.js:70:27)
          at async exports.createNodes (/Users/drew/Sites/terrazzoapp/terrazzo/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@[email protected]_@[email protected]_ffvo47yijgt2k62ikoudbwsnj4/node_modules/@nx/rollup/src/plugins/plugin.js:41:32)

Basically it’s looking for [projectRoot]/tsconfig.base.json when it should be looking for /packages/react-color-picker/tsconfig.base.json

Expected Behavior

Rollup plugins resolve relative to rollup.config.js, rather than cwd or project root

GitHub Repo

https://github.com/terrazzoapp/terrazzo/pull/317/

Steps to Reproduce

  1. Checkout nx branch
  2. Run pnpm i
  3. Run pnpm run build

(search for rollup.config.js files)

Nx Report

 NX   Report complete - copy this into the issue template

Node           : 22.9.0
OS             : darwin-arm64
Native Target  : aarch64-macos
pnpm           : 9.12.1

nx             : 20.0.0
@nx/js         : 20.0.0
@nx/eslint     : 20.0.0
@nx/workspace  : 20.0.0
@nx/cypress    : 20.0.0
@nx/devkit     : 20.0.0
@nx/rollup     : 20.0.0
@nx/storybook  : 20.0.0
@nx/vite       : 20.0.0
@nx/web        : 20.0.0
typescript     : 5.6.3
---------------------------------------
Registered Plugins:
@nx/vite/plugin
@nx/rollup/plugin
---------------------------------------
⚠️ Unable to construct project graph.
Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.
Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.
      An error occurred while processing files for the @nx/rollup/plugin plugin.
    - packages/react-color-picker/rollup.config.js: Could not find specified tsconfig.json at /Users/drew/Sites/terrazzoapp/terrazzo/tsconfig.build.json
      Error: Could not find specified tsconfig.json at /Users/drew/Sites/terrazzoapp/terrazzo/tsconfig.build.json
          at getTsConfigPath (file:///Users/drew/Sites/terrazzoapp/terrazzo/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@rollup/plugin-typescript/dist/es/index.js:244:19)
          at parseTypescriptConfig (file:///Users/drew/Sites/terrazzoapp/terrazzo/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@rollup/plugin-typescript/dist/es/index.js:318:26)
          at typescript (file:///Users/drew/Sites/terrazzoapp/terrazzo/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@rollup/plugin-typescript/dist/es/index.js:754:27)
          at file:///Users/drew/Sites/terrazzoapp/terrazzo/packages/react-color-picker/rollup.config.js?1728965523594:12:5
          at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
          at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:483:26)
          at async getConfigFileExport (/Users/drew/Sites/terrazzoapp/terrazzo/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/shared/loadConfigFile.js:471:17)
          at async loadConfigFile (/Users/drew/Sites/terrazzoapp/terrazzo/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/shared/loadConfigFile.js:430:59)
          at async buildRollupTarget (/Users/drew/Sites/terrazzoapp/terrazzo/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@[email protected]_@[email protected]_ffvo47yijgt2k62ikoudbwsnj4/node_modules/@nx/rollup/src/plugins/plugin.js:70:27)
          at async exports.createNodes (/Users/drew/Sites/terrazzoapp/terrazzo/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@[email protected]_@[email protected]_ffvo47yijgt2k62ikoudbwsnj4/node_modules/@nx/rollup/src/plugins/plugin.js:41:32)
    - packages/tiles/rollup.config.js: Could not find specified tsconfig.json at /Users/drew/Sites/terrazzoapp/terrazzo/tsconfig.build.json
      Error: Could not find specified tsconfig.json at /Users/drew/Sites/terrazzoapp/terrazzo/tsconfig.build.json
          at getTsConfigPath (file:///Users/drew/Sites/terrazzoapp/terrazzo/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@rollup/plugin-typescript/dist/es/index.js:247:19)
          at parseTypescriptConfig (file:///Users/drew/Sites/terrazzoapp/terrazzo/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@rollup/plugin-typescript/dist/es/index.js:321:26)
          at typescript (file:///Users/drew/Sites/terrazzoapp/terrazzo/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@rollup/plugin-typescript/dist/es/index.js:768:27)
          at file:///Users/drew/Sites/terrazzoapp/terrazzo/packages/tiles/rollup.config.js?1728965523597:12:5
          at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
          at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:483:26)
          at async getConfigFileExport (/Users/drew/Sites/terrazzoapp/terrazzo/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/shared/loadConfigFile.js:471:17)
          at async loadConfigFile (/Users/drew/Sites/terrazzoapp/terrazzo/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/shared/loadConfigFile.js:430:59)
          at async buildRollupTarget (/Users/drew/Sites/terrazzoapp/terrazzo/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@[email protected]_@[email protected]_ffvo47yijgt2k62ikoudbwsnj4/node_modules/@nx/rollup/src/plugins/plugin.js:70:27)
          at async exports.createNodes (/Users/drew/Sites/terrazzoapp/terrazzo/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@[email protected]_@[email protected]_ffvo47yijgt2k62ikoudbwsnj4/node_modules/@nx/rollup/src/plugins/plugin.js:41:32)

Failure Logs

No response

Package Manager Version

pnpm 9.12.1

Operating System

  • [x] macOS
  • [ ] Linux
  • [ ] Windows
  • [ ] Other (Please specify)

Additional Information

Running nx reset didn’t fix the issue (it seems to be a problem with the Rollup plugin)

drwpow avatar Oct 15 '24 04:10 drwpow