Skip to content

Commit

Permalink
fix(alita-core): 修复 tree-shake的模块 在执行handleChange等方法的时候报错的bug
Browse files Browse the repository at this point in the history
affects: @areslabs/alita-core
  • Loading branch information
ykforerlang committed Mar 19, 2020
1 parent 6513441 commit 5de491c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/alita-core/src/extractWxCompFiles/extractJSONFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ function getFinalPath(element, source, module, info, defaultSpecifier, chunk, js
function deepSeekPath(element, absolutePath, defaultSpecifier, chunk) {

let info = getModuleInfo(absolutePath)

if (!info) {
console.error('你可能需要把', absolutePath.replace(configure.inputFullpath, '') , '加入include配置。')
return ''
}

let im = info.im

while (im[element]) {
Expand All @@ -155,6 +161,11 @@ function deepSeekPath(element, absolutePath, defaultSpecifier, chunk) {

absolutePath = info.deps[source]
info = getModuleInfo(absolutePath)

if (!info) {
console.error('你可能需要把', absolutePath.replace(configure.inputFullpath, '') , '加入include配置。')
return ''
}
im = info.im
}

Expand Down
13 changes: 13 additions & 0 deletions packages/alita-core/src/extractWxCompFiles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import configure from '../configure'
export const handleChanged = (resource) => {
const info = getModuleInfo(resource)

if (!info) {
return
}


let newFiles = null
if (info.isEntry) {
Expand Down Expand Up @@ -77,6 +81,11 @@ export const handleChanged = (resource) => {

export const handleDeleted = (resource) => {
const info = getModuleInfo(resource)

if (!info) {
return
}

const outFiles = info.outFiles || {}

const allKeys = Object.keys(outFiles)
Expand Down Expand Up @@ -125,6 +134,10 @@ function expandWithChunks(obj, allChunks) {
export const handleJSONUpdate = (resource) => {

const info = getModuleInfo(resource)
if (!info) {
return
}

const finalJSPath = miscNameToJSName(resource).replace(configure.inputFullpath, configure.outputFullpath)

const newJSONFiles = jsonChanged(resource, info, finalJSPath)
Expand Down

0 comments on commit 5de491c

Please sign in to comment.