Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions .changeset/funny-ravens-run.md

This file was deleted.

2 changes: 1 addition & 1 deletion examples/next/faustwp-getting-started/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"@apollo/client": "^3.10.4",
"@faustwp/cli": "^3.3.4",
"@faustwp/core": "^3.3.4",
"@faustwp/core": "^3.4.0",
"@wordpress/base-styles": "^6.15.0",
"@wordpress/block-library": "^9.10.0",
"classnames": "^2.5.1",
Expand Down
80 changes: 64 additions & 16 deletions packages/faustwp-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,53 @@
# @faustwp/core

## 3.4.0

### Minor Changes

- ec26ac4: Feat: Added support `next/dynamic` imports for templates to reduce initial bundle size in a way that's backwards compatible with static imports.

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.

It's recommended you migrate to dynamic imports by updating your template file. Here's an example:

```js title=src/wp-templates/index.js
// Old Static Templates
import category from './category';
import tag from './tag';
import frontPage from './front-page';
import page from './page';
import single from './single';

export default {
category,
tag,
'front-page': frontPage,
page,
single,
};

// New Dynamic Templates
import dynamic from 'next/dynamic';

const category = dynamic(() => import('./category.js'));
const tag = dynamic(() => import('./tag.js'));
const frontPage = dynamic(() => import('./front-page.js'));
const page = dynamic(() => import('./page.js'));

// The above examples assume use of default exports. If you are using named exports you'll need to handle that:
const single = dynamic(() => import('./single.js').then(mod => mod.Single));

export default {
category,
tag,
'front-page': frontPage,
page,
single,
};
```

For further info see the Next.js docs on the use of [`next/dynamic`](https://nextjs.org/docs/pages/guides/lazy-loading#nextdynamic-1).

## 3.3.6

### Patch Changes
Expand Down Expand Up @@ -94,11 +142,11 @@
export default function Sitemap() {}

export function getServerSideProps(ctx) {
return getSitemapProps(ctx, {
sitemapIndexPath: '/sitemap_index.xml', // RankMath changes the default sitemap path to this
frontendUrl: process.env.NEXT_PUBLIC_SITE_URL,
sitemapPathsToIgnore: ['/wp-sitemap-users-*'],
});
return getSitemapProps(ctx, {
sitemapIndexPath: '/sitemap_index.xml', // RankMath changes the default sitemap path to this
frontendUrl: process.env.NEXT_PUBLIC_SITE_URL,
sitemapPathsToIgnore: ['/wp-sitemap-users-*'],
});
}
```

Expand Down Expand Up @@ -202,7 +250,7 @@

```jsx
<ToolbarItem onKeyDown={handleKeyDown} onClick={handleClick}>
Log Out
Log Out
</ToolbarItem>
```

Expand Down Expand Up @@ -308,18 +356,18 @@
import { FaustPage } from '@faustwp/core';

type GetPageData = {
generalSettings: {
title: string;
};
generalSettings: {
title: string;
};
};

type PageProps = {
myProp: string;
myProp: string;
};

const Page: FaustPage<GetPageData, PageProps> = (props) => {
const { myProp, data } = props;
return <></>;
const { myProp, data } = props;
return <></>;
};
```

Expand Down Expand Up @@ -388,9 +436,9 @@
export default function Sitemap() {}

export function getServerSideProps(context) {
return getSitemapProps(context, {
frontendUrl: process.env.FRONTEND_URL, // Set the FRONTEND_URL as an env var
});
return getSitemapProps(context, {
frontendUrl: process.env.FRONTEND_URL, // Set the FRONTEND_URL as an env var
});
}
```

Expand Down Expand Up @@ -420,7 +468,7 @@
import { FaustHooks, FaustPlugin } from '@faustwp/core';

export class MyPlugin implements FaustPlugin {
apply(hooks: FaustHooks) {}
apply(hooks: FaustHooks) {}
}
```

Expand Down
2 changes: 1 addition & 1 deletion packages/faustwp-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@faustwp/core",
"version": "3.3.6",
"version": "3.4.0",
"description": "Faust is a framework that aims to make headless WordPress as streamlined as classic WordPress for both developers and publishers",
"main": "dist/cjs/index.js",
"module": "dist/mjs/index.js",
Expand Down