Skip to content

Commit

Permalink
1793: plugin system - take out of experimental (wpengine#1807)
Browse files Browse the repository at this point in the history
* init commit

* updated config to support experimentalPlugins and new plugins

* warning added around experimentalPlugins deprecation and plugins usage

* updated experimentalPlugins to plugins

* changeset

* Update mighty-geese-cover.md

* updated per PR for console logging consistency

* Update .changeset/mighty-geese-cover.md

Co-authored-by: John Parris <[email protected]>

---------

Co-authored-by: John Parris <[email protected]>
  • Loading branch information
matthewguywright and mindctrl authored Feb 21, 2024
1 parent aad3bbc commit 0b0a88e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/mighty-geese-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@faustwp/core': minor
---

The Faust.js plugin system is no longer experimental. We have maintained backward compatibility as we move towards deprecating `experimentalPlugins` in favor of `plugins` in the Faust config file `faust.config.js`. We recommend moving over to using `plugins` instead of `experimentalPlugins` as soon as possible as a future version will remove the experimental config option.
2 changes: 1 addition & 1 deletion examples/next/block-support/faust.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import possibleTypes from './possibleTypes.json';
**/
export default setConfig({
templates,
experimentalPlugins: [],
plugins: [],
possibleTypes,
});
2 changes: 1 addition & 1 deletion examples/next/custom-toolbar/faust.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CustomToolbar } from "./plugins/CustomToolbar";
**/
export default setConfig({
templates,
experimentalPlugins: [new CustomToolbar()],
plugins: [new CustomToolbar()],
experimentalToolbar: true,
possibleTypes,
});
2 changes: 1 addition & 1 deletion examples/next/faustwp-getting-started/faust.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import possibleTypes from './possibleTypes.json';
**/
export default setConfig({
templates,
experimentalPlugins: [],
plugins: [],
experimentalToolbar: true,
possibleTypes,
});
18 changes: 16 additions & 2 deletions packages/faustwp-core/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import isString from 'lodash/isString.js';
import once from 'lodash/once.js';
import { WordPressTemplate } from '../getWordPressProps.js';
import { hooks, FaustPlugin } from '../wpHooks/index.js';
import { warnLog } from '../utils/log.js';

export interface FaustConfig {
templates: { [key: string]: WordPressTemplate };
experimentalToolbar?: boolean;
loginPagePath?: string;
experimentalPlugins: FaustPlugin[];
plugins: FaustPlugin[];
possibleTypes: PossibleTypesMap;
basePath?: string;
/**
Expand All @@ -33,11 +35,23 @@ export function setConfig(_config: FaustConfig) {
return once(() => {
config = _config;

const { experimentalPlugins: plugins } = _config;
const { experimentalPlugins, plugins } = _config;
// combine both sets of plugins until experimentalPlugins is fully deprecated
const allSupportedPlugins = [
...(experimentalPlugins || []),
...(plugins || []),
];

plugins?.forEach((plugin) => {
allSupportedPlugins?.forEach((plugin) => {
plugin?.apply?.(hooks);
});

if (experimentalPlugins?.length) {
// log to cli if experimentalPlugins is used since it's being deprecated
warnLog(
'Plugin System: The "experimentalPlugins" configuration option will be deprecated in the near future. Please use "plugins" instead in the faust.config.js.',
);
}
})();
}

Expand Down

0 comments on commit 0b0a88e

Please sign in to comment.