Skip to content

Commit

Permalink
feat(cli): 生成的entry文件里面的import使用相对路径
Browse files Browse the repository at this point in the history
  • Loading branch information
roymondchen committed Jul 5, 2023
1 parent bb682cb commit 24bb45e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/cli/src/utils/resolveAppPackages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const resolveAppPackages = (app: App): ModuleMainFilePath => {

const dependencies: Record<string, string> = {};

const setPackages = (cwd: string, packagePath: string, key?: string) => {
const setPackages = (cwd: string, tmp: string, packagePath: string, key?: string) => {
const { name: moduleName } = splitNameVersion(packagePath);

if (!moduleName) throw Error('packages中包含非法配置');
Expand All @@ -42,10 +42,10 @@ export const resolveAppPackages = (app: App): ModuleMainFilePath => {
const result = typeAssertion({ ast, indexPath });

const setItem = (key: string, entry: Entry) => {
if (entry.component) componentMap[key] = entry.component;
if (entry.config) configMap[key] = entry.config;
if (entry.event) eventMap[key] = entry.event;
if (entry.value) valueMap[key] = entry.value;
if (entry.component) componentMap[key] = path.relative(tmp, entry.component);
if (entry.config) configMap[key] = path.relative(tmp, entry.config);
if (entry.event) eventMap[key] = path.relative(tmp, entry.event);
if (entry.value) valueMap[key] = path.relative(tmp, entry.value);
};

if (result.type === PackageType.COMPONENT && key) {
Expand Down Expand Up @@ -116,10 +116,10 @@ export const resolveAppPackages = (app: App): ModuleMainFilePath => {
packages.forEach((item) => {
if (typeof item === 'object') {
Object.entries(item).forEach(([key, packagePath]) => {
setPackages(app.options.source, packagePath, key);
setPackages(app.options.source, app.options.temp, packagePath, key);
});
} else {
setPackages(app.options.source, item);
setPackages(app.options.source, app.options.temp, item);
}
});

Expand Down

0 comments on commit 24bb45e

Please sign in to comment.