From 03aeb8236aa555dda83260ff9511d573646bca79 Mon Sep 17 00:00:00 2001 From: "Matin (aka asma)" <52866914+Matin297@users.noreply.github.com> Date: Sat, 16 Jul 2022 15:30:50 +0430 Subject: [PATCH 1/2] Update code-splitting.mdx --- src/content/guides/code-splitting.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/guides/code-splitting.mdx b/src/content/guides/code-splitting.mdx index 0083034ad83f..1020199f1c9b 100644 --- a/src/content/guides/code-splitting.mdx +++ b/src/content/guides/code-splitting.mdx @@ -314,7 +314,7 @@ Now, instead of statically importing `lodash`, we'll use dynamic importing to se - -function component() { +function getComponent() { - const element = document.createElement('div'); +- const element = document.createElement('div'); - // Lodash, now imported by this script - element.innerHTML = _.join(['Hello', 'webpack'], ' '); From 62e522aadad68afd4aa72764fbb1173d2f30982e Mon Sep 17 00:00:00 2001 From: "Matin (aka asma)" <52866914+Matin297@users.noreply.github.com> Date: Mon, 18 Jul 2022 07:30:14 +0430 Subject: [PATCH 2/2] update code-splitting.mdx Dynamic imports section: as the first call to createElement was removed in the first occurrence of src/index.js, It needed to be added in the second example that uses promises. --- src/content/guides/code-splitting.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/guides/code-splitting.mdx b/src/content/guides/code-splitting.mdx index 1020199f1c9b..a512c783a72d 100644 --- a/src/content/guides/code-splitting.mdx +++ b/src/content/guides/code-splitting.mdx @@ -359,7 +359,7 @@ As `import()` returns a promise, it can be used with [`async` functions](https:/ ```diff -function getComponent() { +async function getComponent() { - const element = document.createElement('div'); ++ const element = document.createElement('div'); + const { default: _ } = await import('lodash'); - return import('lodash')