one
Version:
One is a new React Framework that makes Vite serve both native and web.
57 lines (56 loc) • 2.04 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: !0 });
}, __copyProps = (to, from, except, desc) => {
if (from && typeof from == "object" || typeof from == "function")
for (let key of __getOwnPropNames(from))
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
var loadConfig_exports = {};
__export(loadConfig_exports, {
loadUserOneOptions: () => loadUserOneOptions,
setOneOptions: () => setOneOptions
});
module.exports = __toCommonJS(loadConfig_exports);
var import_vite = require("vite"), import_polyfills_server = require("../polyfills-server");
function setOneOptions(next) {
globalThis.__oneOptions = next;
}
function getUserOneOptions() {
if (!globalThis.__oneOptions)
throw new Error(
"One not loaded properly, is the one() plugin in your vite.config.ts?"
);
return globalThis.__oneOptions;
}
async function loadUserOneOptions(command, silent = !1) {
const originalConsoleError = console.error;
silent && (console.error = () => {
});
try {
const config = await (0, import_vite.loadConfigFromFile)({
mode: command === "serve" ? "dev" : "prod",
command
});
if (!config)
throw new Error(
`No config config in ${process.cwd()}. Is this the correct directory?`
);
const oneOptions = getUserOneOptions();
if (!oneOptions)
throw new Error("No One plugin config in this vite.config");
return {
config,
oneOptions
};
} finally {
silent && (console.error = originalConsoleError);
}
}
//# sourceMappingURL=loadConfig.js.map