Skip to content

Commit

Permalink
feat: improve log feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
aralroca committed Oct 12, 2023
1 parent d5e2c75 commit 7a6e464
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const constants = {
READY: Bun.enableANSIColors ? `[ \x1b[32mready\x1b[0m ] ` : "[ ready ] ",
INFO: Bun.enableANSIColors ? `[ \x1b[34minfo\x1b[0m ] ` : "[ info ] ",
ERROR: Bun.enableANSIColors ? `[ \x1b[31merror\x1b[0m ] ` : "[ error ] ",
WARN: Bun.enableANSIColors ? `[ \x1b[33mwarn\x1b[0m ] ` : "[ warn ] ",
},
LOCALES_SET: new Set(I18N_CONFIG?.locales || []) as Set<string>,
CONFIG: { ...defaultConfig, ...CONFIG } as Configuration,
Expand Down
6 changes: 3 additions & 3 deletions src/utils/transform-to-web-component/from-native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function fromNative({
code: string;
loader: JavaScriptLoader;
}) {
const { IS_PRODUCTION } = getConstants();
const { IS_PRODUCTION, LOG_PREFIX } = getConstants();
const ASTUtil = AST(loader);
const ast = ASTUtil.parseCodeToAST(code);
const exportDefaultIndex = ast.body.findIndex(
Expand All @@ -25,14 +25,14 @@ export default function fromNative({

if (!exportDefault) {
if (!IS_PRODUCTION) {
console.warn(`The web component ${name} doesn't have a default export`);
console.info(LOG_PREFIX.WARN, `The web component ${name} doesn't have a default export`);
}
return { contents: code, loader };
}

if (exportDefault.declaration.type !== "ClassDeclaration") {
if (!IS_PRODUCTION) {
console.warn(`The web component ${name} default export is not a class`);
console.info(LOG_PREFIX.WARN, `The web component ${name} default export is not a class`);
}
return { contents: code, loader };
}
Expand Down

0 comments on commit 7a6e464

Please sign in to comment.