Skip to content

Commit

Permalink
feat: adjust code style
Browse files Browse the repository at this point in the history
  • Loading branch information
imtaotao committed Jun 30, 2021
1 parent e6ade09 commit 378f284
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/runtime/micro-component/src/apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ export function loadComponent(
options: ComponentInfo | string,
): Promise<Record<string, any> | null> {
const info = getLoadOptions(options);
assert(info.url, 'Missing url for loading micro component');
const { url, env, cache, version, error, adapter } = info;

assert(url, 'Missing url for loading micro component');
assert(
isAbsolute(info.url),
isAbsolute(url),
'The loading of the micro component must be an absolute path.',
);

const { url, env, cache, version, error, adapter } = info;
// `1.0@https://xx.js`
// `latest@https://xx.js`
const urlWithVersion = `${version || 'latest'}@${url}`;
Expand Down Expand Up @@ -84,11 +85,11 @@ export function loadComponentSync(
'The loading of the micro component must be an absolute path.',
);

let result = null;
const { url, env, cache, version, error, adapter } = info;
const urlWithVersion = `${version || 'latest'}@${url}`;
let result = null;

const component = cacheComponents[urlWithVersion];

if (cache && component) {
result = component;
} else {
Expand Down Expand Up @@ -142,7 +143,10 @@ export function setExternal(
if (typeof nameOrExtObj === 'object') {
for (const key in nameOrExtObj) {
if (EXTERNALS[key]) {
__DEV__ && warn(`The "${key}" will be overwritten in external.`);
__DEV__ &&
warn(
`The "${key}" will be overwritten in micro components external.`,
);
}
EXTERNALS[key] = nameOrExtObj[key];
}
Expand Down

0 comments on commit 378f284

Please sign in to comment.