Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[@rollup/plugin-typescript] --configPlugin command option with Typescript plugin doesn't support reference option in tsconfig.json. #1755

Open
Mingeax opened this issue Aug 12, 2024 · 4 comments

Comments

@Mingeax
Copy link

Mingeax commented Aug 12, 2024

  • Rollup Plugin Name: @rollup/plugin-typescript
  • Rollup Plugin Version: 7.15.0
  • Rollup Version: v4.20.0
  • Operating System (or Browser): Windows 10
  • Node Version: v20.13.1
  • Link to reproduction (⚠️ read below): https://stackblitz.com/edit/rollup-repro-hfhjsp

Expected Behavior

Output successfully.

Actual Behavior

Throw error: Note that you need plugins to import files that are not JavaScript.

Additional Information

The rollup config file is included with the tsconfig file in references array.

@hsnMoghadasi
Copy link

same here, any solution?

tsconfig.json

{
  "files": ["./dist/atomsbuildinfo"], // this root tsconfig just exists to compose sub-projects
  "references": [
    {
      "path": "./src"
    },
    {
      "path": "./src/components/atoms"
    },
    {
      "path": "./src/components/molecules"
    },
    {
      "path": "./src/components/organisms"
    }
  ]
}

src\components\atoms\tsconfig.json


{
  "extends": "../../../tsconfig-base.json",
  "compilerOptions": {
    "outDir": "../../../dist",
    "composite": true, // needed for references sub-projects
    "rootDir": ".",
    "tsBuildInfoFile": "../../../dist/atomsbuildinfo",
    "rootDirs": [
      "../../../src",
      "../../../src/component/atoms",
      "../../../src/component/molecules",
      "../../../src/component/organisms"
    ]
  },
  "references": [
    {
      "path": "../../../src" // test project depends on src
    }
  ]
}

tsconfig-base.json


{
  // see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
  // "include": ["./src/**/*/*"],
  "compilerOptions": {
    "allowJs": true,
    // output .d.ts declaration files for consumers
    "declaration": true,
    "declarationDir": "./dist",
    // interop between ESM and CJS modules. Recommended by TS
    "esModuleInterop": true,
    // error out if import and file system have a casing mismatch. Recommended by TS
    "forceConsistentCasingInFileNames": true,
    "importHelpers": true,
    // transpile JSX to React.createElement
    "jsx": "react",
    "lib": ["dom", "esnext"],
    "module": "esnext",
    // use Node's module resolution algorithm, instead of the legacy TS one
    "moduleResolution": "node",
    // `tsdx build` ignores this option, but it is commonly used when type-checking separately with `tsc`
    "noEmit": false,
    "noFallthroughCasesInSwitch": true,
    // linter checks for common issues
    "noImplicitReturns": true,
    // noUnused* overlap with @typescript-eslint/no-unused-vars, can disable if duplicative
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    // match output dir to input dir. e.g. dist/index instead of dist/src/index
    "rootDir": "./src",
    "outDir": "./dist",
    // "baseUrl": "./src",
    // "paths": {
    //   "*": ["*"]
    // },
    // significant perf increase by skipping checking .d.ts files, particularly those in node_modules. Recommended by TS
    "skipLibCheck": true,
    // output .js.map sourcemap files for consumers
    "sourceMap": true,
    // stricter type-checking for stronger correctness. Recommended by TS
    "strict": true,
    "typeRoots": ["./src/types", "node_modules/@types"],
    // "emitDeclarationOnly": true
    "target": "es6",
    "build": true
  }
}

@crunk1
Copy link

crunk1 commented Oct 2, 2024

Also running into this. Replacing my base tsconfig.json with my tsconfig.rollup.json allows rollup to handle rollup.config.ts, but obviously the rest of my project breaks.

  • Rollup Plugin Name: @rollup/plugin-typescript
  • Rollup Plugin Version: 12.1.0
  • Rollup Version: v4.22.5
  • Operating System (or Browser): Linux
  • Node Version: v22.9.0

tsconfig.json

{
	"files": [],
	"references": [
		{ "path": "./tsconfig.integrations.json" },
		{ "path": "./tsconfig.rollup.json" },
		{ "path": "./tsconfig.service-worker.json" },
	],
}

tsconfig.rollup.json

{
	"include": ["./rollup.config.ts"],
	"compilerOptions": {
		"composite": true,
		"noEmit": true,
		"esModuleInterop": true,
		"module": "ESNext",
		"moduleResolution": "Bundler",
		"lib": ["ESNext"],
	}
}

@crunk1
Copy link

crunk1 commented Oct 2, 2024

Ah it appears to not only break for rollup.config.ts, but my other files as well. I converted rollup.config.ts to mjs and I saw the same Note that you need plugins to import files that are not JavaScript for other files in my project.

@hsnMoghadasi
Copy link

its work for me
in rollup config change the tsconfig to './tsconfig-base.json

   plugins: [
      typescript({ tsconfig: './tsconfig-base.json' }),
      ]

and use this command to make the d.ts files

yarn tsc -b -v

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants