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 26, 2019
1 parent 1ecf6a4 commit d6dbb7e
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions packages/taro-mini-runner/src/plugins/MiniPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,11 @@ export default class MiniPlugin {
return componentRealPath
}

transfromComponentsPath (filePath, components: IComponentObj[]) {
transformComponentsPath (filePath, components: IComponentObj[]) {
const { buildAdapter, alias } = this.options
components.forEach(component => {
let componentPath = component.path
let realComponentPath = componentPath
let realComponentPath
if (componentPath) {
if (isNpmPkg(componentPath)) {
if (isAliasPath(componentPath, alias)) {
Expand All @@ -340,6 +340,8 @@ export default class MiniPlugin {
} else {
realComponentPath = resolveNpmSync(componentPath, this.context)
}
} else {
realComponentPath = resolveScriptPath(path.resolve(filePath, '..', componentPath as string))
}
const code = fs.readFileSync(realComponentPath).toString()
const newComponent = Object.assign({}, component, { path: realComponentPath })
Expand Down Expand Up @@ -398,7 +400,11 @@ export default class MiniPlugin {
}
}

getPages (compiler) {
getShowPath (filePath) {
return filePath.replace(this.context, '').replace(/\\/g, '/').replace(/^\//, '')
}

getPages () {
const { buildAdapter } = this.options
const appEntry = this.appEntry
const code = fs.readFileSync(appEntry).toString()
Expand All @@ -415,7 +421,7 @@ export default class MiniPlugin {
if (!appPages || appPages.length === 0) {
throw new Error('缺少页面')
}
printLog(processTypeEnum.COMPILE, '发现入口', appEntry)
printLog(processTypeEnum.COMPILE, '发现入口', this.getShowPath(appEntry))
this.getSubPackages(configObj)
this.getTabBarFiles(configObj)
const template = ''
Expand Down Expand Up @@ -607,7 +613,7 @@ export default class MiniPlugin {
code = transformResult.code
}
depComponents = depComponents.filter(item => !/^plugin:\/\//.test(item.path))
this.transfromComponentsPath(file.path, depComponents)
this.transformComponentsPath(file.path, depComponents)
if (isQuickApp) {
const scriptPath = file.path
const outputScriptPath = scriptPath.replace(this.sourceDir, this.outputDir).replace(path.extname(scriptPath), MINI_APP_FILES[buildAdapter].SCRIPT)
Expand All @@ -633,7 +639,7 @@ export default class MiniPlugin {
imports: new Set([...importTaroSelfComponents, ...importUsingComponent, ...importCustomComponents])
})
}
printLog(processTypeEnum.COMPILE, isRoot ? '发现页面' : '发现组件', file.path)
printLog(processTypeEnum.COMPILE, isRoot ? '发现页面' : '发现组件', this.getShowPath(file.path))
taroFileTypeMap[file.path] = {
type: isRoot ? PARSE_AST_TYPE.PAGE : PARSE_AST_TYPE.COMPONENT,
config: merge({}, isComponentConfig, buildUsingComponents(file.path, this.sourceDir, alias, depComponents), configObj),
Expand Down Expand Up @@ -808,7 +814,7 @@ export default class MiniPlugin {

run (compiler: webpack.Compiler) {
if (!this.options.isBuildPlugin) {
this.getPages(compiler)
this.getPages()
this.getComponents(this.pages, true)
this.addEntries(compiler)
} else {
Expand Down

0 comments on commit d6dbb7e

Please sign in to comment.