Closed
Description
Preliminary Checks
- This issue is not a duplicate. Before opening a new issue, please search existing issues: https://github.com/gatsbyjs/gatsby/issues
- This issue is not a question, feature request, RFC, or anything other than a bug report directly related to Gatsby. Please post those things in GitHub Discussions: https://github.com/gatsbyjs/gatsby/discussions
Description
Gatsby is not picking up the default values nor validating the plugin schema in a gatsby-node.ts file
export const pluginOptionsSchema: GatsbyNode["pluginOptionsSchema"] = ({
Joi,
}) => {
return Joi.object({
siteId: Joi.string().required(),
templatePath: Joi.string()
.default("/src/templates")
});
};
export const onPreInit: GatsbyNode["onPreInit"] = (args, options) => {
console.log("options: ", options);
// options does NOT contain default values, nor is validation on required options performed
};
but if I change it to plain js (gatsby-node.js) with commonjs exports everything's fine:
exports.pluginOptionsSchema = ({ Joi }) => {
return Joi.object({
siteId: Joi.string().required(),
templatePath: Joi.string()
.default("/src/templates")
});
};
exports.onPreInit = (args, options) => {
console.log("options: ", options);
// options contain default values as expected
};
Reproduction Link
see code
Steps to Reproduce
- Create plugin in
/plugins/test-plugin
- Add gatsby-node.ts with above code
- Run gatsby develop
...
Expected Result
Validation should be performed on the plugin options schema, and default option values set
Actual Result
No defaults are set, and validation is not performed
Environment
System:
OS: macOS 12.5
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
Yarn: 1.22.5 - ~/.yarn/bin/yarn
npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
Browsers:
Chrome: 108.0.5359.124
Firefox: 107.0.1
Safari: 15.6
npmPackages:
gatsby: ^5.3.3 => 5.3.3
gatsby-plugin-google-gtag: ^5.2.0 => 5.2.0
gatsby-plugin-image: ^3.2.0 => 3.2.0
gatsby-plugin-manifest: ^5.2.0 => 5.2.0
gatsby-plugin-root-import: ^2.0.9 => 2.0.9
gatsby-plugin-sharp: ^5.2.0 => 5.2.0
gatsby-plugin-sitemap: ^6.0.0 => 6.2.0
gatsby-plugin-styled-components: ^6.0.0 => 6.2.0
gatsby-source-filesystem: ^5.2.0 => 5.2.0
gatsby-transformer-sharp: ^5.2.0 => 5.2.0
npmGlobalPackages:
gatsby: 5.3.3
Config Flags
No response