How to configure Angular to use Firebird with Webpack

Viewed 298

How to correct way to implement the Firebird with Webpack on one simple Angular component? I read some posts that "require" has been discouraged?

The package used is this https://www.npmjs.com/package/firebird

I already installed webpack

npm install --save-dev @types/webpack-env

And updating my tsconfig.json with the following under compilerOptions:

"types": [
      "webpack-env"
    ]

Could someone help me with the syntax and fix this code snippet below

import {Component} from '@angular/core';
//discouraged var fb = require ('firebird');

@Component ({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'project01';
  constructor () {
    var con = fb.createConnection();
    con.connectSync ('d:/data_base.FDB', 'SYSDBA', 'masterkey', '');

    var resfb = con.querySync ("select vendors.name_vendor from vendors");
    var rows = resfb.fetchSync ("all", true);
    con.commitSync ();
    console.log (sys.inspect (rows));
  }
}

For those who want to check the versions of the current libraries in my package.json:

{
  "name": "mOS",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "https://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "~9.1.6",
    "@angular/core": "~9.1.6",
    "@angular/forms": "~9.1.6",
    "@angular/platform-browser": "~9.1.6",
    "@angular/platform-browser-dynamic": "~9.1.6",
    "@angular/router": "~9.1.6",
    "@ionic-native/core": "^5.0.7",
    "@ionic-native/splash-screen": "^5.0.0",
    "@ionic-native/status-bar": "^5.0.0",
    "@ionic/angular": "^5.0.0",
    "firebird": "^0.1.4",
    "rxjs": "~6.5.1",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.901.5",
    "@angular/cli": "~9.1.5",
    "@angular/compiler": "~9.1.6",
    "@angular/compiler-cli": "~9.1.6",
    "@angular/language-service": "~9.1.6",
    "@ionic/angular-toolkit": "^2.1.1",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.12.39",
    "@types/webpack-env": "^1.15.2",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~2.1.0",
    "karma-jasmine": "~3.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "protractor": "~5.4.3",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~3.8.3"
  },
  "description": "An Ionic project"
}
0 Answers
Related