Skip to content

Commit

Permalink
fix(mini-runner): 修复插件中引用 taro-ui 组件路径错误,close #7694
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Sep 28, 2020
1 parent d0fc948 commit 7fcfd0b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/taro-mini-runner/src/plugins/MiniPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ export default class MiniPlugin {
}

getComponents (compiler: webpack.Compiler, fileList: Set<IComponent>, isRoot: boolean) {
const { buildAdapter, alias, isBuildQuickapp, fileType, constantsReplaceList, nodeModulesPath } = this.options
const { buildAdapter, alias, isBuildQuickapp, fileType, constantsReplaceList, nodeModulesPath, isBuildPlugin } = this.options
fileList.forEach(file => {
try {
const isNative = file.isNative
Expand Down Expand Up @@ -824,7 +824,7 @@ export default class MiniPlugin {
}
taroFileTypeMap[file.path] = {
type: isRoot ? PARSE_AST_TYPE.PAGE : PARSE_AST_TYPE.COMPONENT,
config: merge({}, isComponentConfig, buildUsingComponents(file.path, this.sourceDir, alias, depComponents), configObj),
config: merge({}, isComponentConfig, buildUsingComponents(file.path, this.sourceDir, alias, depComponents, isBuildPlugin), configObj),
code,
importStyles
}
Expand Down
4 changes: 3 additions & 1 deletion packages/taro-mini-runner/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function buildUsingComponents (
sourceDir: string,
pathAlias: IOption,
components: IComponentObj[],
isBuildPlugin: boolean,
isComponent?: boolean
): IOption {
const usingComponents = Object.create(null)
Expand All @@ -59,7 +60,8 @@ export function buildUsingComponents (
componentPath = resolveScriptPath(path.resolve(filePath, '..', componentPath as string))
if (fs.existsSync(componentPath)) {
if (NODE_MODULES_REG.test(componentPath) && !NODE_MODULES_REG.test(filePath)) {
componentPath = componentPath!.replace(NODE_MODULES_REG, path.join(sourceDir, 'npm'))
const npmDir = isBuildPlugin ? 'plugin/npm' : 'npm'
componentPath = componentPath!.replace(NODE_MODULES_REG, path.join(sourceDir, npmDir))
}
componentPath = promoteRelativePath(path.relative(filePath, componentPath!))
} else {
Expand Down

0 comments on commit 7fcfd0b

Please sign in to comment.