Skip to content

[Bug]: keepNames doesn't keep the class names if a JSON file with same key name is imported #6097

@aminya

Description

@aminya

Reproduction link or steps

https://stackblitz.com/edit/rolldown-rolldown-starter-stackblitz-tcmgvqlm?file=dist%2Findex.js

What is expected?

The class names should be kept since the ORM relies on the name and metadata of those classes

What is actually happening?

Class is unnamed or in some cases named to something with $1 suffix.

//#region rolldown:runtime
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", {
	value,
	configurable: true
});

//#endregion
//#region src/a.json
var Message$1 = 1;
var a_default = { Message: Message$1 };

//#endregion
//#region src/index.ts
var Message = class {
	id;
	constructor(id) {
		this.id = id;
	}
	toString() {
		return this.id.toString();
	}
};
const y = new Message(1);
console.log(y.toString());
console.log(a_default.Message + y.toString());

//#endregion

System Info

All

Any additional comments?

I kept the same error in TSDown, but it should be the same.

Metadata

Metadata

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions