Skip to content

[Bug]: rangeError with retainLines and multi lines comments #16165

@ArnaudBarre

Description

@ArnaudBarre

💻

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

import { transform } from "@babel/core";

transform(`
export const App = () => {
    return (
        /**
         * First
         */
        2
    );
};

/**
 * Second
 */
`, {
    retainLines: true,
})

Configuration file name

No response

Configuration

No response

Current and expected behavior

Current: crash with RangeError: Invalid count value: -2

Expected: No crash

Environment

v7.23.5

Possible solution

No response

Additional context

After some debugging, commenting this line remove the error:

Maybe this need an indent() few lines above?

The pretty stacktrace when running inside Vite:

Screenshot 2023-12-10 at 23 46 04

Metadata

Metadata

Assignees

Labels

i: regressionoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: generator

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions