"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.loaderResolver = loaderResolver;
exports.moduleResolver = moduleResolver;

var _client_packages_group = require("@zohodesk/client_packages_group");

var _constants = require("../../constants");

var _libAlias = require("./common/libAlias");

function moduleResolver(options) {
  const {
    moduleResolvePath,
    disableES5Transpile
  } = options.app;
  const nodeModulesPath = moduleResolvePath // eslint-disable-next-line import/no-dynamic-require, global-require
  ? require(require.resolve(moduleResolvePath, {
    paths: [options.cwd]
  })).nodeModulesPath : _client_packages_group.nodeModulesPath; // const {unstableDepsInverse} = options;
  // console.log({ nodeModulesPath });

  return {
    modules: [_constants.cliNodemodulesPath, nodeModulesPath, 'node_modules'].filter(Boolean),
    alias: disableES5Transpile ? _libAlias.libAlias : {} // alias: { ...libAlias, ...clientDependenies }

  };
}

function loaderResolver(options) {
  // const unstableDepsInverse = false;
  const {
    unstableDepsInverse
  } = options;
  return {
    modules: unstableDepsInverse ? ['node_modules', _constants.cliNodemodulesPath] : [_constants.cliNodemodulesPath, 'node_modules'] // alias:  libAlias

  };
}