From 0b137e9eceb6e7b4f83635cd1dc589466756ffcf Mon Sep 17 00:00:00 2001 From: axe312ger Date: Tue, 31 May 2022 11:40:25 +0200 Subject: [PATCH] chore: clean up typings --- packages/gatsby-plugin-mdx/src/gatsby-node.ts | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/gatsby-plugin-mdx/src/gatsby-node.ts b/packages/gatsby-plugin-mdx/src/gatsby-node.ts index d7bc48cad276d..e5dbd89912c15 100644 --- a/packages/gatsby-plugin-mdx/src/gatsby-node.ts +++ b/packages/gatsby-plugin-mdx/src/gatsby-node.ts @@ -21,6 +21,16 @@ export const onCreateWebpackConfig: GatsbyNode["onCreateWebpackConfig"] = ( const fileMap = new Map() fileNodes.forEach(fileNode => fileMap.set(fileNode.absolutePath, fileNode)) + const loaderOptions: Options = { + useDynamicImport: true, + providerImportSource: `@mdx-js/react`, + } + + const gatsbyLoaderOptions: IMdxLoaderOptions = { + fileMap, + pluginOptions: pluginOptions as IMdxPluginOptions, + } + actions.setWebpackConfig({ module: { rules: [ @@ -30,17 +40,11 @@ export const onCreateWebpackConfig: GatsbyNode["onCreateWebpackConfig"] = ( loaders.js(), { loader: `@mdx-js/loader`, - options: { - useDynamicImport: true, - providerImportSource: `@mdx-js/react`, - } as Options, + options: loaderOptions, }, { loader: path.join(`gatsby-plugin-mdx`, `dist`, `mdx-loader`), - options: { - fileMap, - pluginOptions, - } as IMdxLoaderOptions, + options: gatsbyLoaderOptions, }, ], },