Skip to content

Commit 65739fc

Browse files
LekoArtsaxe312ger
andauthored
fix(gatsby-plugin-mdx): Hashing and pluginOptions (#36387)
Co-authored-by: Benedikt Rötsch <[email protected]>
1 parent 0744cfd commit 65739fc

File tree

4 files changed

+28
-25
lines changed

4 files changed

+28
-25
lines changed

packages/gatsby-plugin-mdx/src/get-source-plugins-as-remark-plugins.ts

+20-21
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,29 @@ export async function getSourcePluginsAsRemarkPlugins({
3232

3333
const userPlugins = userPluginsFiltered.map(plugin => {
3434
const requiredPlugin = plugin.module
35-
const wrappedGatsbyPlugin: Pluggable<Array<any>> =
36-
function wrappedGatsbyPlugin() {
37-
// eslint-disable-next-line @babel/no-invalid-this
38-
const mdxNode = getNode(this.data(`mdxNodeId`) as string)
35+
const wrappedGatsbyPlugin: Pluggable<any> = function wrappedGatsbyPlugin() {
36+
// eslint-disable-next-line @babel/no-invalid-this
37+
const mdxNode = getNode(this.data(`mdxNodeId`) as string)
3938

40-
return async function transformer(markdownAST): Promise<any> {
41-
// Execute gatsby-remark-* plugin
42-
await requiredPlugin(
43-
{
44-
markdownAST,
45-
markdownNode: mdxNode,
46-
getNode,
47-
getNodesByType,
48-
get files() {
49-
return getNodesByType(`File`)
50-
},
51-
pathPrefix,
52-
reporter,
53-
cache,
39+
return async function transformer(markdownAST): Promise<any> {
40+
// Execute gatsby-remark-* plugin
41+
await requiredPlugin(
42+
{
43+
markdownAST,
44+
markdownNode: mdxNode,
45+
getNode,
46+
getNodesByType,
47+
get files() {
48+
return getNodesByType(`File`)
5449
},
55-
plugin.options || {}
56-
)
57-
}
50+
pathPrefix,
51+
reporter,
52+
cache,
53+
},
54+
plugin.pluginOptions || {}
55+
)
5856
}
57+
}
5958

6059
return wrappedGatsbyPlugin
6160
})

packages/gatsby-plugin-mdx/src/plugin-options.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ProcessorOptions } from "@mdx-js/mdx"
22
import type { GatsbyCache, NodePluginArgs, PluginOptions, Store } from "gatsby"
33
import deepmerge from "deepmerge"
4-
import type { IPluginRefObject } from "gatsby-plugin-utils/types"
4+
import type { IPluginInfo } from "gatsby-plugin-utils/types"
55
import { getSourcePluginsAsRemarkPlugins } from "./get-source-plugins-as-remark-plugins"
66
import rehypeMdxMetadataExtractor from "./rehype-metadata-extractor"
77
import { remarkMdxHtmlPlugin } from "./remark-mdx-html-plugin"
@@ -10,7 +10,7 @@ import { remarkPathPlugin } from "./remark-path-prefix-plugin"
1010
export interface IMdxPluginOptions {
1111
extensions: [string]
1212
mdxOptions: ProcessorOptions
13-
gatsbyRemarkPlugins?: [IPluginRefObject]
13+
gatsbyRemarkPlugins?: [IPluginInfo]
1414
}
1515
interface IHelpers {
1616
getNode: NodePluginArgs["getNode"]
@@ -84,7 +84,7 @@ export const enhanceMdxOptions: EnhanceMdxOptions = async (
8484

8585
if (typeof requiredPlugin.setParserPlugins === `function`) {
8686
for (const parserPlugin of requiredPlugin.setParserPlugins(
87-
plugin.options || {}
87+
plugin.pluginOptions || {}
8888
)) {
8989
if (Array.isArray(parserPlugin)) {
9090
const [parser, parserPluginOptions] = parserPlugin

packages/gatsby-plugin-utils/src/types.ts

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ export interface IPluginInfo {
3333

3434
/** Options passed to the plugin */
3535
pluginOptions?: IPluginInfoOptions
36+
37+
module?: any
38+
modulePath?: string
3639
}
3740

3841
export interface IPluginInfoOptions {

packages/gatsby/src/utils/js-chunk-names.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ export function generateComponentChunkName(componentPath: string): string {
5252
* File names should not exceed 255 characters
5353
* minus 12 for `component---`
5454
* minus 7 for `.js.map`
55+
* minus 20 for `-[hash].js`
5556
*/
56-
const maxLength = 236
57+
const maxLength = 215
5758
const shouldTruncate = name.length > maxLength
5859

5960
/**

0 commit comments

Comments
 (0)