Skip to content

Commit

Permalink
fix(mini-runner): 组件引入支持统一从一个入口文件中引入
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Dec 31, 2019
1 parent 6ccfe83 commit d8898f1
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/taro-mini-runner/src/plugins/MiniPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,17 +331,19 @@ export default class MiniPlugin {
const { buildAdapter, alias } = this.options
components.forEach(component => {
let componentPath = component.path
let realComponentPath
if (componentPath && isNpmPkg(componentPath)) {
if (isAliasPath(componentPath, alias)) {
componentPath = replaceAliasPath(filePath, componentPath, alias)
realComponentPath = resolveScriptPath(path.resolve(filePath, '..', componentPath as string))
} else {
const res = resolveNpmSync(componentPath, this.context)
const code = fs.readFileSync(res).toString()
const newComponent = Object.assign({}, component, { path: res })
realComponentPath = this.getNpmComponentRealPath(code, newComponent, buildAdapter)
let realComponentPath = componentPath
if (componentPath) {
if (isNpmPkg(componentPath)) {
if (isAliasPath(componentPath, alias)) {
componentPath = replaceAliasPath(filePath, componentPath, alias)
realComponentPath = resolveScriptPath(path.resolve(filePath, '..', componentPath as string))
} else {
realComponentPath = resolveNpmSync(componentPath, this.context)
}
}
const code = fs.readFileSync(realComponentPath).toString()
const newComponent = Object.assign({}, component, { path: realComponentPath })
realComponentPath = this.getNpmComponentRealPath(code, newComponent, buildAdapter)
component.path = realComponentPath
}
})
Expand Down

0 comments on commit d8898f1

Please sign in to comment.