Skip to content

Commit 7b7400e

Browse files
Version Packages
1 parent 91886b1 commit 7b7400e

File tree

5 files changed

+70
-70
lines changed

5 files changed

+70
-70
lines changed

.changeset/cute-doors-argue.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/funny-ravens-run.md

Lines changed: 0 additions & 47 deletions
This file was deleted.

examples/next/faustwp-getting-started/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"dependencies": {
1313
"@apollo/client": "^3.14.0",
1414
"@faustwp/cli": "^3.3.6",
15-
"@faustwp/core": "^3.3.6",
15+
"@faustwp/core": "^3.4.0",
1616
"@wordpress/base-styles": "^6.15.0",
1717
"@wordpress/block-library": "9.10.0",
1818
"classnames": "^2.5.1",

packages/faustwp-core/CHANGELOG.md

Lines changed: 68 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,57 @@
11
# @faustwp/core
22

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+
355
## 3.3.6
456

557
### Patch Changes
@@ -94,11 +146,11 @@
94146
export default function Sitemap() {}
95147

96148
export function getServerSideProps(ctx) {
97-
return getSitemapProps(ctx, {
98-
sitemapIndexPath: '/sitemap_index.xml', // RankMath changes the default sitemap path to this
99-
frontendUrl: process.env.NEXT_PUBLIC_SITE_URL,
100-
sitemapPathsToIgnore: ['/wp-sitemap-users-*'],
101-
});
149+
return getSitemapProps(ctx, {
150+
sitemapIndexPath: '/sitemap_index.xml', // RankMath changes the default sitemap path to this
151+
frontendUrl: process.env.NEXT_PUBLIC_SITE_URL,
152+
sitemapPathsToIgnore: ['/wp-sitemap-users-*'],
153+
});
102154
}
103155
```
104156

@@ -202,7 +254,7 @@
202254
203255
```jsx
204256
<ToolbarItem onKeyDown={handleKeyDown} onClick={handleClick}>
205-
Log Out
257+
Log Out
206258
</ToolbarItem>
207259
```
208260
@@ -308,18 +360,18 @@
308360
import { FaustPage } from '@faustwp/core';
309361

310362
type GetPageData = {
311-
generalSettings: {
312-
title: string;
313-
};
363+
generalSettings: {
364+
title: string;
365+
};
314366
};
315367

316368
type PageProps = {
317-
myProp: string;
369+
myProp: string;
318370
};
319371

320372
const Page: FaustPage<GetPageData, PageProps> = (props) => {
321-
const { myProp, data } = props;
322-
return <></>;
373+
const { myProp, data } = props;
374+
return <></>;
323375
};
324376
```
325377
@@ -388,9 +440,9 @@
388440
export default function Sitemap() {}
389441

390442
export function getServerSideProps(context) {
391-
return getSitemapProps(context, {
392-
frontendUrl: process.env.FRONTEND_URL, // Set the FRONTEND_URL as an env var
393-
});
443+
return getSitemapProps(context, {
444+
frontendUrl: process.env.FRONTEND_URL, // Set the FRONTEND_URL as an env var
445+
});
394446
}
395447
```
396448
@@ -420,7 +472,7 @@
420472
import { FaustHooks, FaustPlugin } from '@faustwp/core';
421473

422474
export class MyPlugin implements FaustPlugin {
423-
apply(hooks: FaustHooks) {}
475+
apply(hooks: FaustHooks) {}
424476
}
425477
```
426478

packages/faustwp-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@faustwp/core",
3-
"version": "3.3.6",
3+
"version": "3.4.0",
44
"description": "Faust is a framework that aims to make headless WordPress as streamlined as classic WordPress for both developers and publishers",
55
"main": "dist/cjs/index.js",
66
"module": "dist/mjs/index.js",

0 commit comments

Comments
 (0)