resolve-targets.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.resolveBrowserslistConfigFile = resolveBrowserslistConfigFile;
  6. exports.resolveTargets = resolveTargets;
  7. function _path() {
  8. const data = require("path");
  9. _path = function () {
  10. return data;
  11. };
  12. return data;
  13. }
  14. function _helperCompilationTargets() {
  15. const data = require("@babel/helper-compilation-targets");
  16. _helperCompilationTargets = function () {
  17. return data;
  18. };
  19. return data;
  20. }
  21. ({});
  22. function resolveBrowserslistConfigFile(browserslistConfigFile, configFileDir) {
  23. return _path().resolve(configFileDir, browserslistConfigFile);
  24. }
  25. function resolveTargets(options, root) {
  26. const optTargets = options.targets;
  27. let targets;
  28. if (typeof optTargets === "string" || Array.isArray(optTargets)) {
  29. targets = {
  30. browsers: optTargets
  31. };
  32. } else if (optTargets) {
  33. if ("esmodules" in optTargets) {
  34. targets = Object.assign({}, optTargets, {
  35. esmodules: "intersect"
  36. });
  37. } else {
  38. targets = optTargets;
  39. }
  40. }
  41. const {
  42. browserslistConfigFile
  43. } = options;
  44. let configFile;
  45. let ignoreBrowserslistConfig = false;
  46. if (typeof browserslistConfigFile === "string") {
  47. configFile = browserslistConfigFile;
  48. } else {
  49. ignoreBrowserslistConfig = browserslistConfigFile === false;
  50. }
  51. return (0, _helperCompilationTargets().default)(targets, {
  52. ignoreBrowserslistConfig,
  53. configFile,
  54. configPath: root,
  55. browserslistEnv: options.browserslistEnv
  56. });
  57. }
  58. 0 && 0;
  59. //# sourceMappingURL=resolve-targets.js.map