JReinhold / mdx-deck-live-code

A component for mdx-deck to live code in your slides. 🤯
https://reinhold.is/live-coding-in-slides
Other
202 stars 18 forks source link

CI doesn't test that the example works with the source package - only the published package #3

Closed JReinhold closed 3 years ago

JReinhold commented 5 years ago

The problem

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 /examplefolder, however this leads to problems with peerDependencies such as react and styled-components.

The solutions

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
  1. What is the least amount of work/commands required to do this (eg. can we make do with only linking mdx-deck?
  2. Can we somehow cache these links on CI, they take quite a long time to execute.

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