UNPKG

@modern-js/utils

Version:

A Progressive React Framework for modern web development.

83 lines (82 loc) 3.12 kB
"use strict"; var __webpack_require__ = {}; (()=>{ __webpack_require__.n = (module)=>{ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module; __webpack_require__.d(getter, { a: getter }); return getter; }; })(); (()=>{ __webpack_require__.d = (exports1, definition)=>{ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, { enumerable: true, get: definition[key] }); }; })(); (()=>{ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop); })(); (()=>{ __webpack_require__.r = (exports1)=>{ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, { value: 'Module' }); Object.defineProperty(exports1, '__esModule', { value: true }); }; })(); var __webpack_exports__ = {}; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { getAliasConfig: ()=>getAliasConfig, getUserAlias: ()=>getUserAlias, mergeAlias: ()=>mergeAlias }); const external_fs_namespaceObject = require("fs"); var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject); const external_path_namespaceObject = require("path"); var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject); const external_applyOptionsChain_js_namespaceObject = require("./applyOptionsChain.js"); const index_js_namespaceObject = require("./get/index.js"); const mergeAlias = (alias)=>(0, external_applyOptionsChain_js_namespaceObject.applyOptionsChain)({}, alias); const getAliasConfig = (aliasOption, option)=>{ const isTsProject = external_fs_default().existsSync(option.tsconfigPath); const alias = mergeAlias(aliasOption); if (!isTsProject) return { absoluteBaseUrl: option.appDirectory, paths: alias, isTsPath: false, isTsProject }; const tsconfig = (0, index_js_namespaceObject.readTsConfigByFile)(option.tsconfigPath); const baseUrl = tsconfig?.compilerOptions?.baseUrl; return { absoluteBaseUrl: baseUrl ? external_path_default().join(option.appDirectory, baseUrl) : option.appDirectory, paths: { ...alias, ...tsconfig?.compilerOptions?.paths }, isTsPath: true, isTsProject }; }; const getUserAlias = (alias = {})=>Object.keys(alias).reduce((o, k)=>{ if (Array.isArray(alias[k])) o[k] = alias[k]; return o; }, {}); exports.getAliasConfig = __webpack_exports__.getAliasConfig; exports.getUserAlias = __webpack_exports__.getUserAlias; exports.mergeAlias = __webpack_exports__.mergeAlias; for(var __rspack_i in __webpack_exports__)if (-1 === [ "getAliasConfig", "getUserAlias", "mergeAlias" ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i]; Object.defineProperty(exports, '__esModule', { value: true });