Skip to content

Commit

Permalink
fix: flexmap didn't work with _module
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobrosenberg committed Sep 15, 2024
1 parent 987e728 commit b7863e5
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions plugins/flexMap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @example
* const routifyConfig = {
* plugins: [
* i18nPlugin({
* flexMapsPlugin({
* variationsMap: {
* default: ['en-us,en','en', 'de'],
* widget: ['en', 'de'],
Expand Down Expand Up @@ -104,16 +104,19 @@ function flexMapsNormalize(options) {

if (node.name.endsWith(`.${priority}`)) {
const newName = node.name.replace(`.${priority}`, '')

// remove old node
/** @type {RNodeBuildtime} */
let targetNode
try {
node.parent.traverse(`./${newName}`).remove()
if (newName === '_module') targetNode = node.parent
else targetNode = node.parent.traverse(`./${newName}`)
} catch (e) {
if (e.message.match('could not travel to'))
missingBaseComponentWarning(node, newName, ctx)
}

node.name = newName
Object.keys(node).forEach(key => {
if (key !== 'name') targetNode[key] = node[key]
})
node.remove()
}
})
})
Expand Down

0 comments on commit b7863e5

Please sign in to comment.