Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LoggerTag is undefined #398

Open
wewelll opened this issue Aug 23, 2022 · 0 comments
Open

LoggerTag is undefined #398

wewelll opened this issue Aug 23, 2022 · 0 comments

Comments

@wewelll
Copy link

wewelll commented Aug 23, 2022

Describe the bug
when importing LoggerTag from @marblejs/core, the enum is undefined.

To Reproduce

import { LoggerTag } from '@marblejs/core'

console.log(LoggerTag.HTTP)

produces the following error:

console.log(LoggerTag.HTTP);
                      ^
TypeError: Cannot read properties of undefined (reading 'HTTP')

Expected behavior
It should not be undefined

Desktop (please complete the following information):

  • OS: MacOS 12.5.1
  • Package + Version: @marblejs/core v4.0.3
  • Node version v16.15.1

Additional context
It looks like a bundling issue. In my node_modules I can see LoggerTag in the type definitions but not in the .js file

// node_modules/@marblejs/core/dist/logger/logger.interface.js
// LoggerTag is here

import { IO } from 'fp-ts/lib/IO';
export declare type Logger = (opts: LoggerOptions) => IO<void>;
export declare enum LoggerLevel {
    INFO = 0,
    WARN = 1,
    ERROR = 2,
    DEBUG = 3,
    VERBOSE = 4
}
export declare type LoggerOptions = {
    tag: string;
    type: string;
    message: string;
    level?: LoggerLevel;
    data?: Record<string, unknown>;
};
export declare const enum LoggerTag {
    CORE = "core",
    HTTP = "http",
    MESSAGING = "messaging",
    EVENT_BUS = "event_bus",
    WEBSOCKETS = "websockets"
}
// node_modules/@marblejs/core/dist/logger/logger.interface.js
// LoggerTag Missing

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LoggerLevel = void 0;
var LoggerLevel;
(function (LoggerLevel) {
    LoggerLevel[LoggerLevel["INFO"] = 0] = "INFO";
    LoggerLevel[LoggerLevel["WARN"] = 1] = "WARN";
    LoggerLevel[LoggerLevel["ERROR"] = 2] = "ERROR";
    LoggerLevel[LoggerLevel["DEBUG"] = 3] = "DEBUG";
    LoggerLevel[LoggerLevel["VERBOSE"] = 4] = "VERBOSE";
})(LoggerLevel = exports.LoggerLevel || (exports.LoggerLevel = {}));

My intuition is that the syntax in the source code is export const enum LoggerTag and should be export enum LoggerTag (removing the const) to work like LoggerLevel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant