const externals = {
  'rxjs': 'rxjs',
  'rxjs/operators': 'rxjs.operators',
  "redux": "Redux",

  // do not include angular libraries in externals with Ivy enabled, because Ivy means there is no runtime
  // '@angular/core': 'ng.core',
  // '@angular/common': 'ng.common',
  // '@angular/common/http': 'ng.common.http',
  // '@angular/compiler': 'ng.compiler',
  // '@angular/elements': 'ng.elements',
  // '@angular/forms': 'ng.forms',
  // '@angular/animations': 'ng.animations',
  // '@angular/animations/browser': 'ng.animations.browser',
  // "@angular/router": "ng.router",

  // '@angular/platform-browser': 'ng.platformBrowser',
  // '@angular/platform-browser-dynamic': 'ng.platformBrowserDynamic',
  // '@angular/platform-browser/animations': 'ng.platformBrowser.animations',

  // "@angular/cdk": "ng.cdk",
  // "@angular/cdk/keycodes": "ng.cdk.keycodes",
  // "@angular/cdk/coercion": "ng.cdk.coercion",
  // "@angular/cdk/platform": "ng.cdk.platform",
  // "@angular/cdk/observers": "ng.cdk.observers",
  // "@angular/cdk/a11y": "ng.cdk.a11y",
  // "@angular/cdk/bidi": "ng.cdk.bidi",
  // "@angular/cdk/collections": "ng.cdk.collections",
  // "@angular/cdk/scrolling": "ng.cdk.scrolling",
  // "@angular/cdk/portal": "ng.cdk.portal",
  // "@angular/cdk/overlay": 'ng.cdk.overlay',
  // "@angular/cdk/text-field": "ng.cdk.textField",
  // "@angular/cdk/tree": "ng.cdk.tree",

  // "@angular/material/core": "ng.material.core",
  // "@angular/material/form-field": "ng.material.formField",
  // "@angular/material/select": "ng.material.select",
  // "@angular/material/progress-spinner": "ng.material.progressSpinner",
  // "@angular/material/toolbar": "ng.material.toolbar",
  // "@angular/material/menu": "ng.material.menu",
  // "@angular/material/chips": "ng.material.chips",
  // "@angular/material/dialog": "ng.material.dialog",
  // "@angular/material/icon": "ng.material.icon",
  // "@angular/material/slider": "ng.material.slider",
  // "@angular/material/sidenav": "ng.material.sidenav",
  // "@angular/material/checkbox": "ng.material.checkbox",
  // "@angular/material/progressSpinner": "ng.material.progressSpinner",
  // "@angular/material/input": "ng.material.input",
  // "@angular/material/tree": "ng.material.tree",
  // "@angular/material/button": "ng.material.button",
  // "@angular/material/divider": "ng.material.divider",
  // "@angular/material/badge": "ng.material.badge",
  // "@angular/material/progress-bar": "ng.material.progressBar",

  "handlebars": "Handlebars",
  "dexie": "Dexie",

  "uuid": "uuid",
  "handlebars": "Handlebars",
  "async": "async",
  "lodash": "_",
  "loadjs": "loadjs",
  "socket.io-client": "io",
  "notyf": "Notyf",
  "immer": "immer",
  "rfc6902": "rfc6902",

  // "@formbird/types": "formbird.types",
  // "@formbird/shared": "formbird.shared",
  // "@formbird/services": "formbird.services"
};

// For testing if external libs are accessible globally. Run this after app load at browser console.
function checkExternalLibs(){
  let invalidRefs = [];
  for (const k of Object.keys(externals)) {
    const val = externals[k];
    let e;
    try {
      e = eval(val);
    }catch (e) {
    }
    if (!e) {
      invalidRefs.push(val);
    }
  }
  console.log(`Invalid external lib references: ${JSON.stringify(invalidRefs, null, 4)}`);
}

module.exports = {
  externals: externals,
  experiments: {
    topLevelAwait: true,
  }
};
