jreinhold / mdx-deck-live-code Goto Github PK
View Code? Open in Web Editor NEWA component for mdx-deck to live code in your slides. 🤯
Home Page: https://reinhold.is/live-coding-in-slides
License: Other
A component for mdx-deck to live code in your slides. 🤯
Home Page: https://reinhold.is/live-coding-in-slides
License: Other
Does this currently support Typescript. I at least cannot get it to work with typescript
Ideally when running CI, we want to test that the example builds with the package from the current commit.
Currently it just downloads the latest published version of the package from the npm registry (using yarn install
). The most straightforward fix is to link the sources using yarn link
in the /example
folder, however this leads to problems with peerDependencies such as react
and styled-components
.
It might be possible to mitigate this by linking the sources' dependencies as well, to those that are installed in the /example
directory. This was originally proposed by Dan on StackOverflow
I don't think yarn support relative links, so we might have to use npm for this.
Something like:
# in project dir
yarn install
cd example
yarn install
npm link ../
cd ..
npm link ./example/node_modules/mdx-deck
npm link ./example/node_modules/styled-components
npm link ./example/node_modules/react
mdx-deck
?An alternative solution is to just copy the /dist
folder into the example's node_modules
.
Something like (untested)
rm -r ./example/node_modules/mdx-deck-live-code/*
cp -r {dist,package.json} ./example/node_modules/mdx-deck-live-code
Currently react-live
uses Bublé under the hood to transpile the code. Bublé doesn't support everything mdx-deck
does, which creates an unexpected experience for the developer, such as class properties not being supported.
We could try to use @babel/standalone
to transpile the code before it enters the <LiveProvider />
, but it would still go through Bublé, and had some difficulties making Babel and Bublé play nice together, so this needs further investigation. This method is discussed here: FormidableLabs/react-live#67
Code snippets for further usage:
import { transform } from '@babel/standalone';
...
<LiveProvider
code={code}
transformCode={transpileWithBabel}
{...providerProps}
>
...
const transpileWithBabel = (input: string) =>
transform(input, {
presets: ['es2017', 'react'],
plugins:['proposal-class-properties']
}).code;
For presets and plugins supported by @babel/standalone
see https://github.com/babel/babel/blob/master/packages/babel-standalone/src/index.js
The current iteration of mdx-deck-live-code
was made for [email protected]
, and doesn't seem to work with [email protected]
. Another unfortunate consequence of this, is that it doesn't work with the CodeSandbox mdx-deck
template.
The main reason it doesn't work, is the fact that mdx-deck
switched from styled-components
to emotion
in version 2. There may be other reasons it doesn't work, but at the moment that is the only one I know of.
To fix this, a (non exhaustive) todo list could look like:
styled-components
to emotion
mdx-deck-live-code
to v2, as this is probably a breaking changemdx-deck
[email protected]
as well, unless it is so big a change that it needs it's own PR.Everyone is welcomed to give this a go.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.