Spaces:
Sleeping
Sleeping
| ; | |
| Object.defineProperty(exports, "__esModule", { | |
| value: true | |
| }); | |
| 0 && (module.exports = { | |
| default: null, | |
| noSSR: null | |
| }); | |
| function _export(target, all) { | |
| for(var name in all)Object.defineProperty(target, name, { | |
| enumerable: true, | |
| get: all[name] | |
| }); | |
| } | |
| _export(exports, { | |
| /** | |
| * This function lets you dynamically import a component. | |
| * It uses [React.lazy()](https://react.dev/reference/react/lazy) with [Suspense](https://react.dev/reference/react/Suspense) under the hood. | |
| * | |
| * Read more: [Next.js Docs: `next/dynamic`](https://nextjs.org/docs/app/building-your-application/optimizing/lazy-loading#nextdynamic) | |
| */ default: function() { | |
| return dynamic; | |
| }, | |
| noSSR: function() { | |
| return noSSR; | |
| } | |
| }); | |
| const _interop_require_default = require("@swc/helpers/_/_interop_require_default"); | |
| const _jsxruntime = require("react/jsx-runtime"); | |
| const _react = /*#__PURE__*/ _interop_require_default._(require("react")); | |
| const _loadablesharedruntime = /*#__PURE__*/ _interop_require_default._(require("./loadable.shared-runtime")); | |
| const isServerSide = typeof window === 'undefined'; | |
| // Normalize loader to return the module as form { default: Component } for `React.lazy`. | |
| // Also for backward compatible since next/dynamic allows to resolve a component directly with loader | |
| // Client component reference proxy need to be converted to a module. | |
| function convertModule(mod) { | |
| return { | |
| default: (mod == null ? void 0 : mod.default) || mod | |
| }; | |
| } | |
| function noSSR(LoadableInitializer, loadableOptions) { | |
| // Removing webpack and modules means react-loadable won't try preloading | |
| delete loadableOptions.webpack; | |
| delete loadableOptions.modules; | |
| // This check is necessary to prevent react-loadable from initializing on the server | |
| if (!isServerSide) { | |
| return LoadableInitializer(loadableOptions); | |
| } | |
| const Loading = loadableOptions.loading; | |
| // This will only be rendered on the server side | |
| return ()=>/*#__PURE__*/ (0, _jsxruntime.jsx)(Loading, { | |
| error: null, | |
| isLoading: true, | |
| pastDelay: false, | |
| timedOut: false | |
| }); | |
| } | |
| function dynamic(dynamicOptions, options) { | |
| let loadableFn = _loadablesharedruntime.default; | |
| let loadableOptions = { | |
| // A loading component is not required, so we default it | |
| loading: (param)=>{ | |
| let { error, isLoading, pastDelay } = param; | |
| if (!pastDelay) return null; | |
| if (process.env.NODE_ENV !== 'production') { | |
| if (isLoading) { | |
| return null; | |
| } | |
| if (error) { | |
| return /*#__PURE__*/ (0, _jsxruntime.jsxs)("p", { | |
| children: [ | |
| error.message, | |
| /*#__PURE__*/ (0, _jsxruntime.jsx)("br", {}), | |
| error.stack | |
| ] | |
| }); | |
| } | |
| } | |
| return null; | |
| } | |
| }; | |
| // Support for direct import(), eg: dynamic(import('../hello-world')) | |
| // Note that this is only kept for the edge case where someone is passing in a promise as first argument | |
| // The react-loadable babel plugin will turn dynamic(import('../hello-world')) into dynamic(() => import('../hello-world')) | |
| // To make sure we don't execute the import without rendering first | |
| if (dynamicOptions instanceof Promise) { | |
| loadableOptions.loader = ()=>dynamicOptions; | |
| // Support for having import as a function, eg: dynamic(() => import('../hello-world')) | |
| } else if (typeof dynamicOptions === 'function') { | |
| loadableOptions.loader = dynamicOptions; | |
| // Support for having first argument being options, eg: dynamic({loader: import('../hello-world')}) | |
| } else if (typeof dynamicOptions === 'object') { | |
| loadableOptions = { | |
| ...loadableOptions, | |
| ...dynamicOptions | |
| }; | |
| } | |
| // Support for passing options, eg: dynamic(import('../hello-world'), {loading: () => <p>Loading something</p>}) | |
| loadableOptions = { | |
| ...loadableOptions, | |
| ...options | |
| }; | |
| const loaderFn = loadableOptions.loader; | |
| const loader = ()=>loaderFn != null ? loaderFn().then(convertModule) : Promise.resolve(convertModule(()=>null)); | |
| // coming from build/babel/plugins/react-loadable-plugin.js | |
| if (loadableOptions.loadableGenerated) { | |
| loadableOptions = { | |
| ...loadableOptions, | |
| ...loadableOptions.loadableGenerated | |
| }; | |
| delete loadableOptions.loadableGenerated; | |
| } | |
| // support for disabling server side rendering, eg: dynamic(() => import('../hello-world'), {ssr: false}). | |
| if (typeof loadableOptions.ssr === 'boolean' && !loadableOptions.ssr) { | |
| delete loadableOptions.webpack; | |
| delete loadableOptions.modules; | |
| return noSSR(loadableFn, loadableOptions); | |
| } | |
| return loadableFn({ | |
| ...loadableOptions, | |
| loader: loader | |
| }); | |
| } | |
| if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') { | |
| Object.defineProperty(exports.default, '__esModule', { value: true }); | |
| Object.assign(exports.default, exports); | |
| module.exports = exports.default; | |
| } | |
| //# sourceMappingURL=dynamic.js.map |