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

Getting Error while running on Browser using vite package manager #287

Open
funcbind opened this issue May 18, 2024 · 2 comments
Open

Getting Error while running on Browser using vite package manager #287

funcbind opened this issue May 18, 2024 · 2 comments

Comments

@funcbind
Copy link

funcbind commented May 18, 2024

Issue :

  • Trying to use caterpillar logger in an frontend app ( using vite, react etc ) on browser
  • Getting error in the console and unable to proceed further

> Logger Instantiation Code

import { Logger, Human, Browser } from 'caterpillar';

// Caterpillar logger
const cLogger = new Logger();
cLogger.pipe(new Human()).pipe(new Browser());

cLogger.log('warn', 'this is a warning, which is level', 4);
cLogger.warn('this is a warning, which is level', 4);

> Error On Console

browser-external:util:9 Module "util" has been externalized for browser compatibility. Cannot access "util.inspect" in client code. See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
get @ browser-external:util:9

human.js:72 Uncaught (in promise) TypeError: (0 , import_util.inspect) is not a function
    at human.js:72:15
    at Array.map (<anonymous>)
    at Human.formatArguments (human.js:70:14)
    at Human.format (human.js:105:24)
    at Human.write (transform.js:28:27)
    at transform.js:38:32

> Package.json File Contents

{
  "name": "vite-react-zustand-tryout",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
    "preview": "vite preview"
  },
  "dependencies": {
    "auto-zustand-selectors-hook": "^2.0.0",
    "caterpillar": "^8.2.0",
    "immer": "^10.1.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "zustand": "^4.5.2"
  },
  "devDependencies": {
    "@types/react": "^18.2.66",
    "@types/react-dom": "^18.2.22",
    "@vitejs/plugin-react-swc": "^3.5.0",
    "autoprefixer": "^10.4.19",
    "eslint": "^8.57.0",
    "eslint-plugin-react": "^7.34.1",
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-react-refresh": "^0.4.6",
    "postcss": "^8.4.38",
    "tailwindcss": "^3.4.3",
    "vite": "^5.2.0"
  }
}
@balupton
Copy link
Member

balupton commented May 21, 2024

Hrmmm, seems inspect needs to be removed from the human browser bundle, or internalised within it. Thanks for the detailed log. Not sure when I will get to this, could be a few months from now. If it's important for your company, the work can be funded to make it a priority.

@molleweide
Copy link

I got similar issues when trying to use caterpillar as well in vite/react

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

3 participants