Skip to content

Commit c66cdf4

Browse files
authored
docs(guides): refine code-splitting code snippets (#6279)
* Update code-splitting.mdx * 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.
1 parent f0b8411 commit c66cdf4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/content/guides/code-splitting.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ Now, instead of statically importing `lodash`, we'll use dynamic importing to se
314314
-
315315
-function component() {
316316
+function getComponent() {
317-
const element = document.createElement('div');
317+
- const element = document.createElement('div');
318318

319319
- // Lodash, now imported by this script
320320
- element.innerHTML = _.join(['Hello', 'webpack'], ' ');
@@ -359,7 +359,7 @@ As `import()` returns a promise, it can be used with [`async` functions](https:/
359359
```diff
360360
-function getComponent() {
361361
+async function getComponent() {
362-
const element = document.createElement('div');
362+
+ const element = document.createElement('div');
363363
+ const { default: _ } = await import('lodash');
364364

365365
- return import('lodash')

0 commit comments

Comments
 (0)