Comments (2)
And any calls to require()
seem to need to be replaced by require().default
:
<CodeSurfer
steps={[
{
- code: require('!raw-loader!./exampleTypescript.ts').replace(
+ code: require('!raw-loader!./exampleTypescript.ts').default.replace(
/ *\/\/ prettier-ignore\n/g,
'',
),
lang: 'ts',
},
]}
progress={0}
/>
from mdx-deck.
Maybe it has something to do with the usage of @mdx-js/loader
in the Gatsby plugin.
Maybe a better way would be to use the approach taken by gatsby-plugin-mdx
, with exports.preprocessSource
and other methods.
Funny enough, it does appear to recognize the change (below are logs from the browser, which has recognized there is a change):
client.js:241 [HMR] bundle rebuilding
client.js:250 [HMR] bundle rebuilt in 926ms
process-update.js:51 [HMR] Checking for updates on the server...
process-update.js:125 [HMR] Updated modules:
process-update.js:127 [HMR] - ../../slideDecks/deck25/index.mdx
process-update.js:127 [HMR] - ./.cache/_this_is_virtual_fs_path_/$virtual/async-requires.js
process-update.js:132 [HMR] App is up to date.
Seems like the issue may be fundamental in the MDX loader 🤔
Currently HMR with fast-refresh doesn't work with mdx files. The reason is that mdx loader generate modules with 2 exports (
MDXContent
that is actual react component andfrontmatter
) which doesn't satisfy restrictions of fast refresh for there to be single export.
Next.js also had to do loader work for Fast Refresh: vercel/next.js#15851
Ahhh, gaearon's comment here is the reason for the hot reloading problems!
Just wanted to add I ran into this and then realized I had
export const stuff = ...
at the top of my MDX, which caused the bailout. I removed that and it worked.
The problem is my usage of a custom theme:
export { theme } from './theme'
So I'll figure out how to strip that (maybe with a custom webpack loader added after @mdx-js/loader
).
Or if I can find a way to override the theme
prop that's being passed to the wrapper
component that mdx-deck
is passing to <MDXProvider />
... 🤔
Not sure where this theme
prop is magically coming from actually...
After diving through a bunch of @mdx-deck/*
and @mdx-js/*
packages, closest that I came to finding it was this layoutProps
thing here: @mdx/mdx/mdx-hast-to-jsx.js
Actually, maybe a simpler way would be to override the theme globally for all of my slide decks - since I only use a single theme... 🤔
Ended up going with another patch-package
patch to patch @mdx-deck/gatsby-plugin/src/theme.js
to add in my custom theme 😅
from mdx-deck.
Related Issues (20)
- Integrating the presentation into existing website causes number of issues
- gatsby-theme-mdx-deck not working
- Running mdx-deck <filename>.mdx constantly forces a repaint in the browser and the recreation of gatsby pages. HOT 10
- Simple create, resize and fill div
- Presenter mode inaccessible in Windows HOT 3
- Infinite loop when using steps HOT 6
- Readme Clarity
- File-Import in 4.1.1 not working
- Can't start mdx-deck on localhost HOT 1
- Still supported/maintained? HOT 8
- Is there a way to run custom javascript on deck load and slid transitions ? HOT 3
- Can't resolve 'mdx-deck/themes' HOT 2
- Is there support for remark plugins?
- Can this be used with Next.Js HOT 2
- Trying to get in touch with you regarding a security issue
- Import partial slide decks? HOT 4
- "Getting Started" steps do not work HOT 4
- Need custom shortcuts
- Not running on Gatsbyjs 4 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mdx-deck.