Skip to content

Commit

Permalink
fix(cli): ui 库编译支持文件循环引用,close #4427
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Sep 23, 2019
1 parent b6818a3 commit 5e7fa88
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/taro-cli/src/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ const tempDir = '.temp'

let buildData: IBuildData

const processedScriptFiles:Set<string> = new Set()

function setBuildData (appPath, uiIndex) {
const configDir = path.join(appPath, PROJECT_CONFIG)
const projectConfig = require(configDir)(_.merge)
Expand Down Expand Up @@ -255,6 +257,10 @@ function parseEntryAst (ast: t.File, relativeFile: string) {
function analyzeFiles (files: string[], sourceDir: string, outputDir: string) {
files.forEach(file => {
if (fs.existsSync(file)) {
if (processedScriptFiles.has(file)) {
return
}
processedScriptFiles.add(file)
const code = fs.readFileSync(file).toString()
const transformResult = wxTransformer({
code,
Expand Down Expand Up @@ -355,7 +361,7 @@ async function buildForWeapp () {
}
}

async function buildForH5 (uiIndex) {
async function buildForH5 (uiIndex = 'index') {
const { appPath } = buildData
const compiler = new Compiler(appPath, uiIndex)
console.log()
Expand Down

0 comments on commit 5e7fa88

Please sign in to comment.