holistics / dbml

Database Markup Language (DBML), designed to define and document database structures
https://dbml.org
Apache License 2.0
2.77k stars 163 forks source link

Can't use the library in reactjs #597

Open raxkumar opened 1 month ago

raxkumar commented 1 month ago

Uncaught runtime errors: × ERROR Super expression must either be null or a function TypeError: Super expression must either be null or a function at _inherits (http://localhost:3000/static/js/bundle.js:9127:11) at http://localhost:3000/static/js/bundle.js:9196:3 at ./node_modules/@dbml/core/lib/parse/ANTLR/ASTGeneration/postgres/PostgreSQLLexerBase.js (http://localhost:3000/static/js/bundle.js:9203:2) at options.factory (http://localhost:3000/static/js/bundle.js:433157:31) at webpack_require__ (http://localhost:3000/static/js/bundle.js:432586:32) at fn (http://localhost:3000/static/js/bundle.js:432815:21) at ./node_modules/@dbml/core/lib/parse/ANTLR/parsers/postgresql/PostgreSQLLexer.js (http://localhost:3000/static/js/bundle.js:106257:53) at options.factory (http://localhost:3000/static/js/bundle.js:433157:31) at webpack_require__ (http://localhost:3000/static/js/bundle.js:432586:32) at fn (http://localhost:3000/static/js/bundle.js:432815:21)

NQPhuc commented 1 month ago

Hi @raxkumar

Can you provide the code where you use it so that we can investigate more?

raxkumar commented 1 month ago

Hi @NQPhuc ,

It was actually straight forward. my usecase is to validate the dbml on the front-end [react]

import React from 'react';
import Parser from '@dbml/core'; // Ensure correct import

const App = () => {
  const parser = new Parser();
  return (
    <div>
      <h1>DBML Parser Test</h1>
    </div>
  );
};

export default App;

but when i import this package and start the react app, I am getting this error:-

Uncaught runtime errors:
×
ERROR
Super expression must either be null or a function
TypeError: Super expression must either be null or a function
at _inherits (http://localhost:3000/static/js/bundle.js:9127:11)
at http://localhost:3000/static/js/bundle.js:9196:3
at ./node_modules/@dbml/core/lib/parse/ANTLR/ASTGeneration/postgres/PostgreSQLLexerBase.js (http://localhost:3000/static/js/bundle.js:9203:2)
at options.factory (http://localhost:3000/static/js/bundle.js:433157:31)
at webpack_require (http://localhost:3000/static/js/bundle.js:432586:32)
at fn (http://localhost:3000/static/js/bundle.js:432815:21)
at ./node_modules/@dbml/core/lib/parse/ANTLR/parsers/postgresql/PostgreSQLLexer.js (http://localhost:3000/static/js/bundle.js:106257:53)
at options.factory (http://localhost:3000/static/js/bundle.js:433157:31)
at webpack_require (http://localhost:3000/static/js/bundle.js:432586:32)
at fn (http://localhost:3000/static/js/bundle.js:432815:21)
NQPhuc commented 1 month ago

Hi, you should import the parser like this

import { Parser } from '@dbml/core';

Also, what are the react version and @dbml/core version you are using?

raxkumar commented 3 weeks ago
Screenshot 2024-08-26 at 12 29 11 AM
raxkumar commented 3 weeks ago

This is my package.json

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@dbml/core": "^3.7.4",
    "@testing-library/jest-dom": "^5.17.0",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "react": "^18.3.1",
    "react-dom": "^18.3.1",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}
raxkumar commented 3 weeks ago

I am still facing, Same problem.