Skip to content

Commit 14eb299

Browse files
Version Packages
1 parent c32874b commit 14eb299

4 files changed

Lines changed: 66 additions & 65 deletions

File tree

.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: 64 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,53 @@
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+
351
## 3.3.6
452

553
### Patch Changes
@@ -94,11 +142,11 @@
94142
export default function Sitemap() {}
95143

96144
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-
});
145+
return getSitemapProps(ctx, {
146+
sitemapIndexPath: '/sitemap_index.xml', // RankMath changes the default sitemap path to this
147+
frontendUrl: process.env.NEXT_PUBLIC_SITE_URL,
148+
sitemapPathsToIgnore: ['/wp-sitemap-users-*'],
149+
});
102150
}
103151
```
104152

@@ -202,7 +250,7 @@
202250
203251
```jsx
204252
<ToolbarItem onKeyDown={handleKeyDown} onClick={handleClick}>
205-
Log Out
253+
Log Out
206254
</ToolbarItem>
207255
```
208256
@@ -308,18 +356,18 @@
308356
import { FaustPage } from '@faustwp/core';
309357

310358
type GetPageData = {
311-
generalSettings: {
312-
title: string;
313-
};
359+
generalSettings: {
360+
title: string;
361+
};
314362
};
315363

316364
type PageProps = {
317-
myProp: string;
365+
myProp: string;
318366
};
319367

320368
const Page: FaustPage<GetPageData, PageProps> = (props) => {
321-
const { myProp, data } = props;
322-
return <></>;
369+
const { myProp, data } = props;
370+
return <></>;
323371
};
324372
```
325373
@@ -388,9 +436,9 @@
388436
export default function Sitemap() {}
389437

390438
export function getServerSideProps(context) {
391-
return getSitemapProps(context, {
392-
frontendUrl: process.env.FRONTEND_URL, // Set the FRONTEND_URL as an env var
393-
});
439+
return getSitemapProps(context, {
440+
frontendUrl: process.env.FRONTEND_URL, // Set the FRONTEND_URL as an env var
441+
});
394442
}
395443
```
396444
@@ -420,7 +468,7 @@
420468
import { FaustHooks, FaustPlugin } from '@faustwp/core';
421469

422470
export class MyPlugin implements FaustPlugin {
423-
apply(hooks: FaustHooks) {}
471+
apply(hooks: FaustHooks) {}
424472
}
425473
```
426474

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)