Skip to content

Named commit and rollback to any named stage  #1

@XiLaiTL

Description

@XiLaiTL

Clear and concise description of the problem

The function commit update the MagicString to the new one.
I wonder If it is possible that you can commit with name, and rollback the named stage to use the relative position of any committed one?

Suggested solution

Like this:

const s = new MagicStringStack('problems = 99') //now we named it `origin`

s.replace('problems', 'issues')
  .append('var ')

s.toString() 
s.original 

s.commit("Middle") // now we named the staged `Middle`

s.original
s.replace('issues', 'problems')
s.toString() 

//many named stage

s.rollback('Middle') //now we go back to 'Middle' stage

s.rollback('origin')  //now we go back the origin one
//...

s.generateMap()

Alternative

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions