import { jsx, jsxs, Fragment } from 'solid-jsx/jsx-runtime';

/*@jsxRuntime automatic @jsxImportSource solid-jsx*/
const toc = [];
function _createMdxContent(props) {
  const _components = Object.assign({
    p: "p",
    code: "code",
    pre: "pre",
    span: "span"
  }, props.components);
  return jsxs(Fragment, {
    children: [jsxs(_components.p, {
      children: ["ほとんどのバンドラー（Webpack, Rollup, Parcel, Vite など）は、動的インポートを使用する際にコード分割を自動的に処理します。Solid の ", jsx(_components.code, {
        children: "lazy"
      }), " メソッドでは、コンポーネントの動的インポートをラップして遅延ロードを行うことができます。出力されるのは、JSX テンプレートで通常どおりに使用できるコンポーネントです。ただし、内部的には、最初にレンダリングされるときに、基となるインポートされたコードを動的にロードし、コードが利用可能になるまでレンダリングのブランチを停止するという例外があります。"]
    }), "\n", jsxs(_components.p, {
      children: [jsx(_components.code, {
        children: "lazy"
      }), " を使用するには、import 文を置き換えます:"]
    }), "\n", jsx(_components.pre, {
      children: jsxs(_components.code, {
        className: "hljs language-js",
        children: [jsx(_components.span, {
          className: "hljs-keyword",
          children: "import"
        }), " ", jsx(_components.span, {
          className: "hljs-title class_",
          children: "Greeting"
        }), " ", jsx(_components.span, {
          className: "hljs-keyword",
          children: "from"
        }), " ", jsx(_components.span, {
          className: "hljs-string",
          children: "\"./greeting\""
        }), ";\n"]
      })
    }), "\n", jsx(_components.p, {
      children: "このように:"
    }), "\n", jsx(_components.pre, {
      children: jsxs(_components.code, {
        className: "hljs language-js",
        children: [jsx(_components.span, {
          className: "hljs-keyword",
          children: "const"
        }), " ", jsx(_components.span, {
          className: "hljs-title class_",
          children: "Greeting"
        }), " = ", jsx(_components.span, {
          className: "hljs-title function_",
          children: "lazy"
        }), "(", jsx(_components.span, {
          className: "hljs-function",
          children: "() =>"
        }), " ", jsx(_components.span, {
          className: "hljs-title function_",
          children: "import"
        }), "(", jsx(_components.span, {
          className: "hljs-string",
          children: "\"./greeting\""
        }), "));\n"]
      })
    }), "\n", jsx(_components.p, {
      children: "これでもロードが早すぎて見えないかもしれません。しかし、ローディングをより見やすくしたい場合は、偽の遅延を追加します。"
    }), "\n", jsx(_components.pre, {
      children: jsxs(_components.code, {
        className: "hljs language-js",
        children: [jsx(_components.span, {
          className: "hljs-keyword",
          children: "const"
        }), " ", jsx(_components.span, {
          className: "hljs-title class_",
          children: "Greeting"
        }), " = ", jsx(_components.span, {
          className: "hljs-title function_",
          children: "lazy"
        }), "(", jsx(_components.span, {
          className: "hljs-keyword",
          children: "async"
        }), " () => {\n  ", jsx(_components.span, {
          className: "hljs-comment",
          children: "// 遅延をシミュレート"
        }), "\n  ", jsx(_components.span, {
          className: "hljs-keyword",
          children: "await"
        }), " ", jsx(_components.span, {
          className: "hljs-keyword",
          children: "new"
        }), " ", jsx(_components.span, {
          className: "hljs-title class_",
          children: "Promise"
        }), "(", jsxs(_components.span, {
          className: "hljs-function",
          children: [jsx(_components.span, {
            className: "hljs-params",
            children: "r"
          }), " =>"]
        }), " ", jsx(_components.span, {
          className: "hljs-built_in",
          children: "setTimeout"
        }), "(r, ", jsx(_components.span, {
          className: "hljs-number",
          children: "1000"
        }), "))\n  ", jsx(_components.span, {
          className: "hljs-keyword",
          children: "return"
        }), " ", jsx(_components.span, {
          className: "hljs-title function_",
          children: "import"
        }), "(", jsx(_components.span, {
          className: "hljs-string",
          children: "\"./greeting\""
        }), ")\n});\n"]
      })
    })]
  });
}
function MDXContent(props = {}) {
  const {wrapper: MDXLayout} = props.components || ({});
  return MDXLayout ? jsx(MDXLayout, Object.assign({}, props, {
    children: jsx(_createMdxContent, props)
  })) : _createMdxContent(props);
}

export { MDXContent as default, toc };
//# sourceMappingURL=lesson-bbfac518.js.map
