Skip to content

Commit

Permalink
fix: this usage adpot to vite@3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
csr632 committed Sep 7, 2022
1 parent ee4a732 commit 5f3d06c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function createPlugin(
const reactRefresh = reactRefreshPlugins.find(p => p.transform);
const transform = createTransformer(root, namedImports)

this.transform = async function (code, id, ssr) {
mdxPlugin.transform = async function (code, id, ssr) {
if (/\.mdx?$/.test(id)) {
const mdxOptions = mergeOptions(globalMdxOptions, getMdxOptions?.(id))
mdxOptions.filepath = id
Expand Down
7 changes: 4 additions & 3 deletions src/viteMdxTransclusion/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ export function viteMdxTransclusion(
*/
let astCache: MdxAstCache

return {
const plugin = {
name: 'mdx:transclusion',
configResolved({ root, logger }) {
let watcher: FSWatcher | undefined

this.configureServer = (server) => {
plugin.configureServer = (server) => {
watcher = server.watcher
importMap = new ImportMap()
astCache = new LRUCache({
Expand All @@ -67,7 +67,7 @@ export function viteMdxTransclusion(
})
}

this.buildStart = function () {
plugin.buildStart = function () {
globalMdxOptions.remarkPlugins.push(
remarkTransclusion({
astCache,
Expand Down Expand Up @@ -98,4 +98,5 @@ export function viteMdxTransclusion(
}
}
}
return plugin
}

0 comments on commit 5f3d06c

Please sign in to comment.