Skip to content

Bug on ExportDefatultDeclaration's sourcemap generation #373

@clark-t

Description

@clark-t

Bug description

raw code like:

export default {
  a() {}
}

escodegen generates sourcemap now is:

{
  mappings: 'AAAA;AAAA;AAAA;AAAA',
  // other properties
}

the correct sourcemap should be:

{
  mappings: 'AAAA,eAAe;AAAA,IACdA,CAAA,GAAI;AAAA,KADU;AAAA,CAAf'
}

Reason

I found out that L1213 cause this problem, which this.generateExpression(xxx) + this.semicolon(flags) turns SourceNode tree into string and lost sourcemap information.

I think the correct code should be:

// LINE 1213
result = join(result, this.generateExpression(stmt.declaration, Precedence.Assignment, E_TTT));
result.push(this.semicolon(flags));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions