Skip to content

Errors duplicated in buildEnd hook #487

Description

@ekkxl

Troubleshooting

  1. Does tsc have the same output? If so, please explain why this is incorrect behavior

    tsc only reports the error once.

  2. Does your Rollup plugin order match this plugin's compatibility? If not, please elaborate

    Yes

  3. Can you create a minimal example that reproduces this behavior? Preferably, use this environment for your reproduction

    https://stackblitz.com/edit/rpt2-repro-nzp9odzw?file=src%2Findex.ts

What happens and why it is incorrect

When there's an type error in the code, it gets reported multiple times:

src/index.ts → bundle.js...
[!] (plugin rpt2) RollupError: There was an error during the build:
  [plugin rpt2] src/index.ts:6:5 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'number[]'.

6 foo('foo');
      ~~~~~

Additionally, handling the error in the 'buildEnd' hook caused the following error:
  [plugin rpt2] src/index.ts:6:5 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'number[]'.

6 foo('foo');
      ~~~~~

src/index.ts
Error: There was an error during the build:
  [plugin rpt2] src/index.ts:6:5 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'number[]'.

6 foo('foo');
      ~~~~~

Additionally, handling the error in the 'buildEnd' hook caused the following error:
  [plugin rpt2] src/index.ts:6:5 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'number[]'.

6 foo('foo');
      ~~~~~

    at getRollupError (/home/projects/rpt2-repro/node_modules/rollup/dist/shared/parseAst.js:289:41)
    at <anonymous> (/home/projects/rpt2-repro/node_modules/rollup/dist/shared/rollup.js:24220:51)

Environment

Versions

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 22.22.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @rollup/wasm-node:  4.60.3 
    rollup-plugin-typescript2: ^0.37.0 => 0.37.0 
    typescript: ^5.9.3 => 5.9.3 

rollup.config.js

:
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
import terser from '@rollup/plugin-terser';

export default {
	input: 'src/index.ts',
	output: {
		file: 'bundle.js',
		format: 'iife',
		sourcemap: true,
		sourcemapFileNames: 'bundle.jsmap',
		plugins: [
			terser({
				compress: {
					drop_debugger: false,
				},
			}),
		],
	},
	context: 'window',
	plugins: [
		commonjs({
			include: 'node_modules/**',
			ignoreGlobal: false,
			sourceMap: false,
		}),
		resolve(),
		typescript({
			clean: true,
			outputToFilesystem: true
		}),
	],
};

tsconfig.json

:
{
  "compilerOptions": {
    "incremental": true,
    "tsBuildInfoFile": "./Build/tsbuildinfo.json",
    
    "target": "es2020",
    
    "sourceMap": true,
    
    "module": "es6",
    "moduleResolution": "bundler",
    
    "noEmit": true,
    "noEmitOnError": true,
    
    "forceConsistentCasingInFileNames": true,
    
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "strictBindCallApply": true,
    "strictPropertyInitialization": true,
    "noImplicitThis": true,
    "useUnknownInCatchVariables": true,
    "alwaysStrict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "exactOptionalPropertyTypes": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitOverride": true,
    "noPropertyAccessFromIndexSignature": true,
    "allowUnusedLabels": false,
    "allowUnreachableCode": false,
    
    "skipLibCheck": true,
  }
}

package.json

:
{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "author": "",
  "license": "UNLICENSED",
  "type": "module",
  "devDependencies": {
    "@rollup/plugin-commonjs": "^29.0.1",
    "@rollup/plugin-node-resolve": "^16.0.3",
    "@rollup/plugin-terser": "^1.0.0",
    "rollup": "^4.59.0",
    "rollup-plugin-typescript2": "^0.37.0",
    "source-map": "^0.7.6",
    "tsc": "^2.0.4",
    "tslib": "^2.8.1",
    "typescript": "^5.9.3"
  },
  "scripts": {
    "build": "npx rollup --config rollup.config.mjs"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions