pxt-microbit
pxt-microbit copied to clipboard
Question: How can local dependencies be referenced in pxt.json
Hello,
When developing my micro:bit v2 application using TypeScript, I forked an external dependency on GitHub to make a few changes that I want to propose as a Pull Request.
Now I need to link that local dependency to my application to test my changes.
In the pxt.json, dependencies are defined in this fashion:
{
"dependencies": {
"core": "*",
"sonarbit": "github:elecfreaks/pxt-sonarbit#v1.0.9"
}
}
I tried to change the above to:
{
"dependencies": {
"core": "*",
"sonarbit": "local:../pxt-sonarbit"
}
}
However, when running mkc build, I got
Exception: Error: Error: extension sonarbit is missing pxt.json
The pxt.json file is there. Even when changing the relative path to an absolute path, the same happened.
I know it's possible to achieve what I'm after in the online MakeCode editor. Is the same possible locally when using mkc?
The online editor is so inconvenient for day-to-day development.
@jwunderl ?
You can commit and use the hash in the dependency, so: "sonarbit": "github:<your_fork>#<commit_hash>"
This can make a mess of version control in your fork unfortunately. I've never been able to get proper local development to work. Would love to hear that it's possible and I've been missing something.
You can commit and use the hash in the dependency, so: "sonarbit": "github:<your_fork>#<commit_hash>"
This can make a mess of version control in your fork unfortunately. I've never been able to get proper local development to work. Would love to hear that it's possible and I've been missing something.
Yeah, that’s totally doable. But it's a workaround, forcing me to push every single change I need to test.
For day-to-day development, there are so many obstacles that I'm slowly giving up on micro:bit. It's meant to be very beginner-friendly, but it's not meant for serious coding IMO.
When doing extension development where I temporarily have it in the local ./libs tree, I use dependency references like this:
{
"dependencies": {
"core": "file:../core",
"sonarbit": "file:../pxt-sonarbit"
}
}
Yeah. That's why I thought it would work for regular projects too. For some reason, it does not.