Repository: rollup/rollup
File: src/utils/FileEmitter.ts (TypeScript)

Code before:
			.then(module => (consumedChunk.module = module))
			.catch(() => {
				// Avoid unhandled Promise rejection as the error will be thrown later
				// once module loading has finished
			});

		return this.assignReferenceId(consumedChunk, emittedChunk.id);
	}

	private emitPrebuiltChunk(
		emitPrebuiltChunk: Omit<EmittedFile, 'fileName' | 'name'> &
			Pick<EmittedPrebuiltChunk, 'exports' | 'map'>
	): string {
		if (typeof emitPrebuiltChunk.code !== 'string') {
			return error(
				errorFailedValidation(
					`Emitted prebuilt chunks need to have a valid string code, received "${emitPrebuiltChunk.code}"`
				)
			);
		}
		if (
			typeof emitPrebuiltChunk.fileName !== 'string' ||
			!(
				typeof emitPrebuiltChunk.fileName === 'string' &&
				!isPathFragment(emitPrebuiltChunk.fileName)
			)
		) {
			return error(
				errorFailedValidation(
					`Emitted prebuilt chunks need to have a valid string fileName and that is neither absolute nor relative paths, received "${emitPrebuiltChunk.fileName}"`
				)
			);
		}
		const consumedPrebuiltChunk: ConsumedPrebuiltChunk = {
			code: emitPrebuiltChunk.code,
			exports: emitPrebuiltChunk.exports,
			fileName: emitPrebuiltChunk.fileName,
			map: emitPrebuiltChunk.map,
			referenceId: '',
			type: 'prebuilt-chunk'
		};
		const referenceId = this.assignReferenceId(
			consumedPrebuiltChunk,
			consumedPrebuiltChunk.fileName
		);
		if (this.output) {
			this.output.bundle[consumedPrebuiltChunk.fileName] =
				this.createPrebuiltChunk(consumedPrebuiltChunk);
		}
		return referenceId;
	}

Review comment (suggestion):
You do not need to repeat the first condition here

```suggestion
			typeof emitPrebuiltChunk.fileName !== 'string' ||
			isPathFragment(emitPrebuiltChunk.fileName)
```

Code after:
				// once module loading has finished
			});

		return this.assignReferenceId(consumedChunk, emittedChunk.id);
	}

	private emitPrebuiltChunk(
		emitPrebuiltChunk: Omit<EmittedFile, 'fileName' | 'name'> &
			Pick<EmittedPrebuiltChunk, 'exports' | 'map'>
	): string {
		if (typeof emitPrebuiltChunk.code !== 'string') {
			return error(
				errorFailedValidation(
					`Emitted prebuilt chunks need to have a valid string code, received "${emitPrebuiltChunk.code}".`
				)
			);
		}
		if (
			typeof emitPrebuiltChunk.fileName !== 'string' ||
			isPathFragment(emitPrebuiltChunk.fileName)
		) {
			return error(
				errorFailedValidation(
					`The "fileName" property of emitted prebuilt chunks must be strings that are neither absolute nor relative paths, received "${emitPrebuiltChunk.fileName}".`
				)
			);
		}
		const consumedPrebuiltChunk: ConsumedPrebuiltChunk = {
			code: emitPrebuiltChunk.code,
			exports: emitPrebuiltChunk.exports,
			fileName: emitPrebuiltChunk.fileName,
			map: emitPrebuiltChunk.map,
			referenceId: '',
			type: 'prebuilt-chunk'
		};
		const referenceId = this.assignReferenceId(
			consumedPrebuiltChunk,
			consumedPrebuiltChunk.fileName
		);
		if (this.output) {
			this.output.bundle[consumedPrebuiltChunk.fileName] =
				this.createPrebuiltChunk(consumedPrebuiltChunk);
		}
		return referenceId;
	}

	private finalizeAdditionalAsset(
		consumedFile: Readonly<ConsumedAsset>,
		source: string | Uint8Array,
		{ bundle, fileNamesBySource, outputOptions }: FileEmitterOutput
	): void {