@prismicio/next
Version:
Helpers to integrate Prismic into Next.js apps
21 lines (20 loc) • 935 B
JavaScript
//#region src/lib/resolveDefaultExport.ts
/**
* Resolves a module's default export. The module may provide its default export as a `default`
* property on an object. This happens when named and default exports are mixed in modules.
*
* In ES Modules, mixing is fine since the module resolver can distinguish default and named
* exports. In transpiled modules, however, all exports are put into a single object, and the
* default export is provided at a property called `default`.
*
* This helper is needed by Next.js uses CJS files with named and default exports.
*
* This helper _should_ be a temporary hack until Next.js and Node.js resolve their ESM
* difficulties. This will likely not be removed any time soon, unfortunately.
*/
function resolveDefaultExport(mod) {
return "default" in mod ? mod.default : mod;
}
//#endregion
exports.resolveDefaultExport = resolveDefaultExport;
//# sourceMappingURL=resolveDefaultExport.cjs.map