unjs/magicast

Inner comment lost when manipulating an object

Andarist opened this issue · 0 comments

Environment

magicast@0.2.0

Reproduction

import { parseModule, generateCode } from "magicast";

const mod = parseModule(`

export default {
  /*inner comment*/
}

`);

mod.exports.default.foo ||= [];
mod.exports.default.foo.push("b");
mod.exports.default.foo.unshift("a");

const { code } = generateCode(mod);

console.log({ code });

Describe the bug

actual: an inner comment within an empty object is lost after manipulating that object
expected: the inner comment should be preserved

Additional context

No response

Logs

No response