UNPKG

@modern-js/builder

Version:
73 lines (72 loc) 2.78 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var config_exports = {}; __export(config_exports, { defineConfig: () => defineConfig, getDefaultEntries: () => getDefaultEntries, loadConfig: () => loadConfig }); module.exports = __toCommonJS(config_exports); var import_jiti = __toESM(require("jiti")); var import_path = require("path"); var import_utils = require("@modern-js/utils"); var import_fs_extra = require("@modern-js/utils/fs-extra"); const defineConfig = (config) => config; async function loadConfig() { const configFile = (0, import_path.join)(process.cwd(), "builder.config.ts"); if ((0, import_fs_extra.existsSync)(configFile)) { const loadConfig2 = (0, import_jiti.default)(__filename, { interopDefault: true }); return loadConfig2(configFile); } return {}; } function getDefaultEntries() { const cwd = process.cwd(); const files = [ "ts", "tsx", "js", "jsx" ].map((ext) => (0, import_path.join)(cwd, `src/index.${ext}`)); const entryFile = (0, import_utils.findExists)(files); if (entryFile) { return { index: entryFile }; } throw new Error("Could not find the entry file, please make sure that `src/index.(js|ts|tsx|jsx)` exists, or customize entry through the `source.entries` configuration."); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { defineConfig, getDefaultEntries, loadConfig });