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

Can't use the library in reactjs #597

Open
raxkumar opened this issue Jul 26, 2024 · 6 comments
Open

Can't use the library in reactjs #597

raxkumar opened this issue Jul 26, 2024 · 6 comments

Comments

@raxkumar
Copy link

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
Copy link
Contributor

NQPhuc commented Jul 26, 2024

Hi @raxkumar

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

@raxkumar
Copy link
Author

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
Copy link
Contributor

NQPhuc commented Aug 2, 2024

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
Copy link
Author

Screenshot 2024-08-26 at 12 29 11 AM

@raxkumar
Copy link
Author

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
Copy link
Author

I am still facing, Same problem.

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

2 participants