Add comments of how conditional import works
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
// If you import a module but never use any of the imported values other than as TypeScript types,
|
||||||
|
// the resulting javascript file will look as if you never imported the module at all.
|
||||||
import { ipcRenderer } from 'electron';
|
import { ipcRenderer } from 'electron';
|
||||||
import * as childProcess from 'child_process';
|
import * as childProcess from 'child_process';
|
||||||
|
|
||||||
@@ -10,6 +12,7 @@ export class ElectronService {
|
|||||||
childProcess: typeof childProcess;
|
childProcess: typeof childProcess;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
//Conditional imports
|
||||||
if (this.isElectron()) {
|
if (this.isElectron()) {
|
||||||
this.ipcRenderer = window.require('electron').ipcRenderer;
|
this.ipcRenderer = window.require('electron').ipcRenderer;
|
||||||
this.childProcess = window.require('child_process');
|
this.childProcess = window.require('child_process');
|
||||||
|
|||||||
Reference in New Issue
Block a user