|
1 | 1 | # @faustwp/core |
2 | 2 |
|
| 3 | +## 3.4.0 |
| 4 | + |
| 5 | +### Minor Changes |
| 6 | + |
| 7 | +- ec26ac4: Feat: Added support `next/dynamic` imports for templates to reduce initial bundle size in a way that's backwards compatible with static imports. |
| 8 | + |
| 9 | + This solves a known issue in Faust where all defined templates are bundled together and loaded on every WordPress page. By enabling the use of dynamic importing of templates this issue is resolved. Now templates are only loaded as needed per route. |
| 10 | + |
| 11 | + It's recommended you migrate to dynamic imports by updating your template file. Here's an example: |
| 12 | + |
| 13 | + ```js title=src/wp-templates/index.js |
| 14 | + // Old Static Templates |
| 15 | + import category from './category'; |
| 16 | + import tag from './tag'; |
| 17 | + import frontPage from './front-page'; |
| 18 | + import page from './page'; |
| 19 | + import single from './single'; |
| 20 | + |
| 21 | + export default { |
| 22 | + category, |
| 23 | + tag, |
| 24 | + 'front-page': frontPage, |
| 25 | + page, |
| 26 | + single, |
| 27 | + }; |
| 28 | + |
| 29 | + // New Dynamic Templates |
| 30 | + import dynamic from 'next/dynamic'; |
| 31 | + |
| 32 | + const category = dynamic(() => import('./category.js')); |
| 33 | + const tag = dynamic(() => import('./tag.js')); |
| 34 | + const frontPage = dynamic(() => import('./front-page.js')); |
| 35 | + const page = dynamic(() => import('./page.js')); |
| 36 | + |
| 37 | + // The above examples assume use of default exports. If you are using named exports you'll need to handle that: |
| 38 | + const single = dynamic(() => import('./single.js').then(mod => mod.Single)); |
| 39 | + |
| 40 | + export default { |
| 41 | + category, |
| 42 | + tag, |
| 43 | + 'front-page': frontPage, |
| 44 | + page, |
| 45 | + single, |
| 46 | + }; |
| 47 | + ``` |
| 48 | + |
| 49 | + For further info see the Next.js docs on the use of [`next/dynamic`](https://nextjs.org/docs/pages/guides/lazy-loading#nextdynamic-1). |
| 50 | + |
| 51 | +### Patch Changes |
| 52 | + |
| 53 | +- 91886b1: Upgraded fast-xml-parser from v5.3.4 to v5.3.6 to incorporate the latest bug fixes, performance improvements, and minor stability enhancements. |
| 54 | +- 95cacbe: Fixed an issue where dynamic template components were rendered via the next/dynamic wrapper directly, causing hydration mismatches and double renders, by resolving the dynamic component to its inner function and storing it in state before rendering. |
| 55 | + |
3 | 56 | ## 3.3.6 |
4 | 57 |
|
5 | 58 | ### Patch Changes |
|
0 commit comments