Skip to content

Commit

Permalink
fix: update runner hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakaryCode committed Aug 12, 2024
1 parent df9bd5b commit f12e134
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions packages/taro-vite-runner/src/harmony/template/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@ export default class Parser extends BaseParser {
parseEntry (rawId: string, config = {}) {
const { creator, creatorLocation, frameworkArgs, importFrameworkStatement, modifyEntryFile } = this.loaderMeta
const createApp = `${creator}(component, ${frameworkArgs})`
const rawCode = isFunction(modifyEntryFile) ? modifyEntryFile.call(this, 'app', rawId, config) : ''

return rawCode || this.transArr2Str([
const rawCode = this.transArr2Str([
'import { initPxTransform } from "@tarojs/taro"',
`import { ${creator} } from "${creatorLocation}"`,
`import component from "${escapePath(rawId)}"`,
Expand All @@ -171,5 +169,7 @@ export default class Parser extends BaseParser {
this.getInitPxTransform(),
`export default () => ${createApp}`,
])

return isFunction(modifyEntryFile) ? modifyEntryFile.call(this, 'app', rawId, rawCode, config) : rawCode
}
}
8 changes: 4 additions & 4 deletions packages/taro-vite-runner/src/harmony/template/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ for (let i = 0; i < taskQueen.length; i++) {

let instantiatePage = this.transArr2Str(structCodeArray)
if (isFunction(modifyInstantiate)) {
instantiatePage = modifyInstantiate.call(this, instantiatePage, 'page')
instantiatePage = modifyInstantiate.call(this, instantiatePage, 'page', page)
}

return instantiatePage
Expand Down Expand Up @@ -1092,9 +1092,7 @@ this.removeTabBarEvent()` : 'callFn(this.page?.onUnload, this)'])
: isBlended
? `'${pageName}', ${frameworkArgs}` : `'${pageName}', config`})`

const rawCode = isFunction(modifyEntryFile) ? modifyEntryFile.call(this, 'page', rawId, page) : ''

return rawCode || this.transArr2Str([
const rawCode = this.transArr2Str([
`import { ${createFn} } from '${creatorLocation}'`,
`import component from "${escapePath(rawId)}"`,
isBlended ? 'import { initPxTransform } from "@tarojs/taro"' : null,
Expand All @@ -1105,5 +1103,7 @@ this.removeTabBarEvent()` : 'callFn(this.page?.onUnload, this)'])
page?.config.enableShareAppMessage ? 'component.enableShareAppMessage = true' : null,
`export default () => ${createPageOrComponent}`,
])

return isFunction(modifyEntryFile) ? modifyEntryFile.call(this, 'page', rawId, rawCode, page) : rawCode
}
}

0 comments on commit f12e134

Please sign in to comment.