Skip to content

builders.raw throws when adding comments. #129

@Hugos68

Description

@Hugos68

Environment

NodeJS: 22.12.0
Magicast: ^0.3.5

Reproduction

import { builders } from 'magicast';

builders.raw('/** foo */');

Describe the bug

Providing a comment of any kind to builders.raw throws an error that looks to be related to the babel parser. I would like to add comments until #103 is merged but unsure how to do that.

I was wondering if I could also add comments using the $ast, perhaps somebody could help me out?

Additional context

No response

Logs

SyntaxError: Unterminated regular expression. (1:2)
 ❯ toParseError ../../node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/src/parse-error.ts:95:45
 ❯ V8IntrinsicMixin.raise ../../node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/src/tokenizer/index.ts:1496:19
 ❯ V8IntrinsicMixin.readRegexp ../../node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/src/tokenizer/index.ts:1074:20
 ❯ V8IntrinsicMixin.parseExprAtom ../../node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/src/parser/expression.ts:1103:14
 ❯ V8IntrinsicMixin.parseExprAtom ../../node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/src/plugins/jsx/index.ts:576:22
 ❯ V8IntrinsicMixin.parseExprAtom ../../node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/src/plugins/v8intrinsic.ts:33:42
 ❯ V8IntrinsicMixin.parseExprSubscripts ../../node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/src/parser/expression.ts:709:23
 ❯ V8IntrinsicMixin.parseUpdate ../../node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/src/parser/expression.ts:688:21
 ❯ V8IntrinsicMixin.parseMaybeUnary ../../node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/src/parser/expression.ts:650:23
 ❯ V8IntrinsicMixin.parseMaybeUnary ../../node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/src/plugins/typescript/index.ts:3593:20

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions