Skip to content

Commit

Permalink
fix(cli): fixed app usingComponents missing build
Browse files Browse the repository at this point in the history
  • Loading branch information
s6nqou committed Sep 16, 2019
1 parent f1bf4bc commit a6ab866
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions packages/cli/core/plugins/parser/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,32 @@ exports = module.exports = function () {
if (ctx.type !== 'app') { // app.json does not need it
config.component = true;
}
let componentKeys = config.usingComponents ? Object.keys(config.usingComponents) : [];
if (!config.usingComponents) {
config.usingComponents = {};
}

let componentKeys = Object.keys(config.usingComponents);

if (!appUsingComponents && componentKeys.length === 0) {
ctx.sfc.config.parsed = {
output: config
};
return Promise.resolve(true);
}
// page Components will inherit app using components
if (appUsingComponents && ctx.type === 'page') {
appUsingComponents.forEach(comp => {
// Existing in page components, then ignore
// Resolve path for page components
if (!config.usingComponents[comp.name] && comp.prefix === 'path') {
const relativePath = path.relative(path.dirname(ctx.file), comp.resolved.path);
const parsedPath = path.parse(relativePath);
// Remove wpy ext
config.usingComponents[comp.name] = path.join(parsedPath.dir, parsedPath.name);
componentKeys.push(comp.name);
}
});
}

let resolvedUsingComponents = {};
let parseComponents = [];
Expand Down Expand Up @@ -100,19 +118,7 @@ exports = module.exports = function () {
} else {
config.usingComponents = resolvedUsingComponents;
}
// page Components will inherit app using components
if (appUsingComponents && ctx.type === 'page') {
appUsingComponents.forEach(comp => {
// Existing in page components, then ignore
// Resolve path for page components
if (!config.usingComponents[comp.name] && comp.prefix === 'path') {
const relativePath = path.relative(path.dirname(ctx.file), comp.resolved.path);
const parsedPath = path.parse(relativePath);
// Remove wpy ext
config.usingComponents[comp.name] = path.join(parsedPath.dir, parsedPath.name);
}
});
}

ctx.sfc.config.parsed = {
output: config,
components: parseComponents
Expand Down

0 comments on commit a6ab866

Please sign in to comment.