How to get the content after the previous api.render change ?(Generator API)

I need help~

when i try to write my preset, my project catalog:

There are tow features can be selected to add to project.

the content of template/test.js is:


then in generator/index.js, I call module feat1 and feat2 to help me deal with it.

const feat1 = require('./feat1')
const feat2 = require('./feat2')

const handle = {
  feat1,
  feat2
}

module.exports = (api, options) => {
  api.render('../template')
  for (const key of Object.keys(options)) {
    if (options[key]) {
      handle[key](api)
    }
  }
}

in feat1/index.js, as like as feat2/index.js

module.exports  = api => {
  api.render('./template')
}

in feat1/template/test.js, I use yaml syntax to replace the part of the content of template/test.js:

---
  extend: '../../../template/test.js'
  replace:
    - !!js/regexp /\/\/.feat.1.todo/
---

<%# REPLACE %>
// insert feat 1 something ...
<%# END_REPLACE %>

in feat2/template/test.js, I use yaml syntax to replace the other part of the content of template/test.js:

---
  extend: '../../../template/test.js'
  replace:
    - !!js/regexp /\/\/.feat.2.todo/
---

<%# REPLACE %>
// insert feat 2 something ...
// something others
<%# END_REPLACE %>

I wish using this preset to create project demo, and I think the test.js file of demo will be:

function test () {
  // insert feat 1 something ...
  console.log('test console')
  // insert feat 2 something ...
// something others
}

but actually, it’s:

function test () {
  // feat 1 todo
  console.log('test console')
  // insert feat 2 something ...
// something others
}

after I see the document of generator API, I know the api.render is to render a vitural file tree, but not apply it to the real file on disk.

so in feat2/template/test.js, the extend get content also is:

function test () {
  // feat 1 todo
  console.log('test console')
  // feat 2 todo
}

it means feat1/template/test.js’s rendering will be coverd by feat2/template/test.js.:joy:

I want to know how can I get the changed content after module feat1 taking effect in module feat2.

Thanks!