Unfork Blockly
Stay organized with collections
Save and categorize content based on your preferences.
This document is aimed at developers that have previously forked Blockly and are
looking to update to a recent release of Blockly, without patching the library.
Although this seems like a daunting task, there are a few steps that you can
take to make the process more manageable.
Understand Unforking
Using mainline Blockly means you are using a recently released version of
Blockly, and all of your customizations use public Blockly APIs without
monkeypatching. Unforking is the work you need to do to implement your fork's
custom functionality with mainline APIs.
Simple Unforking Cases
Below are two common reasons you might have forked, and solutions for how to
return to mainline:
- You created your own blocks and generators without changing any Blockly
code: To unfork in this situation, you can simply move your custom blocks
and generators out of the Blockly repository and into your own application's
code. You should then be able to then update your Blockly version.
- You added custom functionality on the Blockly namespace without changing
any Blockly code: For example, you added custom fields or helper methods
only used by your own application. To unfork in this situation, move this
custom code to your own application outside of the Blockly repository. You
should then be able to then update your Blockly version.
Extensive Unforking Case
Determine forked functionality
The final reason we see users fork is to patch Blockly to create custom
functionality that they perceive isn't included upstream at the time. If your
fork is significantly out of date, we may have already added the functionality
you need, either as plugins or in
core. Knowing what features you added in your fork can provide a roadmap for
what features you will need to update.
Understand the architecture
Once you understand the features that use fork-specific APIs, consider:
- For each feature using the fork, is there a way to replicate it using
Blockly APIs?
- If it seems as though you can't replicate the feature using Blockly APIs,
please reach out to us through the forum or file an issue on
GitHub. Our team will
then investigate adding APIs to enable your customization.
Determine your unforking path
The next step is to actually begin the process of implementing the new Blockly
based architecture for features using the fork. There are two main approaches
you can take:
- Upgrade Blockly and see what breaks: You will immediately see the areas
in your code that need to be updated. You can use this combined with what
you already know is custom behavior to guide your development.
- Refactor your code to separate your features from Blockly: This requires
you to gain a deep understanding of which features are custom to your fork
and which came from Blockly. Once your code is fully separated, replace your
old version of Blockly with the most recent version, then fix any remaining
integration issues.
Moving Forward
Here are a few rules that you should follow as a Blockly developer in the
future:
- In general, you shouldn't add new classes to the Blockly namespace. You can
register custom
fields
or other registrable classes without declaring them inside of the Blockly
repository or on the Blockly namespace.
- You shouldn't rely on Blockly's build tools in order to compile your own
application. We don't consider our build tools to be part of the public API,
so we may make changes to them which break your application. You are
responsible for compiling your application should you wish to do so.
Reach Out
The Blockly team is available through the Blockly
Forum! If you run into any issues during
the unforking process feel free to post them there and we can help.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-23 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-23 UTC."],[],[],null,["# Unfork Blockly\n\nThis document is aimed at developers that have previously forked Blockly and are\nlooking to update to a recent release of Blockly, without patching the library.\nAlthough this seems like a daunting task, there are a few steps that you can\ntake to make the process more manageable.\n\nUnderstand Unforking\n--------------------\n\nUsing mainline Blockly means you are using a recently released version of\nBlockly, and all of your customizations use public Blockly APIs without\nmonkeypatching. Unforking is the work you need to do to implement your fork's\ncustom functionality with mainline APIs.\n\nSimple Unforking Cases\n----------------------\n\nBelow are two common reasons you might have forked, and solutions for how to\nreturn to mainline:\n\n- **You created your own blocks and generators without changing any Blockly\n code**: To unfork in this situation, you can simply move your custom blocks and generators out of the Blockly repository and into your own application's code. You should then be able to then update your Blockly version.\n- **You added custom functionality on the Blockly namespace without changing\n any Blockly code**: For example, you added custom fields or helper methods only used by your own application. To unfork in this situation, move this custom code to your own application outside of the Blockly repository. You should then be able to then update your Blockly version.\n\nExtensive Unforking Case\n------------------------\n\n### Determine forked functionality\n\nThe final reason we see users fork is to patch Blockly to create custom\nfunctionality that they perceive isn't included upstream at the time. If your\nfork is significantly out of date, we may have already added the functionality\nyou need, either as [plugins](/blockly/guides/programming/plugin_overview) or in\ncore. Knowing what features you added in your fork can provide a roadmap for\nwhat features you will need to update.\n\n### Understand the architecture\n\nOnce you understand the features that use fork-specific APIs, consider:\n\n- For each feature using the fork, is there a way to replicate it using Blockly APIs?\n- If it seems as though you can't replicate the feature using Blockly APIs, please reach out to us through the forum or file an issue on [GitHub](https://github.com/google/blockly/issues/new/choose). Our team will then investigate adding APIs to enable your customization.\n\n### Determine your unforking path\n\nThe next step is to actually begin the process of implementing the new Blockly\nbased architecture for features using the fork. There are two main approaches\nyou can take:\n\n- **Upgrade Blockly and see what breaks**: You will immediately see the areas in your code that need to be updated. You can use this combined with what you already know is custom behavior to guide your development.\n- **Refactor your code to separate your features from Blockly**: This requires you to gain a deep understanding of which features are custom to your fork and which came from Blockly. Once your code is fully separated, replace your old version of Blockly with the most recent version, then fix any remaining integration issues.\n\nMoving Forward\n--------------\n\nHere are a few rules that you should follow as a Blockly developer in the\nfuture:\n\n- In general, you shouldn't add new classes to the Blockly namespace. You can register [custom\n fields](https://developers.google.com/blockly/guides/create-custom-blocks/fields/customizing-fields/creating) or other registrable classes without declaring them inside of the Blockly repository or on the Blockly namespace.\n- You shouldn't rely on Blockly's build tools in order to compile your own application. We don't consider our build tools to be part of the public API, so we may make changes to them which break your application. You are responsible for compiling your application should you wish to do so.\n\nReach Out\n---------\n\nThe Blockly team is available through the [Blockly\nForum](https://groups.google.com/g/blockly)! If you run into any issues during\nthe unforking process feel free to post them there and we can help."]]