@modern-js/utils
Version:
A Progressive React Framework for modern web development.
84 lines (83 loc) • 3.31 kB
JavaScript
;
var __webpack_require__ = {};
(()=>{
__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__, {
isSSGEntry: ()=>isSSGEntry,
isSSR: ()=>isSSR,
isServiceWorker: ()=>isServiceWorker,
isSingleEntry: ()=>isSingleEntry,
isUseRsc: ()=>isUseRsc,
isUseSSRBundle: ()=>isUseSSRBundle
});
const external_constants_js_namespaceObject = require("../constants.js");
const external_type_js_namespaceObject = require("./type.js");
const isSSR = (config)=>{
const { server } = config;
if (server?.ssr) return true;
if (server?.ssrByEntries && !(0, external_type_js_namespaceObject.isEmpty)(server.ssrByEntries)) {
for (const name of Object.keys(server.ssrByEntries))if (server.ssrByEntries[name]) return true;
}
return false;
};
const isUseSSRBundle = (config)=>{
const { output } = config;
if (output?.ssg || output?.ssgByEntries && Object.keys(output?.ssgByEntries).length > 0) return true;
return isSSR(config);
};
const isUseRsc = (config)=>config?.server?.rsc;
const isServiceWorker = (config)=>{
const { output, deploy } = config;
if (deploy?.worker?.ssr && (output?.ssg || isSSR(config))) return true;
return false;
};
const isSSGEntry = (config, entryName, entrypoints)=>{
const { output, source } = config;
const single = isSingleEntry(entrypoints, source?.mainEntryName);
if (single) {
const byEntries = output?.ssgByEntries;
return Boolean(output?.ssg) || byEntries && !(0, external_type_js_namespaceObject.isEmpty)(byEntries);
}
const byEntries = output?.ssgByEntries;
if (!byEntries || (0, external_type_js_namespaceObject.isEmpty)(byEntries)) return false;
return Boolean(byEntries[entryName]);
};
const isSingleEntry = (entrypoints, mainEntryName = external_constants_js_namespaceObject.MAIN_ENTRY_NAME)=>1 === entrypoints.length && entrypoints[0].entryName === mainEntryName;
exports.isSSGEntry = __webpack_exports__.isSSGEntry;
exports.isSSR = __webpack_exports__.isSSR;
exports.isServiceWorker = __webpack_exports__.isServiceWorker;
exports.isSingleEntry = __webpack_exports__.isSingleEntry;
exports.isUseRsc = __webpack_exports__.isUseRsc;
exports.isUseSSRBundle = __webpack_exports__.isUseSSRBundle;
for(var __rspack_i in __webpack_exports__)if (-1 === [
"isSSGEntry",
"isSSR",
"isServiceWorker",
"isSingleEntry",
"isUseRsc",
"isUseSSRBundle"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
value: true
});