@@ -65,33 +65,22 @@ import type {DocFile, FullVersion} from './types';
65
65
import type { RuleSetRule } from 'webpack' ;
66
66
67
67
// MDX loader is not 100% deterministic, leading to cache invalidation issue
68
- // It's possible to use env variables to build a site in different flavors
69
- // and you end-up using stale mdx loader cache hits
70
- //
71
- // This doesn't happen when modifying docusaurus.config.js because doing so
72
- // will invalidate the entire site cache, but can happen with other changes
73
- // such as env variables, or after creating a new docs version.
74
- //
75
- // This happens notably because of the resolveMarkdownLink() callback
76
- // Depending on docs options suck as "lastVersion" and "onlyIncludeVersions"
77
- // When docs versions change over time, the callback may behave differently
78
- // Depending on env variables, @site/docs/my-doc.md might resolve to:
79
- // - /docs/my-doc
80
- // - docs/next/my-doc
81
- // - docs/<otherVersion>/my-doc
82
- //
83
- // To avoid this kind of problem, we invalidate the mdx cache
84
- // whenever docs versions are updated in any way
68
+ // This permits to invalidate the MDX loader cache entries when content changes
69
+ // Problem documented here: https://github.com/facebook/docusaurus/pull/10934
70
+ // TODO this is not a perfect solution, find better?
85
71
async function createMdxLoaderDependencyFile ( {
86
72
dataDir,
73
+ options,
87
74
versionsMetadata,
88
75
} : {
89
76
dataDir : string ;
77
+ options : PluginOptions ;
90
78
versionsMetadata : VersionMetadata [ ] ;
91
79
} ) {
92
80
const filePath = path . join ( dataDir , '__mdx-loader-dependency.json' ) ;
93
81
// the cache is invalidated whenever this file content changes
94
82
const fileContent = {
83
+ options,
95
84
versionsMetadata,
96
85
} ;
97
86
await fs . ensureDir ( dataDir ) ;
@@ -146,6 +135,7 @@ export default async function pluginContentDocs(
146
135
dependencies : [
147
136
await createMdxLoaderDependencyFile ( {
148
137
dataDir,
138
+ options,
149
139
versionsMetadata,
150
140
} ) ,
151
141
] ,
0 commit comments