Skip to content

Commit

Permalink
fix(cli): 小程序端编译不能支持文件名中带 . 分割
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Aug 20, 2018
1 parent 582c98f commit b68b983
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
12 changes: 5 additions & 7 deletions packages/taro-cli/src/util/resolve_npm_files.js
Expand Up @@ -108,13 +108,11 @@ function parseAst (ast, filePath, files, isProduction, npmConfig) {
let realRequirePath = path.resolve(path.dirname(filePath), requirePath)
let tempPathWithJS = `${realRequirePath}.js`
let tempPathWithIndexJS = `${realRequirePath}${path.sep}index.js`
if (!path.extname(realRequirePath)) {
if (fs.existsSync(tempPathWithJS)) {
realRequirePath = tempPathWithJS
} else if (fs.existsSync(tempPathWithIndexJS)) {
realRequirePath = tempPathWithIndexJS
requirePath += '/index.js'
}
if (fs.existsSync(tempPathWithJS)) {
realRequirePath = tempPathWithJS
} else if (fs.existsSync(tempPathWithIndexJS)) {
realRequirePath = tempPathWithIndexJS
requirePath += '/index.js'
}
if (files.indexOf(realRequirePath) < 0) {
files.push(realRequirePath)
Expand Down
4 changes: 2 additions & 2 deletions packages/taro-cli/src/weapp.js
Expand Up @@ -523,7 +523,7 @@ function parseAst (type, ast, depComponents, sourceFilePath, filePath, npmSkip =
styleFiles.push(stylePath)
}
astPath.remove()
} else if (!valueExtname) {
} else {
let vpath = Util.resolveScriptPath(path.resolve(sourceFilePath, '..', value))
let outputVpath
if (NODE_MODULES_REG.test(vpath)) {
Expand Down Expand Up @@ -641,7 +641,7 @@ function parseAst (type, ast, depComponents, sourceFilePath, filePath, npmSkip =
sourceDirPath = nodeModulesPath
}
astPath.replaceWith(t.stringLiteral(vpath.replace(sourceDirPath, '').replace(/\\/g, '/')))
} else if (!valueExtname) {
} else {
let vpath = Util.resolveScriptPath(path.resolve(sourceFilePath, '..', value))
let outputVpath
if (NODE_MODULES_REG.test(vpath)) {
Expand Down

0 comments on commit b68b983

Please sign in to comment.