Coder Social home page Coder Social logo

Native modules about electron-angular-ngrx HOT 2 OPEN

kaffiend avatar kaffiend commented on May 30, 2024
Native modules

from electron-angular-ngrx.

Comments (2)

greg9504 avatar greg9504 commented on May 30, 2024

Forgot to add that I had to remove references to bootstrap for now, as the electron-builder would throw errors (Error: Unresolved node modules: jquery, popper.js), for possible work arounds see electron-userland/electron-builder#2529

ON EDIT - just looking at my other changes:

  • In typings.d.ts in root dir I had to add:
declare var window: Window;
interface Window {
  process: any;
  require: any;
}

So that I could do window.require('better-sqlite3');
Again this was found by looking at what https://github.com/maximegris/angular-electron did.

So using better-sqlite3 as an example, to use the native module would look like:

import * as Database from 'better-sqlite3';
// then instead of doing
// const db = new Database(args...);
// do
const dataBase: typeof Database = window.require('better-sqlite3');
const db = dataBase(args...);

The maximegris repo creates a service to hide the window.require("native-module") part.

To be honest I'm not sue why this works. From a 'coding' point of view I much prefer not having to do the window.require and just import then new the object, which is how it worked with the https://github.com/colinskow/angular-electron-dream-starter repo. It would be nice to figure out how the default paths used for require are produced.

Greg.

from electron-angular-ngrx.

Kaffiend avatar Kaffiend commented on May 30, 2024

@greg9504 Fantastic research and documentation. Ill take a look at this, this weekend. There are some things i want to try with extending the CLI for a more natural integration and should help with this.

from electron-angular-ngrx.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.