DEV Community

Ramu Narasinga
Ramu Narasinga

Posted on • Edited on

What if CodeMirror v6 dev setup uses Degit internally to clone packages?

In this article, we explore the idea of using Degit to clone/download core/non core packages required to setup the development environment for CodeMirror V6.

Image description

Pay attention to the run function in the above image.

run("git", ["clone", origin, pkg.dir])
Enter fullscreen mode Exit fullscreen mode

What this does is that it uses child_process execSyncFile API to execute this “git clone” command programmatically in Node.js. But instead of cloning, what if we use degit? you might be wondering what a degit is at this point.

Degit

degit makes copies of git repositories. When you run degit some-user/some-repo, it will find the latest commit on https://github.com/some-user/some-repo and download the associated tar file to ~/.degit/some-user/some-repo/commithash.tar.gz if it doesn’t already exist locally. (This is much quicker than using git clone, because you’re not downloading the entire git history.)

Degit can quickly download the latest commit of any public repository but this does not get you the entire

history.

Would it make sense to use Degit?

Short answer — no, long answer would be CodeMirror does not use monorepo architecture and clones public repositories from CodeMirror organization. What Degit does is it downloads the latest commit of all these packages that make up the CodeMirror but it does not have entire git history

Without Git history, you can’t blame anyone, you wouldn’t know who changed a line of code when there is no history. Degit can be used to download templates/starters to download the latest commit and make it quick. Remotion uses degit

Since this clone execution is part of development setup for CodeMirror v6, you would definitely want the entire git history of core/non core packages used.

About me:

Hey, my name is Ramu Narasinga. I study large open-source projects and create content about their codebase architecture and best practices, sharing it through articles, videos.

I am open to work on an interesting project. Send me an email at ramu.narasinga@gmail.com

My Github - https://github.com/ramu-narasinga
My website - https://ramunarasinga.com
My Youtube channel - https://www.youtube.com/@thinkthroo
Learning platform - https://thinkthroo.com
Codebase Architecture - https://app.thinkthroo.com/architecture
Best practices - https://app.thinkthroo.com/best-practices
Production-grade projects - https://app.thinkthroo.com/production-grade-projects

References

1. https://github.com/Rich-Harris/degit

2. https://github.com/codemirror/dev/blob/main/bin/cm.js#L90C7-L90C45

3. https://github.com/codemirror/dev/blob/main/bin/cm.js#L64-L66

4. https://github.com/remotion-dev/remotion/blob/main/packages/create-video/src/degit.ts

Top comments (0)